summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2013-02-08 12:28:00 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-02-08 22:53:10 +0900
commit693a83dcbc75552bd84377e1a64c8b9efa20c791 (patch)
tree9a1b50e43fb7c5df4faa12087a2bee678421645c
parent68b19be5c4315da10b269d28a31a5216e038d290 (diff)
ryu/controller/network.py: add helper functions for tunnel updater
This will be used by tunnel app. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/controller/network.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/ryu/controller/network.py b/ryu/controller/network.py
index 2d32cb78..4663809c 100644
--- a/ryu/controller/network.py
+++ b/ryu/controller/network.py
@@ -180,8 +180,11 @@ class DPIDs(dict):
except KeyError:
raise PortNotFound(dpid=dpid, port=port_no, network_id=None)
- def get_ports(self, dpid):
- return self.get(dpid, {}).values()
+ def get_ports(self, dpid, network_id=None):
+ if network_id is None:
+ return self.get(dpid, {}).values()
+ return [p for p in self.get(dpid, {}).values()
+ if p.network_id == network_id]
def get_port(self, dpid, port_no):
try:
@@ -195,6 +198,9 @@ class DPIDs(dict):
except KeyError:
raise PortUnknown(dpid=dpid, port=port_no)
+ def get_networks(self, dpid):
+ return set(self[dpid].values())
+
def get_network_safe(self, dpid, port_no):
port = self.get(dpid, {}).get(port_no)
if port is None:
@@ -312,6 +318,9 @@ class Network(app_manager.RyuApp):
def has_network(self, network_id):
return self.networks.has_network(network_id)
+ def get_networks(self, dpid):
+ return self.dpids.get_networks(dpid)
+
def create_mac(self, network_id, dpid, port_no, mac_address):
self.dpids.set_mac(network_id, dpid, port_no, mac_address)
@@ -327,8 +336,8 @@ class Network(app_manager.RyuApp):
return []
return [mac_address]
- def get_ports(self, dpid):
- return self.dpids.get_ports(dpid)
+ def get_ports(self, dpid, network_id=None):
+ return self.dpids.get_ports(dpid, network_id)
def get_port(self, dpid, port_no):
return self.dpids.get_port(dpid, port_no)