initial refactor for all variables named objid
This commit is contained in:
parent
f283c747cc
commit
9517740704
46 changed files with 346 additions and 353 deletions
|
@ -37,11 +37,11 @@ from core.service import ServiceManager
|
|||
EMANE_SERVICES = "zebra|OSPFv3MDR|IPForward"
|
||||
|
||||
|
||||
def node_message(objid, name, emulation_server=None, node_type=NodeTypes.DEFAULT, model=None):
|
||||
def node_message(_id, name, emulation_server=None, node_type=NodeTypes.DEFAULT, model=None):
|
||||
"""
|
||||
Convenience method for creating a node TLV messages.
|
||||
|
||||
:param int objid: node id
|
||||
:param int _id: node id
|
||||
:param str name: node name
|
||||
:param str emulation_server: distributed server name, if desired
|
||||
:param core.enumerations.NodeTypes node_type: node type
|
||||
|
@ -50,7 +50,7 @@ def node_message(objid, name, emulation_server=None, node_type=NodeTypes.DEFAULT
|
|||
:rtype: core.api.coreapi.CoreNodeMessage
|
||||
"""
|
||||
values = [
|
||||
(NodeTlvs.NUMBER, objid),
|
||||
(NodeTlvs.NUMBER, _id),
|
||||
(NodeTlvs.TYPE, node_type.value),
|
||||
(NodeTlvs.NAME, name),
|
||||
(NodeTlvs.EMULATION_SERVER, emulation_server),
|
||||
|
@ -118,7 +118,7 @@ def command_message(node, command):
|
|||
"""
|
||||
flags = MessageFlags.STRING.value | MessageFlags.TEXT.value
|
||||
return CoreExecMessage.create(flags, [
|
||||
(ExecuteTlvs.NODE, node.objid),
|
||||
(ExecuteTlvs.NODE, node.id),
|
||||
(ExecuteTlvs.NUMBER, 1),
|
||||
(ExecuteTlvs.COMMAND, command)
|
||||
])
|
||||
|
|
|
@ -40,7 +40,7 @@ class TestDistributed:
|
|||
|
||||
# create local node
|
||||
message = conftest.node_message(
|
||||
objid=1,
|
||||
_id=1,
|
||||
name="n1",
|
||||
model="host"
|
||||
)
|
||||
|
@ -48,7 +48,7 @@ class TestDistributed:
|
|||
|
||||
# create distributed node and assign to distributed server
|
||||
message = conftest.node_message(
|
||||
objid=2,
|
||||
_id=2,
|
||||
name="n2",
|
||||
emulation_server=cored.distributed_server,
|
||||
model="host"
|
||||
|
@ -57,7 +57,7 @@ class TestDistributed:
|
|||
|
||||
# create distributed switch and assign to distributed server
|
||||
message = conftest.node_message(
|
||||
objid=3,
|
||||
_id=3,
|
||||
name="n3",
|
||||
emulation_server=cored.distributed_server,
|
||||
node_type=NodeTypes.SWITCH
|
||||
|
@ -106,7 +106,7 @@ class TestDistributed:
|
|||
|
||||
# create local node
|
||||
message = conftest.node_message(
|
||||
objid=1,
|
||||
_id=1,
|
||||
name="n1",
|
||||
model="host"
|
||||
)
|
||||
|
@ -114,7 +114,7 @@ class TestDistributed:
|
|||
|
||||
# create distributed node and assign to distributed server
|
||||
message = conftest.node_message(
|
||||
objid=2,
|
||||
_id=2,
|
||||
name="n2",
|
||||
emulation_server=cored.distributed_server,
|
||||
node_type=NodeTypes.PHYSICAL,
|
||||
|
@ -124,7 +124,7 @@ class TestDistributed:
|
|||
|
||||
# create distributed switch and assign to distributed server
|
||||
message = conftest.node_message(
|
||||
objid=3,
|
||||
_id=3,
|
||||
name="n3",
|
||||
node_type=NodeTypes.SWITCH
|
||||
)
|
||||
|
@ -173,7 +173,7 @@ class TestDistributed:
|
|||
|
||||
# create local node
|
||||
message = conftest.node_message(
|
||||
objid=1,
|
||||
_id=1,
|
||||
name="n1",
|
||||
model="host"
|
||||
)
|
||||
|
@ -181,7 +181,7 @@ class TestDistributed:
|
|||
|
||||
# create distributed node and assign to distributed server
|
||||
message = conftest.node_message(
|
||||
objid=2,
|
||||
_id=2,
|
||||
name=distributed_address,
|
||||
emulation_server=cored.distributed_server,
|
||||
node_type=NodeTypes.TUNNEL
|
||||
|
|
|
@ -160,7 +160,7 @@ class TestConf:
|
|||
session.mobility.set_model(wlan_node, BasicRangeModel)
|
||||
|
||||
# then
|
||||
assert session.mobility.get_model_config(wlan_node.objid, BasicRangeModel.name)
|
||||
assert session.mobility.get_model_config(wlan_node.id, BasicRangeModel.name)
|
||||
|
||||
def test_model_set_error(self, session):
|
||||
# given
|
||||
|
|
|
@ -69,7 +69,7 @@ class TestCore:
|
|||
# link nodes to net node
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, net_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, net_node.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
@ -96,7 +96,7 @@ class TestCore:
|
|||
# link nodes to ptp net
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, ptp_node.id, interface_one=interface)
|
||||
|
||||
# get node client for testing
|
||||
client = node_one.client
|
||||
|
@ -152,7 +152,7 @@ class TestCore:
|
|||
# link nodes to ptp net
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, ptp_node.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
@ -199,7 +199,7 @@ class TestCore:
|
|||
# link nodes
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, wlan_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, wlan_node.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
@ -229,7 +229,7 @@ class TestCore:
|
|||
# link nodes
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, wlan_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, wlan_node.id, interface_one=interface)
|
||||
|
||||
# configure mobility script for session
|
||||
config = {
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestEmane:
|
|||
|
||||
# configure tdma
|
||||
if model == EmaneTdmaModel:
|
||||
session.emane.set_model_config(emane_network.objid, EmaneTdmaModel.name, {
|
||||
session.emane.set_model_config(emane_network.id, EmaneTdmaModel.name, {
|
||||
"schedule": os.path.join(_DIR, "../examples/tdma/schedule.xml")
|
||||
})
|
||||
|
||||
|
@ -57,7 +57,7 @@ class TestEmane:
|
|||
for i, node in enumerate([node_one, node_two]):
|
||||
node.setposition(x=150 * (i + 1), y=150)
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, emane_network.objid, interface_one=interface)
|
||||
session.add_link(node.id, emane_network.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
|
|
@ -192,10 +192,10 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node(session.id, node.objid)
|
||||
response = client.get_node(session.id, node.id)
|
||||
|
||||
# then
|
||||
assert response.node.id == node.objid
|
||||
assert response.node.id == node.id
|
||||
|
||||
@pytest.mark.parametrize("node_id, expected", [
|
||||
(1, True),
|
||||
|
@ -237,7 +237,7 @@ class TestGrpc:
|
|||
assert response.result is expected
|
||||
if expected is True:
|
||||
with pytest.raises(KeyError):
|
||||
assert session.get_object(node.objid)
|
||||
assert session.get_object(node.id)
|
||||
|
||||
def test_get_hooks(self, grpc_server):
|
||||
# given
|
||||
|
@ -307,11 +307,11 @@ class TestGrpc:
|
|||
switch = session.add_node(_type=NodeTypes.SWITCH)
|
||||
node = session.add_node()
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, switch.objid, interface)
|
||||
session.add_link(node.id, switch.id, interface)
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node_links(session.id, switch.objid)
|
||||
response = client.get_node_links(session.id, switch.id)
|
||||
|
||||
# then
|
||||
assert len(response.links) == 1
|
||||
|
@ -323,7 +323,7 @@ class TestGrpc:
|
|||
switch = session.add_node(_type=NodeTypes.SWITCH)
|
||||
node = session.add_node()
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, switch.objid, interface)
|
||||
session.add_link(node.id, switch.id, interface)
|
||||
|
||||
# then
|
||||
with pytest.raises(grpc.RpcError):
|
||||
|
@ -339,9 +339,9 @@ class TestGrpc:
|
|||
assert len(switch.all_link_data(0)) == 0
|
||||
|
||||
# then
|
||||
interface = interface_helper.create_interface(node.objid, 0)
|
||||
interface = interface_helper.create_interface(node.id, 0)
|
||||
with client.context_connect():
|
||||
response = client.add_link(session.id, node.objid, switch.objid, interface)
|
||||
response = client.add_link(session.id, node.id, switch.id, interface)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -354,7 +354,7 @@ class TestGrpc:
|
|||
node = session.add_node()
|
||||
|
||||
# then
|
||||
interface = interface_helper.create_interface(node.objid, 0)
|
||||
interface = interface_helper.create_interface(node.id, 0)
|
||||
with pytest.raises(grpc.RpcError):
|
||||
with client.context_connect():
|
||||
client.add_link(session.id, 1, 3, interface)
|
||||
|
@ -366,14 +366,14 @@ class TestGrpc:
|
|||
switch = session.add_node(_type=NodeTypes.SWITCH)
|
||||
node = session.add_node()
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, switch.objid, interface)
|
||||
session.add_link(node.id, switch.id, interface)
|
||||
options = core_pb2.LinkOptions(bandwidth=30000)
|
||||
link = switch.all_link_data(0)[0]
|
||||
assert options.bandwidth != link.bandwidth
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.edit_link(session.id, node.objid, switch.objid, options)
|
||||
response = client.edit_link(session.id, node.id, switch.id, options)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -388,11 +388,11 @@ class TestGrpc:
|
|||
interface_one = ip_prefixes.create_interface(node_one)
|
||||
node_two = session.add_node()
|
||||
interface_two = ip_prefixes.create_interface(node_two)
|
||||
session.add_link(node_one.objid, node_two.objid, interface_one, interface_two)
|
||||
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
|
||||
link_node = None
|
||||
for node_id in session.objects:
|
||||
node = session.objects[node_id]
|
||||
if node.objid not in {node_one.objid, node_two.objid}:
|
||||
if node.id not in {node_one.id, node_two.id}:
|
||||
link_node = node
|
||||
break
|
||||
assert len(link_node.all_link_data(0)) == 1
|
||||
|
@ -400,7 +400,7 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
response = client.delete_link(
|
||||
session.id, node_one.objid, node_two.objid, interface_one.id, interface_two.id)
|
||||
session.id, node_one.id, node_two.id, interface_one.id, interface_two.id)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -414,7 +414,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_wlan_config(session.id, wlan.objid)
|
||||
response = client.get_wlan_config(session.id, wlan.id)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -429,11 +429,11 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_wlan_config(session.id, wlan.objid, {range_key: range_value})
|
||||
response = client.set_wlan_config(session.id, wlan.id, {range_key: range_value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
config = session.mobility.get_model_config(wlan.objid, BasicRangeModel.name)
|
||||
config = session.mobility.get_model_config(wlan.id, BasicRangeModel.name)
|
||||
assert config[range_key] == range_value
|
||||
|
||||
def test_get_emane_config(self, grpc_server):
|
||||
|
@ -475,7 +475,7 @@ class TestGrpc:
|
|||
)
|
||||
config_key = "platform_id_start"
|
||||
config_value = "2"
|
||||
session.emane.set_model_config(emane_network.objid, EmaneIeee80211abgModel.name, {config_key: config_value})
|
||||
session.emane.set_model_config(emane_network.id, EmaneIeee80211abgModel.name, {config_key: config_value})
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
|
@ -483,7 +483,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
assert len(response.configs) == 1
|
||||
assert emane_network.objid in response.configs
|
||||
assert emane_network.id in response.configs
|
||||
|
||||
def test_set_emane_model_config(self, grpc_server):
|
||||
# given
|
||||
|
@ -499,11 +499,11 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_emane_model_config(
|
||||
session.id, emane_network.objid, EmaneIeee80211abgModel.name, {config_key: config_value})
|
||||
session.id, emane_network.id, EmaneIeee80211abgModel.name, {config_key: config_value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
config = session.emane.get_model_config(emane_network.objid, EmaneIeee80211abgModel.name)
|
||||
config = session.emane.get_model_config(emane_network.id, EmaneIeee80211abgModel.name)
|
||||
assert config[config_key] == config_value
|
||||
|
||||
def test_get_emane_model_config(self, grpc_server):
|
||||
|
@ -518,7 +518,7 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_emane_model_config(
|
||||
session.id, emane_network.objid, EmaneIeee80211abgModel.name)
|
||||
session.id, emane_network.id, EmaneIeee80211abgModel.name)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -540,7 +540,7 @@ class TestGrpc:
|
|||
client = CoreGrpcClient()
|
||||
session = grpc_server.coreemu.create_session()
|
||||
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
|
||||
session.mobility.set_model_config(wlan.objid, Ns2ScriptedMobility.name, {})
|
||||
session.mobility.set_model_config(wlan.id, Ns2ScriptedMobility.name, {})
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
|
@ -548,18 +548,18 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
assert len(response.configs) > 0
|
||||
assert wlan.objid in response.configs
|
||||
assert wlan.id in response.configs
|
||||
|
||||
def test_get_mobility_config(self, grpc_server):
|
||||
# given
|
||||
client = CoreGrpcClient()
|
||||
session = grpc_server.coreemu.create_session()
|
||||
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
|
||||
session.mobility.set_model_config(wlan.objid, Ns2ScriptedMobility.name, {})
|
||||
session.mobility.set_model_config(wlan.id, Ns2ScriptedMobility.name, {})
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_mobility_config(session.id, wlan.objid)
|
||||
response = client.get_mobility_config(session.id, wlan.id)
|
||||
|
||||
# then
|
||||
assert len(response.groups) > 0
|
||||
|
@ -574,11 +574,11 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_mobility_config(session.id, wlan.objid, {config_key: config_value})
|
||||
response = client.set_mobility_config(session.id, wlan.id, {config_key: config_value})
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
config = session.mobility.get_model_config(wlan.objid, Ns2ScriptedMobility.name)
|
||||
config = session.mobility.get_model_config(wlan.id, Ns2ScriptedMobility.name)
|
||||
assert config[config_key] == config_value
|
||||
|
||||
def test_mobility_action(self, grpc_server):
|
||||
|
@ -586,12 +586,12 @@ class TestGrpc:
|
|||
client = CoreGrpcClient()
|
||||
session = grpc_server.coreemu.create_session()
|
||||
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
|
||||
session.mobility.set_model_config(wlan.objid, Ns2ScriptedMobility.name, {})
|
||||
session.mobility.set_model_config(wlan.id, Ns2ScriptedMobility.name, {})
|
||||
session.instantiate()
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.mobility_action(session.id, wlan.objid, core_pb2.MOBILITY_STOP)
|
||||
response = client.mobility_action(session.id, wlan.id, core_pb2.MOBILITY_STOP)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -642,7 +642,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node_service(session.id, node.objid, "IPForward")
|
||||
response = client.get_node_service(session.id, node.id, "IPForward")
|
||||
|
||||
# then
|
||||
assert len(response.service.configs) > 0
|
||||
|
@ -655,7 +655,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.get_node_service_file(session.id, node.objid, "IPForward", "ipforward.sh")
|
||||
response = client.get_node_service_file(session.id, node.id, "IPForward", "ipforward.sh")
|
||||
|
||||
# then
|
||||
assert response.data is not None
|
||||
|
@ -670,11 +670,11 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_node_service(session.id, node.objid, service_name, (), validate, ())
|
||||
response = client.set_node_service(session.id, node.id, service_name, (), validate, ())
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
service = session.services.get_service(node.objid, service_name, default_service=True)
|
||||
service = session.services.get_service(node.id, service_name, default_service=True)
|
||||
assert service.validate == validate
|
||||
|
||||
def test_set_node_service_file(self, grpc_server):
|
||||
|
@ -688,7 +688,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.set_node_service_file(session.id, node.objid, service_name, file_name, file_data)
|
||||
response = client.set_node_service_file(session.id, node.id, service_name, file_name, file_data)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -704,7 +704,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.service_action(session.id, node.objid, service_name, core_pb2.SERVICE_STOP)
|
||||
response = client.service_action(session.id, node.id, service_name, core_pb2.SERVICE_STOP)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -736,7 +736,7 @@ class TestGrpc:
|
|||
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
|
||||
node = session.add_node()
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, wlan.objid, interface)
|
||||
session.add_link(node.id, wlan.id, interface)
|
||||
link_data = wlan.all_link_data(0)[0]
|
||||
queue = Queue()
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def command_message(node, command):
|
|||
:param command: command to execute
|
||||
:return: packed execute message
|
||||
"""
|
||||
tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.objid)
|
||||
tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.id)
|
||||
tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.NUMBER.value, 1)
|
||||
tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.COMMAND.value, command)
|
||||
return coreapi.CoreExecMessage.pack(MessageFlags.STRING.value | MessageFlags.TEXT.value, tlv_data)
|
||||
|
@ -52,8 +52,8 @@ def switch_link_message(switch, node, address, prefix_len):
|
|||
:param prefix_len: prefix length of address
|
||||
:return: packed link message
|
||||
"""
|
||||
tlv_data = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.objid)
|
||||
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.N2_NUMBER.value, node.objid)
|
||||
tlv_data = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.id)
|
||||
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.N2_NUMBER.value, node.id)
|
||||
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.TYPE.value, LinkTypes.WIRED.value)
|
||||
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.INTERFACE2_NUMBER.value, 0)
|
||||
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.INTERFACE2_IP4.value, address)
|
||||
|
@ -70,7 +70,7 @@ def run_cmd(node, exec_cmd):
|
|||
:return: Returns the result of the command
|
||||
"""
|
||||
# Set up the command api message
|
||||
# tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.objid)
|
||||
# tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.id)
|
||||
# tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.NUMBER.value, 1)
|
||||
# tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.COMMAND.value, exec_cmd)
|
||||
# message = coreapi.CoreExecMessage.pack(MessageFlags.STRING.value | MessageFlags.TEXT.value, tlv_data)
|
||||
|
|
|
@ -11,7 +11,7 @@ def create_ptp_network(session, ip_prefixes):
|
|||
# link nodes to net node
|
||||
interface_one = ip_prefixes.create_interface(node_one)
|
||||
interface_two = ip_prefixes.create_interface(node_two)
|
||||
session.add_link(node_one.objid, node_two.objid, interface_one, interface_two)
|
||||
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
@ -43,7 +43,7 @@ class TestLinks:
|
|||
inteface_two = ip_prefixes.create_interface(node_two)
|
||||
|
||||
# when
|
||||
session.add_link(node_one.objid, node_two.objid, interface_one, inteface_two)
|
||||
session.add_link(node_one.id, node_two.id, interface_one, inteface_two)
|
||||
|
||||
# then
|
||||
assert node_one.netif(interface_one.id)
|
||||
|
@ -56,7 +56,7 @@ class TestLinks:
|
|||
interface_one = ip_prefixes.create_interface(node_one)
|
||||
|
||||
# when
|
||||
session.add_link(node_one.objid, node_two.objid, interface_one)
|
||||
session.add_link(node_one.id, node_two.id, interface_one)
|
||||
|
||||
# then
|
||||
assert node_two.all_link_data(0)
|
||||
|
@ -69,7 +69,7 @@ class TestLinks:
|
|||
interface_two = ip_prefixes.create_interface(node_two)
|
||||
|
||||
# when
|
||||
session.add_link(node_one.objid, node_two.objid, interface_two=interface_two)
|
||||
session.add_link(node_one.id, node_two.id, interface_two=interface_two)
|
||||
|
||||
# then
|
||||
assert node_one.all_link_data(0)
|
||||
|
@ -81,7 +81,7 @@ class TestLinks:
|
|||
node_two = session.add_node(_type=NodeTypes.SWITCH)
|
||||
|
||||
# when
|
||||
session.add_link(node_one.objid, node_two.objid)
|
||||
session.add_link(node_one.id, node_two.id)
|
||||
|
||||
# then
|
||||
assert node_one.all_link_data(0)
|
||||
|
@ -91,7 +91,7 @@ class TestLinks:
|
|||
node_one = session.add_node()
|
||||
node_two = session.add_node(_type=NodeTypes.SWITCH)
|
||||
interface_one = ip_prefixes.create_interface(node_one)
|
||||
session.add_link(node_one.objid, node_two.objid, interface_one)
|
||||
session.add_link(node_one.id, node_two.id, interface_one)
|
||||
interface = node_one.netif(interface_one.id)
|
||||
output = utils.check_cmd(["tc", "qdisc", "show", "dev", interface.localname])
|
||||
assert "delay" not in output
|
||||
|
@ -105,7 +105,7 @@ class TestLinks:
|
|||
link_options.bandwidth = 5000000
|
||||
link_options.per = 25
|
||||
link_options.dup = 25
|
||||
session.update_link(node_one.objid, node_two.objid,
|
||||
session.update_link(node_one.id, node_two.id,
|
||||
interface_one_id=interface_one.id, link_options=link_options)
|
||||
|
||||
# then
|
||||
|
@ -121,12 +121,12 @@ class TestLinks:
|
|||
node_two = session.add_node()
|
||||
interface_one = ip_prefixes.create_interface(node_one)
|
||||
interface_two = ip_prefixes.create_interface(node_two)
|
||||
session.add_link(node_one.objid, node_two.objid, interface_one, interface_two)
|
||||
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
|
||||
assert node_one.netif(interface_one.id)
|
||||
assert node_two.netif(interface_two.id)
|
||||
|
||||
# when
|
||||
session.delete_link(node_one.objid, node_two.objid, interface_one.id, interface_two.id)
|
||||
session.delete_link(node_one.id, node_two.id, interface_one.id, interface_two.id)
|
||||
|
||||
# then
|
||||
assert not node_one.netif(interface_one.id)
|
||||
|
@ -155,7 +155,7 @@ class TestLinks:
|
|||
# change bandwidth in bits per second
|
||||
link_options = LinkOptions()
|
||||
link_options.bandwidth = 500000
|
||||
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
|
||||
session.update_link(node_one.id, node_two.id, link_options=link_options)
|
||||
|
||||
# run iperf again
|
||||
stdout = iperf(node_one, node_two, ip_prefixes)
|
||||
|
@ -186,7 +186,7 @@ class TestLinks:
|
|||
# change bandwidth in bits per second
|
||||
link_options = LinkOptions()
|
||||
link_options.per = 50
|
||||
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
|
||||
session.update_link(node_one.id, node_two.id, link_options=link_options)
|
||||
|
||||
# run iperf again
|
||||
stdout = iperf(node_one, node_two, ip_prefixes)
|
||||
|
@ -216,7 +216,7 @@ class TestLinks:
|
|||
# change delay in microseconds
|
||||
link_options = LinkOptions()
|
||||
link_options.delay = 1000000
|
||||
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
|
||||
session.update_link(node_one.id, node_two.id, link_options=link_options)
|
||||
|
||||
# run ping for delay information again
|
||||
stdout = ping_output(node_one, node_two, ip_prefixes)
|
||||
|
@ -249,7 +249,7 @@ class TestLinks:
|
|||
# change jitter in microseconds
|
||||
link_options = LinkOptions()
|
||||
link_options.jitter = 1000000
|
||||
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
|
||||
session.update_link(node_one.id, node_two.id, link_options=link_options)
|
||||
|
||||
# run iperf again
|
||||
stdout = iperf(node_one, node_two, ip_prefixes)
|
||||
|
|
|
@ -48,7 +48,7 @@ class TestNodes:
|
|||
update_options.set_position(x=position_value, y=position_value)
|
||||
|
||||
# when
|
||||
session.update_node(node.objid, update_options)
|
||||
session.update_node(node.id, update_options)
|
||||
|
||||
# then
|
||||
assert node.position.x == position_value
|
||||
|
@ -59,11 +59,11 @@ class TestNodes:
|
|||
node = session.add_node()
|
||||
|
||||
# when
|
||||
session.delete_node(node.objid)
|
||||
session.delete_node(node.id)
|
||||
|
||||
# then
|
||||
with pytest.raises(KeyError):
|
||||
session.get_object(node.objid)
|
||||
session.get_object(node.id)
|
||||
|
||||
@pytest.mark.parametrize("net_type", NET_TYPES)
|
||||
def test_net(self, session, net_type):
|
||||
|
|
|
@ -55,10 +55,10 @@ class TestServices:
|
|||
node = session.add_node()
|
||||
|
||||
# when
|
||||
session.services.set_service_file(node.objid, SERVICE_ONE, file_name, "# test")
|
||||
session.services.set_service_file(node.id, SERVICE_ONE, file_name, "# test")
|
||||
|
||||
# then
|
||||
service = session.services.get_service(node.objid, SERVICE_ONE)
|
||||
service = session.services.get_service(node.id, SERVICE_ONE)
|
||||
all_files = session.services.all_files(service)
|
||||
assert service
|
||||
assert all_files and len(all_files) == 1
|
||||
|
@ -69,8 +69,8 @@ class TestServices:
|
|||
node = session.add_node()
|
||||
|
||||
# when
|
||||
session.services.set_service(node.objid, SERVICE_ONE)
|
||||
session.services.set_service(node.objid, SERVICE_TWO)
|
||||
session.services.set_service(node.id, SERVICE_ONE)
|
||||
session.services.set_service(node.id, SERVICE_TWO)
|
||||
|
||||
# then
|
||||
all_configs = session.services.all_configs()
|
||||
|
@ -189,8 +189,8 @@ class TestServices:
|
|||
node = session.add_node()
|
||||
|
||||
# when
|
||||
session.services.set_service(node.objid, my_service.name)
|
||||
custom_my_service = session.services.get_service(node.objid, my_service.name)
|
||||
session.services.set_service(node.id, my_service.name)
|
||||
custom_my_service = session.services.get_service(node.id, my_service.name)
|
||||
custom_my_service.startup = ("sh custom.sh",)
|
||||
|
||||
# then
|
||||
|
@ -205,13 +205,13 @@ class TestServices:
|
|||
file_name = my_service.configs[0]
|
||||
file_data_one = "# custom file one"
|
||||
file_data_two = "# custom file two"
|
||||
session.services.set_service_file(node_one.objid, my_service.name, file_name, file_data_one)
|
||||
session.services.set_service_file(node_two.objid, my_service.name, file_name, file_data_two)
|
||||
session.services.set_service_file(node_one.id, my_service.name, file_name, file_data_one)
|
||||
session.services.set_service_file(node_two.id, my_service.name, file_name, file_data_two)
|
||||
|
||||
# when
|
||||
custom_service_one = session.services.get_service(node_one.objid, my_service.name)
|
||||
custom_service_one = session.services.get_service(node_one.id, my_service.name)
|
||||
session.services.create_service_files(node_one, custom_service_one)
|
||||
custom_service_two = session.services.get_service(node_two.objid, my_service.name)
|
||||
custom_service_two = session.services.get_service(node_two.id, my_service.name)
|
||||
session.services.create_service_files(node_two, custom_service_two)
|
||||
|
||||
# then
|
||||
|
@ -240,10 +240,10 @@ class TestServices:
|
|||
node = session.add_node()
|
||||
|
||||
# when
|
||||
no_service = session.services.get_service(node.objid, SERVICE_ONE)
|
||||
default_service = session.services.get_service(node.objid, SERVICE_ONE, default_service=True)
|
||||
session.services.set_service(node.objid, SERVICE_ONE)
|
||||
custom_service = session.services.get_service(node.objid, SERVICE_ONE, default_service=True)
|
||||
no_service = session.services.get_service(node.id, SERVICE_ONE)
|
||||
default_service = session.services.get_service(node.id, SERVICE_ONE, default_service=True)
|
||||
session.services.set_service(node.id, SERVICE_ONE)
|
||||
custom_service = session.services.get_service(node.id, SERVICE_ONE, default_service=True)
|
||||
|
||||
# then
|
||||
assert no_service is None
|
||||
|
|
|
@ -64,14 +64,14 @@ class TestXml:
|
|||
# link nodes to ptp net
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, ptp_node.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# get ids for nodes
|
||||
n1_id = node_one.objid
|
||||
n2_id = node_two.objid
|
||||
n1_id = node_one.id
|
||||
n2_id = node_two.id
|
||||
|
||||
# save xml
|
||||
xml_file = tmpdir.join("session.xml")
|
||||
|
@ -118,20 +118,20 @@ class TestXml:
|
|||
# link nodes to ptp net
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, ptp_node.id, interface_one=interface)
|
||||
|
||||
# set custom values for node service
|
||||
session.services.set_service(node_one.objid, SshService.name)
|
||||
session.services.set_service(node_one.id, SshService.name)
|
||||
service_file = SshService.configs[0]
|
||||
file_data = "# test"
|
||||
session.services.set_service_file(node_one.objid, SshService.name, service_file, file_data)
|
||||
session.services.set_service_file(node_one.id, SshService.name, service_file, file_data)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# get ids for nodes
|
||||
n1_id = node_one.objid
|
||||
n2_id = node_two.objid
|
||||
n1_id = node_one.id
|
||||
n2_id = node_two.id
|
||||
|
||||
# save xml
|
||||
xml_file = tmpdir.join("session.xml")
|
||||
|
@ -155,7 +155,7 @@ class TestXml:
|
|||
session.open_xml(file_path, start=True)
|
||||
|
||||
# retrieve custom service
|
||||
service = session.services.get_service(node_one.objid, SshService.name)
|
||||
service = session.services.get_service(node_one.id, SshService.name)
|
||||
|
||||
# verify nodes have been recreated
|
||||
assert session.get_object(n1_id)
|
||||
|
@ -184,15 +184,15 @@ class TestXml:
|
|||
# link nodes
|
||||
for node in [node_one, node_two]:
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, wlan_node.objid, interface_one=interface)
|
||||
session.add_link(node.id, wlan_node.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# get ids for nodes
|
||||
wlan_id = wlan_node.objid
|
||||
n1_id = node_one.objid
|
||||
n2_id = node_two.objid
|
||||
wlan_id = wlan_node.id
|
||||
n1_id = node_one.id
|
||||
n2_id = node_two.id
|
||||
|
||||
# save xml
|
||||
xml_file = tmpdir.join("session.xml")
|
||||
|
@ -251,15 +251,15 @@ class TestXml:
|
|||
for i, node in enumerate([node_one, node_two]):
|
||||
node.setposition(x=150 * (i + 1), y=150)
|
||||
interface = ip_prefixes.create_interface(node)
|
||||
session.add_link(node.objid, emane_network.objid, interface_one=interface)
|
||||
session.add_link(node.id, emane_network.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# get ids for nodes
|
||||
emane_id = emane_network.objid
|
||||
n1_id = node_one.objid
|
||||
n2_id = node_two.objid
|
||||
emane_id = emane_network.id
|
||||
n1_id = node_one.id
|
||||
n2_id = node_two.id
|
||||
|
||||
# save xml
|
||||
xml_file = tmpdir.join("session.xml")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue