3 Authors: Baohua Yang@IBM, Denghui Huang@IBM
10 from restlib import * # noqa
11 from testmodule import TestModule
16 class HostTracker(TestModule):
18 Test for the host tracker..
19 Start 2-layer tree topology network. e.g., in Mininet, run
20 'sudo mn --controller=remote,ip=127.0.0.1 --mac --topo tree,2'
23 def __init__(self, restSubContext='/controller/nb/v2/hosttracker', user=DEFAULT_USER, password=DEFAULT_PWD,
24 container=DEFAULT_CONTAINER, contentType='json', prefix=DEFAULT_PREFIX):
25 super(self.__class__, self).__init__(restSubContext, user, password, container, contentType, prefix)
29 The name is suggested to match the NB API.
30 list all active hosts, should be done after using h1 ping h2 in mininet
32 return super(self.__class__, self).get_entries(['hosts/active', 'hosts/inactive'], 'hostConfig')
34 def add_host(self, name, body):
38 super(self.__class__, self).add_entry('address', name, body)
40 def remove_host(self, name):
44 super(self.__class__, self).remove_entry('address', name)
46 def test_host_operations(self, name, body):
48 Test host operations, like adding and removing.
49 >>> HostTracker().test_host_operations('10.0.1.4',
50 {'nodeType': 'OF', 'dataLayerAddress': '5e:bf:79:84:10:a6', 'vlan': '1',
51 'nodeId': '00:00:00:00:00:00:00:03', 'nodeConnectorId': '9',
52 'networkAddress': '10.0.1.4', 'staticHost': True, 'nodeConnectorType': 'OF'})
55 return super(self.__class__, self).test_add_remove_operations(['hosts/active', 'hosts/inactive'], 'address',