cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2872
Views
5
Helpful
2
Replies

Vlan pool using Acitoolkit

sqambera
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

qsnyder
Cisco Employee
Cisco Employee

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.

View solution in original post

2 Replies 2

qsnyder
Cisco Employee
Cisco Employee

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.

Thank you so much Qsnyder