Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] p2p_link creation fails for node_type IOL devices #186

Open
teresoic opened this issue Jan 3, 2023 · 1 comment
Open

[BUG] p2p_link creation fails for node_type IOL devices #186

teresoic opened this issue Jan 3, 2023 · 1 comment

Comments

@teresoic
Copy link

teresoic commented Jan 3, 2023

Describe the bug
Unable to create p2p links for IOL devices. Receiving error:
File "C:...\BulkImportLab\Lib\site-packages\evengsdk\api.py", line 397, in
if interface["name"] == interface_name

TypeError: string indices must be integers, not 'str'

To Reproduce
Running script...

from evengsdk.client import EvengClient

client = EvengClient("x.x.x.x", log_file="test.log", ssl_verify=False, protocol="http")
client.disable_insecure_warnings() # disable warnings for self-signed certificates
client.login(username="admin", password="eve")
client.set_log_level("DEBUG")

create a lab

lab = {"name": "Lab", "description": "Test Lab", "path": "/"}

resp = client.api.create_lab(**lab)
if resp['status'] == "success":
print("lab created successfully.")

we need the lab path to create objects in the lab

lab_path = f"{lab['path']}{lab['name']}.unl"

create management network

mgmt_cloud = {"name": "eve-mgmt", "network_type": "pnet1"}
client.api.add_lab_network(lab_path, **mgmt_cloud)

create Nodes

nodes = [
{"template":"fortinet","node_type":"qemu","image": "fortinet-FGT-v6-build1828","name": "F1", "icon":"Forti_FGT.png","ethernet":"10","console":"telnet","left": 550,"top":700},
{"template":"iol","node_type":"iol","image":"i86bi-linux-l2-adventerprisek9-15.1a.bin","name":"S1","icon":"Switch.png","nvram":"1024","ram":"1024","ethernet":"2","left":875,"top":460},
{"template":"iol","node_type":"iol","image":"i86bi-linux-l2-adventerprisek9-15.1a.bin","name":"S2","icon":"Switch.png","nvram":"1024","ram":"1024","ethernet":"2","left":1075,"top":460},
{"template":"vpcs","name":"VPC1","icon":"Desktop.png","node_type":"vpcs","left":875,"top":660},
{"template":"vpcs","name":"VPC2","icon":"Desktop.png","node_type":"vpcs","left":1075,"top":660},
]

for node in nodes:
client.api.add_node(lab_path, **node)

print(client.api.get_node_interfaces(lab_path,1))
print(client.api.get_node_interfaces(lab_path,2))
print(client.api.get_node_interfaces(lab_path,4))

connect nodes to management network

mgmt_connections = [
{"src": "F1", "src_label": "port1", "dst": "eve-mgmt"},
]

for link in mgmt_connections:
client.api.connect_node_to_cloud(lab_path, **link)

create p2p links

p2p_links = [
{"src": "F1", "src_label": "port2", "dst": "VPC2", "dst_label": "eth0"},
{"src": "VPC1", "src_label": "eth0", "dst": "S1", "dst_label": "e0/1"},
{"src": "S1", "src_label": "e0/2", "dst": "S2", "dst_label": "e0/2"},
]

for link in p2p_links:
client.api.connect_node_to_node(lab_path, **link)

client.logout()

Expected behavior
Expect to create links to IOL devices successfully. There is not issue with other device types, for example qemu and vpcs. in the above script these are created without error

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
note from the output of the
print(client.api.get_node_interfaces(lab_path,1))
print(client.api.get_node_interfaces(lab_path,2))
print(client.api.get_node_interfaces(lab_path,4))

you can see that the device_id 1 and 4 (qemu & vpcs respectively) has normal key value pairs for the get_node_interface output. but you can see device_id 2 (iol) has an int before the key value pair

get_node_interface output....
lab created successfully.
{'code': 200, 'status': 'success', 'message': 'Successfully listed node interfaces (60030).', 'data': {'id': 1, 'sort': 'qemu', 'ethernet': [{'name': 'port1', 'network_id': 0}, {'name': 'port2', 'network_id': 0}, {'name': 'port3', 'network_id': 0}, {'name': 'port4', 'network_id': 0}, {'name': 'port5', 'network_id': 0}, {'name': 'port6', 'network_id': 0}, {'name': 'port7', 'network_id': 0}, {'name': 'port8', 'network_id': 0}, {'name': 'port9', 'network_id': 0}, {'name': 'port10', 'network_id': 0}], 'serial': []}}

{'code': 200, 'status': 'success', 'message': 'Successfully listed node interfaces (60030).', 'data': {'id': 2, 'sort': 'iol', 'ethernet': {'0': {'name': 'e0/0', 'network_id': 0}, '16': {'name': 'e0/1', 'network_id': 0}, '32': {'name': 'e0/2', 'network_id': 0}, '48': {'name': 'e0/3', 'network_id': 0}, '1': {'name': 'e1/0', 'network_id': 0}, '17': {'name': 'e1/1', 'network_id': 0}, '33': {'name': 'e1/2', 'network_id': 0}, '49': {'name': 'e1/3', 'network_id': 0}}, 'serial': []}}

{'code': 200, 'status': 'success', 'message': 'Successfully listed node interfaces (60030).', 'data': {'id': 4, 'sort': 'vpcs', 'ethernet': [{'name': 'eth0', 'network_id': 0}], 'serial': []}}

EVE-NG VERSION

Community Edition

||/ Name Version Architecture Description
+++-==============-============-============-==============================================
ii eve-ng 5.0.1-10 amd64 A new generation software for networking labs.

NOTE: it is possible to create the IOL device and p2p links successfully without defined the node_type as "IOL". However the device will not start due all interfaces "Lost carrier". see screenshot attached

LogOutputStartNodeFailNoNode_Type

@teresoic
Copy link
Author

teresoic commented Jun 15, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant