ttafsir/evengsdk

addNode seems to be coded towards using a vEOS image only?

thebeerman opened this issue · 2 comments

I tried to use the api to add a cisco 3725 template/image and getting a NoneType object is not subscriptable when building the node list .
Looking at addNode it is trying to find in the template options things like "ethernet" and "cpu" etc, which the cisco ios template does not allow you to set. Seems like need some logic to say if they are not in the template (besides set to None), just don't add them to the dictionary passed to the eve api?

resp=client.api.node_template_detail('c3725')
nodes = [
... {"name": "srelab01", "template": "c3725", "image": "c3725-adventerprisek9-mz.124-15.T14.image", "left": 50},
... {"name": "srelab02", "template": "c3725", "image": "c3725-adventerprisek9-mz.124-15.T14.image", "left": 200}
... ]
for node in nodes:
... client.api.add_node(lab_path, **node)
...
Traceback (most recent call last):
File "", line 2, in
File "/usr/local/lib/python3.8/dist-packages/eve_ng-0.2.5-py3.8.egg/evengsdk/api.py", line 1005, in add_node
ethernet = ethernet or template_defaults.get("ethernet")["value"]
TypeError: 'NoneType' object is not subscriptable

sorry forgot the template output

pprint(resp)
{'code': 200,
'data': {'description': 'Cisco IOS 3725 (Dynamips)',
'dynamips': {'options': '-P 3725 -o 4 -c 0x2102 -X --disk0 128 '
'--disk1 128'},
'options': {'config': {'list': ['None', 'Exported'],
'name': 'Startup configuration',
'type': 'list',
'value': '0'},
'delay': {'name': 'Delay (s)',
'type': 'input',
'value': 0},
'icon': {'list': {'AMPServer.png': 'AMPServer.png',
'ASA.png': 'ASA.png',
'Access_point.png': 'Access_point.png',
'Apic.png': 'Apic.png',
'AristaSW.png': 'AristaSW.png',
'Aruba_ctrl.png': 'Aruba_ctrl.png',
'CSRv1000.png': 'CSRv1000.png',
'CUCM.png': 'CUCM.png',
'Checkpoint.png': 'Checkpoint.png',
'Cisco ACS.png': 'Cisco ACS.png',
'Cisco WAAS.png': 'Cisco WAAS.png',
'Cloud.png': 'Cloud.png',
'Cube.png': 'Cube.png',
'CustomShape.png': 'CustomShape.png',
'Desktop.png': 'Desktop.png',
'Desktop2.png': 'Desktop2.png',
'Desktop_Win.png': 'Desktop_Win.png',
'Desktop_linux.png': 'Desktop_linux.png',
'ESA.png': 'ESA.png',
'ESXi.png': 'ESXi.png',
'FMC.png': 'FMC.png',
'Firewall.png': 'Firewall.png',
'Firewall2.png': 'Firewall2.png',
'Frame Relay.png': 'Frame Relay.png',
'HUB.png': 'HUB.png',
'IPS.png': 'IPS.png',
'IPphone.png': 'IPphone.png',
'ISE.png': 'ISE.png',
'ISE1.png': 'ISE1.png',
'Infoblox.png': 'Infoblox.png',
'JuniperMX.png': 'JuniperMX.png',
'JuniperSRX.png': 'JuniperSRX.png',
'JunipervQFXpfe.png': 'JunipervQFXpfe.png',
'JunipervQFXre.png': 'JunipervQFXre.png',
'JunosSpace.png': 'JunosSpace.png',
'Laptop.png': 'Laptop.png',
'Linux.png': 'Linux.png',
'Load Balancer.png': 'Load '
'Balancer.png',
'MAC_PC.png': 'MAC_PC.png',
'MPLS.png': 'MPLS.png',
'NSX.png': 'NSX.png',
'Network Analyzer.png': 'Network '
'Analyzer.png',
'Nexus7K.png': 'Nexus7K.png',
'NexusK5.png': 'NexusK5.png',
'PaloAlto.png': 'PaloAlto.png',
'PaloPanorama.png': 'PaloPanorama.png',
'Prime.png': 'Prime.png',
'Pulse.png': 'Pulse.png',
'Router.png': 'Router.png',
'Router_FW.png': 'Router_FW.png',
'SROS linecard.png': 'SROS '
'linecard.png',
'SROS.png': 'SROS.png',
'Server.png': 'Server.png',
'Server_AD.png': 'Server_AD.png',
'Server_Linux.png': 'Server_Linux.png',
'Server_WEB.png': 'Server_WEB.png',
'Server_Win.png': 'Server_Win.png',
'Server_mail.png': 'Server_mail.png',
'Server_storage.png': 'Server_storage.png',
'Sonicwall_FW.png': 'Sonicwall_FW.png',
'Sophos_fw.png': 'Sophos_fw.png',
'Switch L3.png': 'Switch L3.png',
'Switch.png': 'Switch.png',
'User_icon.png': 'User_icon.png',
'WAN Optimizer.png': 'WAN '
'Optimizer.png',
'WSA.png': 'WSA.png',
'Winserver.png': 'Winserver.png',
'XR.png': 'XR.png',
'dcnm.png': 'dcnm.png',
'ixia.png': 'ixia.png',
'sp_edge.png': 'sp_edge.png',
'sp_orch.png': 'sp_orch.png',
'stealthfc.png': 'stealthfc.png',
'stealthfr.png': 'stealthfr.png',
'stealthfs.png': 'stealthfs.png',
'stealthmc.png': 'stealthmc.png',
'vBond.png': 'vBond.png',
'vEdge.png': 'vEdge.png',
'vManage.png': 'vManage.png',
'vSmart.png': 'vSmart.png',
'vWLC.png': 'vWLC.png',
'vanalytic.png': 'vanalytic.png',
'vdirector.png': 'vdirector.png',
'veloedge.png': 'veloedge.png',
'velogw.png': 'velogw.png',
'veloorch.png': 'veloorch.png',
'versaflex.png': 'versaflex.png'},
'name': 'Icon',
'type': 'list',
'value': 'Router.png'},
'idlepc': {'name': 'Idle PC',
'type': 'input',
'value': '0x60c08728'},
'image': {'list': {'c3725-adventerprisek9-mz.124-15.T14.image': 'c3725-adventerprisek9-mz.124-15.T14.image'},
'name': 'Image',
'type': 'list',
'value': 'c3725-adventerprisek9-mz.124-15.T14.image'},
'name': {'name': 'Name/prefix',
'type': 'input',
'value': '3725'},
'nvram': {'name': 'NVRAM', 'type': 'input', 'value': 128},
'ram': {'name': 'RAM', 'type': 'input', 'value': 256},
'slot1': {'list': {'': 'Empty',
'NM-16ESW': 'NM-16ESW',
'NM-1FE-TX': 'NM-1FE-TX'},
'name': 'Slot 1',
'type': 'list',
'value': ''},
'slot2': {'list': {'': 'Empty',
'NM-16ESW': 'NM-16ESW',
'NM-1FE-TX': 'NM-1FE-TX'},
'name': 'Slot 2',
'type': 'list',
'value': ''}},
'type': 'dynamips'},
'message': 'Successfully listed node template (60032).',
'status': 'success'}

@thebeerman Apparently the EVE-NG API doesn't set some of the defaults for dynamips-based images. The fix is in develop (#151) and will be released soon.