import sys
sys.path.append('..')
-from restlib import *
+from restlib import * # noqa
from testmodule import TestModule
sys.path.remove('..')
class SwitchManager(TestModule):
"""
Test for the switch manager, including read switch nodes.
- Start 2-layer tree topology network. e.g., in Mininet, run 'sudo mn --controller=remote,ip=127.0.0.1 --mac --topo tree,2'
+ Start 2-layer tree topology network. e.g., in Mininet, run
+ 'sudo mn --controller=remote,ip=127.0.0.1 --mac --topo tree,2'
"""
def __init__(self, restSubContext='/controller/nb/v2/switchmanager', user=DEFAULT_USER, password=DEFAULT_PWD,
Add a property to given node.
"""
suffix = 'node/' + node_type + '/' + node_id + '/property'
- r = super(self.__class__, self).update(suffix + '/' + property + '/' + str(value))
+ super(self.__class__, self).update(suffix + '/' + property + '/' + str(value))
def remove_property_from_node(self, node_type, node_id, property):
"""
Remove a property from given node.
"""
suffix = 'node/' + node_type + '/' + node_id + '/property'
- r = super(self.__class__, self).delete(suffix + '/' + property)
+ super(self.__class__, self).delete(suffix + '/' + property)
def add_property_to_nodeconnector(self, node_type, node_id, nc_type, nc_id, property, value):
"""
Add a property to given node.
"""
suffix = 'nodeconnector/' + node_type + '/' + node_id + '/' + nc_type + '/' + nc_id + '/property'
- r = super(self.__class__, self).update(suffix + '/' + property + '/' + str(value))
+ super(self.__class__, self).update(suffix + '/' + property + '/' + str(value))
def remove_property_from_nodeconnector(self, node_type, node_id, nc_type, nc_id, property):
"""
Add a property to given node.
"""
suffix = 'nodeconnector/' + node_type + '/' + node_id + '/' + nc_type + '/' + nc_id + '/property'
- r = super(self.__class__, self).delete(suffix + '/' + property)
+ super(self.__class__, self).delete(suffix + '/' + property)
def test_list_nodes(self):
"""
True
"""
result = []
- #current node properties should not include description
+ # current node properties should not include description
r = self.get_nodes()
v = [e['properties'].get(property) for e in r['nodeProperties'] if
e['node'] == {u'type': node_type, u'id': node_id}]
result.append(v == [{u'value': u'None'}] or v == [None])
- #After adding, current node properties should include description
+ # After adding, current node properties should include description
self.add_property_to_node(node_type, node_id, property, value)
r = self.get_nodes()
v = [e['properties'].get(property) for e in r['nodeProperties'] if
e['node'] == {u'type': node_type, u'id': node_id}]
result.append(v == [{u'value': value}])
- #After removing, current node properties should not include description
+ # After removing, current node properties should not include description
self.remove_property_from_node(node_type, node_id, property)
r = self.get_nodes()
v = [e['properties'].get(property) for e in r['nodeProperties'] if
"""
Test the add,remove,show actions on nodeconnector properties.
- >>> SwitchManager().test_nodeconnector_property_operations('OF','00:00:00:00:00:00:00:01','OF','1','bandwidth',1000)
+ >>> SwitchManager().test_nodeconnector_property_operations(
+ 'OF','00:00:00:00:00:00:00:01','OF','1','bandwidth',1000)
True
"""
result = []
node_suffix = 'node/' + node_type + '/' + node_id
- #default bw should be 10000000000L
+ # default bw should be 10000000000L
r = self.get_node(node_suffix)
default_value = [e['properties'][property] for e in r['nodeConnectorProperties'] if
property in e['properties'] and e['nodeconnector'] == {
u'node': {u'type': node_type, u'id': node_id}, u'type': nc_type, u'id': nc_id}]
- #After setting, the value should be the value
+ # After setting, the value should be the value
self.add_property_to_nodeconnector(node_type, node_id, nc_type, nc_id, property, value)
r = self.get_node(node_suffix)
current_value = [e['properties'][property] for e in r['nodeConnectorProperties'] if
property in e['properties'] and e['nodeconnector'] == {
u'node': {u'type': node_type, u'id': node_id}, u'type': nc_type, u'id': nc_id}]
result.append(current_value == [{'value': value}])
- #After removing, and restoring the default value, the bandwidth property should be default
+ # After removing, and restoring the default value, the bandwidth property should be default
self.remove_property_from_nodeconnector(node_type, node_id, nc_type, nc_id, property)
r = self.get_node(node_suffix)
v = [e['properties'][property] for e in r['nodeConnectorProperties'] if
property in e['properties'] and e['nodeconnector'] == {
u'node': {u'type': node_type, u'id': node_id}, u'type': nc_type, u'id': nc_id}]
result.append(current_value == default_value)
- return result == [True, True, True]
\ No newline at end of file
+ return result == [True, True, True]