cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4231
Views
10
Helpful
5
Replies

ACI Toolkit Creating EPG

Maaz.Javed
Level 1
Level 1

I have the following script that im trying to run to generate an epg but getting an error on it. Im using python 3.8

 

 

#!/usr/bin/env python
"""
Sample of creating a EPG
"""
import json 
from acitoolkit import Credentials, Session, Tenant, AppProfile, BridgeDomain, EPG
import sys 

# Modify the LOGIN, PASSWORD, URL 
LOGIN    = "mylogin"
PASSWORD = " mypassword"
URL      = "myurl"

def main():
    """
    Main execution routine
    :return: None
    """
    creds = Credentials('apic')
    creds.add_argument('--tenant'help='The name of Tenant')
    creds.add_argument('--app'help='The name of ApplicationProfile')
    creds.add_argument('--bd'help='The name of BridgeDomain')
    creds.add_argument('--epg'help='The name of EPG')
    creds.add_argument('--json'const='false'nargs='?'help='Json output only')

    args = creds.get()
    session = Session(args.url, args.login, args.password)
    session.login()

    tenant = Tenant(args.tenant)
    app = AppProfile(args.app, tenant)
    bd = BridgeDomain(args.bd, tenant)
    epg = EPG(args.epg, app)
    epg.add_bd(bd)

    if args.json:
        print(tenant.get_json())
    else:
        resp = session.push_to_apic(tenant.get_url(),
                                    tenant.get_json())

        if not resp.ok:
            print('%% Error: Could not push configuration to APIC')
            print(resp.text)

if __name__ == '__main__':
    main()
1 Accepted Solution

Accepted Solutions

Is it possible that you copied the Script from another machine to the machine you are trying to run it on now?
I guess it never worked on this machine before?

It looks like you are missing the websocket-client:

https://pythonrepo.com/repo/websocket-client-websocket-client-python-websocket

You should install pip3 (if not there already) and then run:

pip3 install websocket-client

Can you try that?

BR
Jules

View solution in original post

5 Replies 5

julian.bendix
Level 3
Level 3

Hey,

what is the response?

BR
Jules

here is the error response im getting:

 

Traceback (most recent call last):
File "aci_create_epg.py", line 6, in <module>
from acitoolkit import Credentials, Session, Tenant, AppProfile, BridgeDomain, EPG
File "<frozen zipimport>", line 259, in load_module
File "C:\Users\u28057\AppData\Local\Programs\Python\Python38-32\lib\site-packages\acitoolkit-0.4-py3.8.egg\acitoolkit\__init__.py", line 30, in <module>
File "<frozen zipimport>", line 259, in load_module
File "C:\Users\u28057\AppData\Local\Programs\Python\Python38-32\lib\site-packages\acitoolkit-0.4-py3.8.egg\acitoolkit\aciFaults.py", line 5, in <module>
File "<frozen zipimport>", line 259, in load_module
File "C:\Users\u28057\AppData\Local\Programs\Python\Python38-32\lib\site-packages\acitoolkit-0.4-py3.8.egg\acitoolkit\acibaseobject.py", line 38, in <module>
File "<frozen zipimport>", line 259, in load_module
File "C:\Users\u28057\AppData\Local\Programs\Python\Python38-32\lib\site-packages\acitoolkit-0.4-py3.8.egg\acitoolkit\acisession.py", line 55, in <module>
ImportError: cannot import name 'create_connection' from 'websocket' (C:\Users\u28057\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websocket\__init__.py)

Is it possible that you copied the Script from another machine to the machine you are trying to run it on now?
I guess it never worked on this machine before?

It looks like you are missing the websocket-client:

https://pythonrepo.com/repo/websocket-client-websocket-client-python-websocket

You should install pip3 (if not there already) and then run:

pip3 install websocket-client

Can you try that?

BR
Jules

Awesome that helped. Thank You soo much.

Great to hear that!!

Can you mark my answer my last reply as solution? This would also help others if they search for the same problem in the future, and it also marks this discussion as solved.

 

Best regards
Juls

Review Cisco Networking for a $25 gift card

Save 25% on Day-2 Operations Add-On License