03-29-2021 09:48 PM
Hello,
I am trying to create a vlan pool in ACI using attached python code. Could anyone please help me to know why am I getting error while trying to push it to ACI.
Thanks and appreciate your time to answer this question.
Regards,
Qamber
Solved! Go to Solution.
04-07-2021 04:06 PM
The error messaging you're receiving as part of the .get_json() method is giving you a clue
Traceback (most recent call last):
File "<pyshell#44>", line 1, in <module>
session.push_to_apic(testpool.get_url(), testpool.get_json())
File "C:\automation\ACI\lib\site-packages\acitoolkit-0.4-py3.9.egg\acitoolkit\acitoolkit.py", line 6552, in get_json
from_id = self.encap_type + '-' + self.start_id
TypeError: can only concatenate str (not "NoneType") to str
In this instance -- you can see that its attempting to concatenate the encap_type with start_id, of which you don't have defined (hence NoneType)
I just tested this -- and if you refactor to something like the following
>>> testpool = aci.NetworkPool('test_pool','vlan','dynamic',start_id='10',end_id='100')
>>> print(testpool.get_json())
{'infraInfra': {'attributes': {}, 'children': [{'fvnsVlanInstP': {'attributes': {'name': 'test_pool', 'allocMode': 'dynamic'}, 'children': [{'fvnsEncapBlk':
{'attributes': {'name': 'encap', 'from': 'vlan-10', 'to': 'vlan-100'}, 'children': []}}]}}]}}
>>> session.push_to_apic(testpool.get_url(),testpool.get_json())
<Response [200]>
it will succeed (and you can see that the print() statement will print the appropriate JSON payload of the call made to the APIC).
The attached screenshot is from pushing the VLAN pool to the always-on ACI sandbox. It may also be helpful to install bpython in your virtualenv, which will provide handy "tooltips" when working in the interactive interpreter.
q.
04-07-2021 04:06 PM
The error messaging you're receiving as part of the .get_json() method is giving you a clue
Traceback (most recent call last):
File "<pyshell#44>", line 1, in <module>
session.push_to_apic(testpool.get_url(), testpool.get_json())
File "C:\automation\ACI\lib\site-packages\acitoolkit-0.4-py3.9.egg\acitoolkit\acitoolkit.py", line 6552, in get_json
from_id = self.encap_type + '-' + self.start_id
TypeError: can only concatenate str (not "NoneType") to str
In this instance -- you can see that its attempting to concatenate the encap_type with start_id, of which you don't have defined (hence NoneType)
I just tested this -- and if you refactor to something like the following
>>> testpool = aci.NetworkPool('test_pool','vlan','dynamic',start_id='10',end_id='100')
>>> print(testpool.get_json())
{'infraInfra': {'attributes': {}, 'children': [{'fvnsVlanInstP': {'attributes': {'name': 'test_pool', 'allocMode': 'dynamic'}, 'children': [{'fvnsEncapBlk':
{'attributes': {'name': 'encap', 'from': 'vlan-10', 'to': 'vlan-100'}, 'children': []}}]}}]}}
>>> session.push_to_apic(testpool.get_url(),testpool.get_json())
<Response [200]>
it will succeed (and you can see that the print() statement will print the appropriate JSON payload of the call made to the APIC).
The attached screenshot is from pushing the VLAN pool to the always-on ACI sandbox. It may also be helpful to install bpython in your virtualenv, which will provide handy "tooltips" when working in the interactive interpreter.
q.
04-08-2021 08:04 AM
Thank you so much Qsnyder
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide