2008年6月18日星期三

EtherChannel Configuration

1. config multi interfaces at same time
  (config)# interface range fa0/21 - 24    ,or  fa0/21 , fa0/23

2. before config the new setting, the old setting in those interfaces must be remove firstly. (with command 'no')

3. there are 3 options for the channel-protocol: pagp, lacp, none
  the channel mode is depended by protocol:
   pagp:  'auto' or 'desirable'
   lacp:  'active' or 'passive'
   None: 'on'

 Note: the port-channel interfaces with channel mode marked as 'on'  will always up.

4. commands for checking etherChannel:
 - show etherchannel summary
SwitchC#show etherchannel summary
Flags:  D - down        P - in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        u - unsuitable for bundling
        U - in use      f - failed to allocate aggregator
        d - default port

Number of channel-groups in use: 4
Number of aggregators:           4

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SU)         LACP      Fa0/22(Pd)  Fa0/24(P)
2      Po2(SU)          -        Fa0/21(Pd)  Fa0/23(P)
3      Po3(SD)          -
5      Po5(SD)          -


- show interface portchannel 1
SwitchC#show interfaces port-channel 1 etherchannel
Port-channel1   (Primary aggregator)

Age of the Port-channel   = 0d:03h:45m:04s
Logical slot/port   = 1/0          Number of ports = 2
HotStandBy port = null
Port state          = Port-channel Ag-Inuse
Protocol            =   LACP

Ports in the Port-channel:

Index   Load   Port     EC state        No of bits
------+------+------+------------------+-----------
  0     00     Fa0/22   Active             0
  0     00     Fa0/24   Active             0

Time since last port bundled:    0d:00h:54m:00s    Fa0/24
Time since last port Un-bundled: 0d:01h:21m:08s    Fa0/24

--
Just do it!
Posted by Gmail on E61

2008年6月17日星期二

北京第一家埃塞俄比亚餐厅

在北京兆维工业园上课,中午找饭吃的时候发现了这家餐厅,在酒仙桥将台路上。
Have no idea if the photo can be attached..:(






--
Just do it!

mobile blog test

Hi, I post this by gmail on my Nokia E61!
--
Just do it!

Python与Hadoop

“Hadoop,一个全世界都在关注的项目。包括Google和IBM,Yahoo用Hadoop让大学来培训分布式计算的学生。IBM用其来做Cloud Computing 。Yahoo用它来做基础结构Yahoo搜索等。”

以上转贴Hadoop研究,一个研究讨论hadoop的中文平台。

Hadoop原来是Apache Lucene下的一个子项目,它最初是从Nutch项目中分离出来的专门负责分布式存储以及分布式运算的项目。简单地说来,Hadoop是一个可以更容易开发和运行处理大规模数据的软件平台。不过Hadoop是基于Java语言的,要想让Python也能用上Hadoop,有两种方法:一是利用Jpython将python编译为java代码,另一种方式则是使用Hadoop Streaming帮 助我们用非Java的编程语言使用MapReduce,Streaming用STDIN (标准输入)和STDOUT (标准输出)来和我们编写的Map和Reduce进行数据的交换数据。任何能够使用STDIN和STDOUT都可以用来编写MapReduce程序,比如 用Python的sys.stdin和sys.stdout。

这篇文章详细介绍了使用Hadoop streaming的方法。


Web.py模板系统的tips [2008-6-12]

在webpy的模板系统里,仅能使用由程序传过来的变量和类,以及一些基本的itorator语句,不直接支持在模板里使用python的语句。如下面webpy的模板里的range和len会被系统报错,称“range”和“len”没有被定义。对于这种情况,有人说不好,不方便;也有人说就是应该这样,表现逻辑应该和呈现逻辑就是要区分开来,不应该允许在模板中直接调用python代码。
<h1>$title</h1>
$ for x in range(len(itemlist)):
<li> $x </li>

但是,如果以上例子能使用range和len将会带来很大的便利而并不会mix up所谓的表现逻辑和呈现逻辑。该怎么办?在webpy的论坛了,我找到了答案;)
只要在“表现逻辑”里增加以下语句,你的“呈现逻辑”模板就再也不会报错啦!
web.template.Template.globals['len'] = len
web.template.Template.globals['range'] = range


后来又找到一个更强的用法:

web.template.Template.globals['py'] = web.storify(__builtins__)

这样,你就可以使用py.xxx的方式,使用python所有的语句和函数啦!

2008年6月6日星期五

又一个模板系统: Tenjin

在webpy的论坛上看到一个叫makoto kuwata的日本人, 介绍被他成为世界上最快的模板引擎(the fastest template engine in the world..),Tenjin。他的网站在这儿
根据介绍,该引擎有多个语言版本,java,php,ruby,当然也包括python。其速度比我常用的cheetach要快大约三倍,比Django的模板系统要快9倍等,详细的测试结果可以看下面:

MacOS X 10.4 Tiger, Intel CoreDuo 1.83GHz, Memory 2GB
Language Template Engine Test#1(sec) Test#2(sec)
Python(2.5.1) pyTenjin (0.6.1) 6.96 5.61
Cheetah (2.0) 20.36 19.82
Django (0.9.5) 71.33 59.80
Myghty (1.1) 107.88 19.30
Kid (0.9.6) 380.24 378.96
Genshi (0.4.4) 560.30 271.69
Mako (0.1.9) 17.78 13.49
Templetor (web.py 0.22) 428.19 61.53
Ruby(1.8.6) rbTenjin (0.6.0) 7.34 4.52
eruby (1.0.5) 12.29 11.53
ERB(def_method) (Ruby1.8.6) 36.73 5.85
PHP(5.2.0) phpTenjin (0.0.1) 5.39 3.64
Smarty (2.6.18) 10.84 10.21
Perl(5.8.8) plTenjin (0.0.1) 10.42 5.72
Template-Toolkit(XS) (2.18) 103.58 26.30
HTML::Template (2.9) 46.70 30.21
JS(spidermonkey) jsTenjin (0.0.1) 19.00 12.98
JS(Rhino, JDK5) jsTenjin (0.0.1) 24.29 19.15
Java(JDK5) Velocity (1.4) 22.80 11.41
Velocity (1.5) 20.01 8.42

2008年6月2日星期一

简单易用的python WEB框架:web.py

正在做一个管理GPRS网元配置的小工具,打算用web来做界面。也许是用python太容易实现web应用了,用python的web框架有好多,因为只是做为界面使用,因此找一个轻量级的就可以。目前轻量级的有Karrigell和web.py。Karrigell试用了一下,还算挺方便的,但由于它可以使用多答四种类型的脚本语言,有时反而让人无所适从。后来决定用web.py。

web.py用起来真是非常地简单:
1. 首先按web.py的helloworld程序的基础架构写几行引用web的语句
2. 列出需要用到的url与对应的处理函数名
3. 根据以上列出的列表,编写实现相应功能的的class
4. 运行你的程序!

以下是我尝试的第一个例子:
import web

urls = ('/', 'index')

class index:
def GET(self):
print "Hello, world!"

if __name__ == "__main__":
web.run(urls, globals())

运行后,在命令窗口会出现以下信息:
http://0.0.0.0:8080/

这时候,你打开浏览器,输入以上地址,就可以看到你的第一个web页面了!

web.py的官方网站上还提供了中文版的Tutorial,想了解更多的信息可以参考一下。