CiscoDevNet / virl2-client

Client library for the Cisco VIRL 2 Network Simulation Platform
Apache License 2.0
56 stars 18 forks source link

Controller version 2.2.3+build63 is incompatible with virl2_client #20

Closed daniel1820815 closed 2 years ago

daniel1820815 commented 2 years ago

Tried to create a testbed, but controller version 2.2.3+build63 is incompatible with virl2_client:

_% python3 create_testbed_from_cml.py SSL Verification disabled Traceback (most recent call last): File "/Users/danielkuhl/Coding/nauto-lab-connectivity/create_testbed_from_cml.py", line 10, in client = ClientLibrary(url, user, password, ssl_verify=False) File "/Users/danielkuhl/Coding/nauto-lab-connectivity/venv/lib/python3.9/site-packages/virl2_client/virl2_client.py", line 281, in init self.check_controller_version() File "/Users/danielkuhl/Coding/nauto-lab-connectivity/venv/lib/python3.9/site-packages/virl2_client/virl2_client.py", line 429, in check_controller_version raise InitializationError( virl2_client.virl2client.InitializationError: Controller version 2.2.3+build63 is marked incompatible! List of versions marked explicitly as incompatible: [2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.1, 2.2.2, 2.2.3].

Tested with the following code:

from virl2_client import ClientLibrary
import os

# Set variables
url = os.environ.get("CML_URL")
user = os.environ.get("CML_USER")
password = os.environ.get("CML_PASS")

# Create a client object for interacting with CML
client = ClientLibrary(url, user, password, ssl_verify=False)

# Find your lab. Method returns a list, this assumes the first lab returned is what you want
lab = client.find_labs_by_title("Test-Lab")[0]

# Retrieve the testbed for the lab 
pyats_testbed = lab.get_pyats_testbed()

# Write the YAML testbed out to a file
with open("testbed.yaml", "w") as f: 
    f.write(pyats_testbed)

Tested with Python 3.9.13 in a virtual environment and the following packages installed:

Package                      Version
---------------------------- -----------
aiofiles                     0.8.0
aiohttp                      3.8.1
aiohttp-swagger              1.0.16
aiosignal                    1.2.0
async-lru                    1.0.3
async-timeout                4.0.2
attrs                        21.4.0
bcrypt                       3.2.2
certifi                      2022.5.18.1
cffi                         1.15.0
chardet                      4.0.0
charset-normalizer           2.0.12
cisco-gnmi                   1.0.15
click                        8.1.3
cryptography                 36.0.2
dill                         0.3.5.1
distro                       1.7.0
docopt                       0.6.2
Flask                        2.1.2
frozenlist                   1.3.0
genie                        22.4
genie.libs.clean             22.4.1
genie.libs.conf              22.4
genie.libs.filetransferutils 22.4
genie.libs.health            22.4
genie.libs.ops               22.4
genie.libs.parser            22.4
genie.libs.sdk               22.4
gitdb                        4.0.9
GitPython                    3.1.18
grpcio                       1.46.1
gunicorn                     20.1.0
idna                         3.3
importlib-metadata           4.12.0
itsdangerous                 2.1.2
Jinja2                       3.1.2
jsonpickle                   2.2.0
junit-xml                    1.9
lxml                         4.8.0
MarkupSafe                   2.1.1
multidict                    6.0.2
ncclient                     0.6.9
netaddr                      0.8.0
packaging                    21.3
paramiko                     2.11.0
pathspec                     0.9.0
pip                          22.1.2
prettytable                  3.3.0
protobuf                     3.20.1
psutil                       5.9.0
pyats                        22.4
pyats.aereport               22.4
pyats.aetest                 22.4
pyats.async                  22.4
pyats.connections            22.4
pyats.datastructures         22.4
pyats.easypy                 22.4
pyats.kleenex                22.4
pyats.log                    22.4
pyats.reporter               22.4
pyats.results                22.4
pyats.tcl                    22.4
pyats.topology               22.4
pyats.utils                  22.4
pycparser                    2.21
pyftpdlib                    1.5.6
PyNaCl                       1.5.0
pyparsing                    3.0.9
python-dateutil              2.8.2
python-engineio              3.14.2
python-socketio              4.6.1
PyYAML                       6.0
requests                     2.27.1
requests-toolbelt            0.9.1
ruamel.yaml                  0.17.21
ruamel.yaml.clib             0.2.6
setuptools                   62.3.2
six                          1.16.0
smmap                        5.0.0
tabulate                     0.8.10
tftpy                        0.8.0
tqdm                         4.64.0
unicon                       22.4
unicon.plugins               22.4
urllib3                      1.26.9
virl2-client                 2.4.0
virlutils                    1.3.8
wcwidth                      0.2.5
Werkzeug                     2.1.2
wheel                        0.37.1
xmltodict                    0.13.0
yamllint                     1.26.3
yang.connector               22.4
yarl                         1.7.2
zipp                         3.8.0
rschmied commented 2 years ago

that's expected -- can't use latest with your version of the controller... do

$ pip install "virl2-client<2.3.0"
...
$ pip list
Package            Version
------------------ -----------
Package            Version
------------------ -----------
certifi            2022.6.15
charset-normalizer 2.1.0
idna               3.3
pip                22.1.2
requests           2.28.1
requests-toolbelt  0.9.1
setuptools         56.0.0
urllib3            1.26.10
virl2-client       2.2.1.post2
$ 

which should give you a working combination -- alternatively, you can also download/install the client library from your controller which should always be compatible :)

rschmied commented 2 years ago

Also... with that version, there's no "extra" section in the manifest... e.g. if you need pyATS then you have to pull in that dependency yourself... like pip install pyats[full]. Which might still be what you want as "full" with pyATS also pulls in Genie and other additional dependencies.

With newer versions, you can do e.g. pip install "virl2-client[pyats]==2.4.0.

daniel1820815 commented 2 years ago

Ah yes. My fault. The virl2_client version is linked to the controller version. Makes absolutely sense. Tested with version 2.2.1.post2 and it worked. Thanks a lot!