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>
This commit is contained in:
parent
fd7a4e6119
commit
51baabb9ee
@ -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 '_'
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user