summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMADA Hideki <yamada.hideki@po.ntts.co.jp>2013-03-28 18:50:28 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-03-31 18:13:26 +0900
commit51baabb9ee9cffc7c49bc22dc202bc55feadb4e7 (patch)
treecc2a52ad8087b8e9809feef248e031782210a24e
parentfd7a4e61197cbc6657b64f3658178081b059a762 (diff)
ryu-client: support Topology REST API
Signed-off-by: YAMADA Hideki <yamada.hideki@po.ntts.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rwxr-xr-xbin/ryu-client5
-rw-r--r--ryu/app/client.py34
2 files changed, 39 insertions, 0 deletions
diff --git a/bin/ryu-client b/bin/ryu-client
index 292ee261..ea3a3eaa 100755
--- a/bin/ryu-client
+++ b/bin/ryu-client
@@ -23,6 +23,7 @@ from ryu.app.client import OFPClient
from ryu.app.client import QuantumIfaceClient
from ryu.app.client import SwitchConfClient
from ryu.app.client import TunnelClient
+from ryu.app.client import TopologyClient
def client_test():
@@ -41,6 +42,7 @@ def client_test():
tun_client = TunnelClient(address)
sc_client = SwitchConfClient(address)
qi_client = QuantumIfaceClient(address)
+ topo_client = TopologyClient(address)
commands = {
'list_nets': lambda a: sys.stdout.write(ofp_client.get_networks()),
@@ -87,6 +89,9 @@ def client_test():
qi_client.get_network_id(a[1])),
'qi_create_net_id': lambda a: qi_client.create_network_id(a[1], a[2]),
'qi_update_net_id': lambda a: qi_client.update_network_id(a[1], a[2]),
+
+ 'topo_list_switches': lambda a: topo_client.list_switches(),
+ 'topo_list_links': lambda a: topo_client.list_links(),
}
# allow '-', instead of '_'
diff --git a/ryu/app/client.py b/ryu/app/client.py
index 32b645ee..52dae7c7 100644
--- a/ryu/app/client.py
+++ b/ryu/app/client.py
@@ -245,3 +245,37 @@ class QuantumIfaceClientV1_0(RyuClientBase):
QuantumIfaceClient = QuantumIfaceClientV1_0
+
+
+class TopologyClientV1_0(RyuClientBase):
+ version = 'v1.0'
+
+ # /topology/switches
+ # /topology/switches/{dpid}
+ # /topology/links
+ # /topology/links/{dpid}
+ _path_switches = 'topology/switches'
+ _path_links = 'topology/links'
+
+ def __init__(self, address):
+ super(TopologyClientV1_0, self).__init__(self.version, address)
+
+ # dpid: string representation (see ryu.lib.dpid)
+ # if None, get all
+ def list_switches(self, dpid=None):
+ uri = self._path_switches
+ if dpid:
+ uri += '/%s' % (dpid)
+
+ return self._do_request('GET', uri)
+
+ # dpid: string representation (see ryu.lib.dpid)
+ # if None, get all
+ def list_links(self, dpid=None):
+ uri = self._path_links
+ if dpid:
+ uri += '/%s' % (dpid)
+ return self._do_request('GET', uri)
+
+
+TopologyClient = TopologyClientV1_0