Tuesday, April 10, 2012
[Open vSwitch] How to get port statistics from interface in OVS
1. Show the bridge info
> sudo ovs-vsctl show
result:
2909bfce-536e-4184-a5bb-507f0553abee
Bridge "br0"
Controller "tcp:10.6.186.244"
Port "br0"
Interface "br0"
type: internal
Port "eth3"
Interface "eth3"
Port "eth2"
Interface "eth2"
Port "eth1"
2. Get port statistics from interface
> sudo ovs-vsctl get Interface br0 statistics
result:
> sudo ovs-vsctl show
result:
2909bfce-536e-4184-a5bb-507f0553abee
Bridge "br0"
Controller "tcp:10.6.186.244"
Port "br0"
Interface "br0"
type: internal
Port "eth3"
Interface "eth3"
Port "eth2"
Interface "eth2"
Port "eth1"
2. Get port statistics from interface
> sudo ovs-vsctl get Interface br0 statistics
result:
{collisions=0,
rx_bytes=0,
rx_crc_err=0,
rx_dropped=0,
rx_errors=0,
rx_frame_err=0,
rx_over_err=0,
rx_packets=0,
tx_bytes=0,
tx_dropped=0,
tx_errors=0,
tx_packets=0}
Monday, April 9, 2012
[Python] How to use Decorators for Functions and Methods
When list_ports() is executed, Class ApiCall will be created for becoming a decorator to examine the arguments as follows:
import sys
class ApiCall(object):
"""A Decorator to add support for format and tenant overriding"""
def __init__(self, function):
self.function = function
def __get__(self, instance, owner):
def with_params(*args, **kwargs):
"""
Temporarily sets the format and tenant for this request
"""
(format, tenant) = (instance.format, instance.tenant)
if 'format' in kwargs:
instance.format = kwargs['format']
if 'tenant' in kwargs:
instance.tenant = kwargs['tenant']
ret = self.function(instance, *args)
(instance.format, instance.tenant) = (format, tenant)
return ret
return with_params
class Client(object):
def __init__(self, tenant=None, format="xml"):
self.tenant = tenant
self.format = format
@ApiCall
def list_ports(self, network):
"""
Fetches a list of ports on a given network
"""
return network
def main():
client = Client(tenant="AAA",format="xml")
client.list_ports('my network')
sys.exit(0)
if __name__ == "__main__":
main()
[Tutorial][Trema] Show Topology
Trema有一個很不錯的App, 可以利用toplogy與 topology_discovery App, 去產生topology graph…如下:
下列為Network emulation的設定檔內容
# virtual switches
vswitch("switch1") { datapath_id
"0x1" }
vswitch("switch2") { datapath_id
"0x2" }
vswitch("switch3") { datapath_id
"0x3" }
vswitch("switch4") { datapath_id
"0x4" }
vswitch("switch4") { datapath_id
"0x5" }
# virtual hosts
vhost("host1")
vhost("host2")
vhost("host3")
vhost("host4")
# virtual links
link "switch1",
"switch2"
link "switch1",
"switch3"
link "switch2",
"switch3"
link "switch2",
"switch4"
link "switch2",
"switch5"
link "switch3",
"switch4"
link "switch3", "switch5"
link "switch3", "switch5"
link "switch4",
"switch5"
link "switch4", "host1"
link "switch4", "host2"
link "switch5", "host3"
link "switch5", "host4"
Wednesday, April 4, 2012
[Tutorial] ovsdbmonitor GUI 設定步驟 (setup procedure)
The following steps are the setup procedure for running ovsdbmonitor GUI
(You have to make sure that your "PYTHONPATH" contains the path of openvswitch source path/python. )
1. 增加PYTHONPATH到 .bashrc
for example:
PYTHONPATH="${PYTHONPATH}:/home/liudanny/Source/openvswitch-1.2.2/python/"
Export PYTHONPATH
2. 增加一個symbolic link for ovsdb-client
sudo ln -s /usr/local/bin/ovsdb-client /usr/bin/ovsdb-client
3. 執行ovsdbmonitor
“your openswitch path”/ovsdb/ovsdbmonitor/ovsdbmonitor
4. 設定Host Properties:
Host name or IP: your openvswitch host
SSH Password: ***
Connect target: unix:/usr/local/var/run/openvswitch/db.sock
* 這個connect target 會與 啟動ovsdb-server daemon 的參數有相關 *
PYTHONPATH="${PYTHONPATH}:/home/liudanny/Source/openvswitch-1.2.2/python/"
Export PYTHONPATH
2. 增加一個symbolic link for ovsdb-client
sudo ln -s /usr/local/bin/ovsdb-client /usr/bin/ovsdb-client
3. 執行ovsdbmonitor
“your openswitch path”/ovsdb/ovsdbmonitor/ovsdbmonitor
4. 設定Host Properties:
Host name or IP: your openvswitch host
SSH Password: ***
Connect target: unix:/usr/local/var/run/openvswitch/db.sock
* 這個connect target 會與 啟動ovsdb-server daemon 的參數有相關 *
sudo ovsdb-server --remote=punix:/usr/local/var/ run/openvswitch/db.sock \
--remote=db: Open_vSwitch,manager_options \
--private- key=db:SSL,private_key \
-- certificate=db:SSL,certificate \
--bootstrap- ca-cert=db:SSL,ca_cert \
--pidfile --detach
5. 相關畫面 (可以看到ovs database 內的table content, 每個頁簽都代表一個table)
[Info] Quantum L3 Model and API
The following link is about adding L3 concept and APIs ( routing between Subnets) into OpenStack Quantum.
http://wiki.openstack.org/quantum-l3
The more information is here:
quantum-l3-service-spec-SumitNaiksatam-5.pdf
http://wiki.openstack.org/quantum-l3
The more information is here:
quantum-l3-service-spec-SumitNaiksatam-5.pdf
Monday, April 2, 2012
如何在Python內使用Singleton方法
# There is an example to do with Singleton in Python
def singleton(cls):
instances = {}
def getinstance():
if cls not in instances:
instances[cls] = cls()
return instances[cls]
return getinstance
@singleton
class MyClass():
def __init__(self):
self.data = "AAA"
if __name__ == "__main__":
obj_a = MyClass()
obj_a.data = "AAAA"
print obj_a, obj_a.data
obj_b = MyClass()
print obj_b, obj_b.data
Big Switch: the SDN Coffee Talks
Big Switch Networks Launches SDN Coffee Talks to Further Educate the
Broader IT Community on Software-Defined Networking (SDN)
the SDN Coffee Talks
http://www.bigswitch.com/sdn- coffee-talks/
Broader IT Community on Software-Defined Networking (SDN)
the SDN Coffee Talks
http://www.bigswitch.com/sdn-
[HowTo] Build up GRE Tunneling on Open vSwitch
// Create a bridge
ovs-vsctl add-br br0
// Build up GRE Tunnel on remote host's ip = x.x.x.x
ovs-vsctl add-port br0 gre0 -- set interface gre0 type=gre options:remote_ip=x.x.x.x
In this article, the author explains more info about GRE Tunneling in details.
http://d.hatena.ne.jp/kazuya_ax/20120420/1334928361
The way for him to build GRE Tunneling is as follows:
ovs-vsctl set interface gre0 type=gre options:remote_ip=x.x.x.x options:pmtud=false
ovs-vsctl add-br br0
// Build up GRE Tunnel on remote host's ip = x.x.x.x
ovs-vsctl add-port br0 gre0 -- set interface gre0 type=gre options:remote_ip=x.x.x.x
In this article, the author explains more info about GRE Tunneling in details.
http://d.hatena.ne.jp/kazuya_ax/20120420/1334928361
The way for him to build GRE Tunneling is as follows:
ovs-vsctl set interface gre0 type=gre options:remote_ip=x.x.x.x options:pmtud=false
Subscribe to:
Posts (Atom)