vsphere-automation-sdk-python icon indicating copy to clipboard operation
vsphere-automation-sdk-python copied to clipboard

vsphere-automation-sdk-python is not compatible with dcli

Open brakthehack opened this issue 4 years ago • 2 comments

Environment

  • sdk package version:
(.wcp_cluster_upgrade_env.Linux) brak[-bin]$ pip list | grep v
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
nsx-vmc-aws-integration-python-sdk 3.0.2.0.0.16837625
nsx-vmc-policy-python-sdk          3.0.2.0.0.16837625
pyvmomi                            7.0.1
service-identity                   18.1.0
vapi-client-bindings               3.5.0
vapi-common-client                 2.19.0
vapi-runtime                       2.19.0
vmc-client-bindings                1.29.0
vmc-draas-client-bindings          1.14.0
vSphere-Automation-SDK             1.40.0
  • python version:
(.wcp_cluster_upgrade_env.Linux) brak[-bin]$ python --version
Python 3.5.2
  • vSphere version: 7.0.1

  • Operating System/Shell (used to run SDK-based apps): Linux sc-dbc1104 3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Steps or code snippet to reproduce

Install both the latest version of dcli and vsphere-automation-sdk-python. Invoke dcli in the virtualenv and you will get the following stacktrace.

dcli is at 3.0.0 and vsphere-automation-sdk-python is at d27907d3ffca185c8e11dbb15954fd0e3842c2d6

Actual behavior

(.wcp_cluster_upgrade_env.Linux) brak[-bin]$ ./dcli
/dbc/sc-dbc1104/brak/trees/main-18q2/bora/vpx/wcp/support/cicd/.wcp_cluster_upgrade_env.Linux/lib64/python3.5/site-packages/vmware/vapi/client/dcli/util.py:23: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
  from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
Traceback (most recent call last):
  File "./dcli", line 5, in <module>
    from vmware.vapi.client.dcli.cli import main
  File "/dbc/sc-dbc1104/brak/trees/main-18q2/bora/vpx/wcp/support/cicd/.wcp_cluster_upgrade_env.Linux/lib64/python3.5/site-packages/vmware/vapi/client/dcli/cli.py", line 24, in <module>
    from vmware.vapi.client.dcli.connection import CliConnection
  File "/dbc/sc-dbc1104/brak/trees/main-18q2/bora/vpx/wcp/support/cicd/.wcp_cluster_upgrade_env.Linux/lib64/python3.5/site-packages/vmware/vapi/client/dcli/connection.py", line 33, in <module>
    from vmware.vapi.client.dcli.metadata.file_metadata_provider import \
  File "/dbc/sc-dbc1104/brak/trees/main-18q2/bora/vpx/wcp/support/cicd/.wcp_cluster_upgrade_env.Linux/lib64/python3.5/site-packages/vmware/vapi/client/dcli/metadata/file_metadata_provider.py", line 33, in <module>
    from com.vmware.vapi_client import MetadataInfo
ImportError: cannot import name 'MetadataInfo'

Expected behavior

If I force install the dcli in the current environment, it installs the proper dependencies and starts.

(.wcp_cluster_upgrade_env.Linux) brak[-site-packages]$ pip install --force dcli
(.wcp_cluster_upgrade_env.Linux) brak[-site-packages]$ dcli
/dbc/sc-dbc1104/brak/trees/main-18q2/bora/vpx/wcp/support/cicd/.wcp_cluster_upgrade_env.Linux/lib64/python3.5/site-packages/vmware/vapi/client/dcli/util.py:23: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
  from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
Welcome to VMware Datacenter CLI (DCLI)

usage: dcli <namespaces> <command>

To connect to specified vAPI server: dcli +server <server>
To connect to VMC: dcli +vmc-server or simply: dcli +vmc
To connect to NSX: dcli +nsx-server <nsx-server> or simply: dcli +nsx <nsx-server>
To enter interactive shell mode: dcli +interactive or simply: dcli +i
To execute dcli internal command: dcli env
For detailed help please use: dcli --help

This seems to be an issue where dcli bundles includes the vapi_client that it needs. However, this is overwritten by dependencies included in vsphere-automation-sdk.

brakthehack avatar Dec 02 '20 18:12 brakthehack

@brakthehack

Thanks for reporting this. It is because both Automation SDK and dcli uses the same runtime library, and may go out of sync due to different release timelines. We will look at syncing our release schedule to mitigate this issue.

Thanks!

anusha94 avatar Mar 15 '21 04:03 anusha94

@brakthehack an alternative would be to use separate Python environments, one for each SDK and dcli.

strefethen avatar Mar 16 '21 05:03 strefethen