Giter VIP home page Giter VIP logo

vsphere-automation-sdk-python's Introduction

VMware vSphere Automation SDK for Python

Build Status

Table of Contents

Abstract

This document describes the vSphere Automation Python SDK samples that use the vSphere Automation python client library. Additionally, some of the samples demonstrate the combined use of the vSphere Automation and vSphere APIs. To support this combined use, the vSphere Automation Python SDK samples require the vSphere Management SDK packages (pyVmomi) to be installed on the client. The samples have been developed to work with python 3.8+

Supported OnPrem vCenter Releases

vCenter 7.0, 7.0U1, 7.0U2, 7.0U3 , 8.0, 8.0U1, 8.0U2 Please refer to the notes in each sample for detailed compatibility information.

Supported NSX-T Releases

NSX-T 2.2 - 4.1.2 and VMC 1.7 - 1.24

Latest VMware Cloud on AWS Release:

VMC M24 (1.24) (Release Notes)

Quick Start Guide

Prepare a Python Development Environment

We recommend you to install latest Python and pip on your system.

A Python virtual environment is also highly recommended.

Installing Required Python Packages

SDK package installation commands may differ depending on the environment where it is being installed. The three installation options provided below are for different environments. pip and setuptools are common requirements for these installation types, upgrade to the latest pip and setuptools.

NOTE: The SDK also requires OpenSSL 1.0.1+ in order to support TLS1.1 & 1.2

1. Typical Installation

This is the recommended way to install the SDK. The installation is done from PyPI and Automation SDK Python Github repositories.

Install/Update latest pip from PyPI.

pip install --upgrade pip

Install/Update setuptools

pip install --upgrade setuptools

Install SDK packages from Github.

pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
2. Local installation

Local installation can be used in an environment which either do not have Github access or users do not want to install from Github repository.

Install all the wheel files from SDK's lib directory.

pip install -U lib/*/*.whl

Install dependencies like lxml and pyvmomi from PyPI as other requirements were installed from SDK's lib directory.

pip install -U <SDK_DIRECTORY_PATH>

Where <SDK_DIRECTORY_PATH> is either install directory of the SDK or location of SDK's zip e.g.

pip install -U /root/vsphere-automation-sdk-python
Or
pip install -U vsphere-automation-sdk-python-8.0.0.0.zip
3. Installation in an air gap environment

For this type of environment an additional step is required to ensure SDK's dependencies are available. Following dependencies have to be downloaded from PyPI and transferred to the air gap environment.

NOTE: This step has to be done in an environment which has PyPI access.

pip download  -r requirements_pypi.txt -d lib
zip -r lib.zip lib/

Follow these steps in the air gap environment. Unzip the lib.zip under automation SDK home directory.

unzip lib.zip

Install all the dependencies and packages.

pip install -U lib/**/*.whl

This is to install the "vSphere-Automation-SDK" which provides an SDK version. It also ensures that all the SDK requirements are installed. If not, the installation will fail.

pip install -U `pwd`

Connect to a vCenter Server

import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client
session = requests.session()

# Disable cert verification for demo purpose. 
# This is not recommended in a production environment.
session.verify = False

# Disable the secure connection warning for demo purpose.
# This is not recommended in a production environment.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Connect to a vCenter Server using username and password
vsphere_client = create_vsphere_client(server='<vc_ip>', username='<vc_username>', password='<vc_password>', session=session)

# List all VMs inside the vCenter Server
vsphere_client.vcenter.VM.list()

Output in a Python Interpreter:

(venv) het-m03:vsphere-automation-sdk-python het$ python
Python 3.9.8 (main, Nov 10 2021, 06:03:50)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> import urllib3
>>> from vmware.vapi.vsphere.client import create_vsphere_client
>>> session = requests.session()
>>> session.verify = False
>>> urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 
>>> vsphere_client = create_vsphere_client(server='<vc_ip>', username='<vc_username>', password='<vc_password>', session=session)
>>> vsphere_client.vcenter.VM.list()
[Summary(vm='vm-58', name='standalone-20e4bd3af-esx.0-vm.0', power_state=State(string='POWERED_OFF'), cpu_count=1, memory_size_mib=256), 
...]

NOTE: If you are using Bash, be sure to use single quote for username and password to preserve the values. If you use double quote, you will have to escape special characters, such as "$". See Bash manual

Connect to VMware Cloud on AWS

from vmware.vapi.vmc.client import create_vmc_client

# Connect to VMware Cloud on AWS using refresh token
vmc_client = create_vmc_client('<refresh_token>')

# Get organizations associated with calling user.
vmc_client.Orgs.list()

Output in a Python Interpreter:

(venv) het-m03:vsphere-automation-sdk-python het$ python
Python 3.9.8 (main, Nov 10 2021, 06:03:50)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from vmware.vapi.vmc.client import create_vmc_client
>>> vmc_client = create_vmc_client('<refresh_token>')
>>> vmc_client.Orgs.list()
[Organization(updated=datetime.datetime(2018, 3, 2, 16, 57, 46), user_id='77aa6e6f-3257-3637-9cd9-14fae3a25b9d', updated_by_user_id='2021b5ae-890b-3472-ba9a-bc8cff776ca7', created=datetime.datetime(2017, 4, 4, 11, 57, 48, 861), version=15, updated_by_user_name='[email protected]', user_name='[email protected]', id='2a8ac0ba-c93d-4748-879f-7dc9918beaa5', display_name='VMC-SET', name='j13hqg73', sla='VMC_INTERNAL', project_state='CREATED', properties=OrgProperties(values={'defaultAwsRegions': 'US_WEST_2,US_EAST_1', 'sddcLimit': '5', 'planVersion': '3.0', 'defaultHostsPerSddc': '4', 'invitationCode': '/csp/gateway/slc/api/service-invitations/aa7203c3617bbe755597b8b0ad652', 'enableAWSCloudProvider': 'true', 'enableZeroCloudCloudProvider': 'true', 'accountLinkingOptional': 'false', 'defaultPDXDatacenter': 'pdx2', 'skipSubscriptionCheck': 'true', 'minHostsPerSddc': '4', 'maxHostsPerSddc': '8', 'hostLimit': '16', 'maxHostsPerSddcOnCreate': '4', 'isAllAccess': 'true', 'enabledAvailabilityZones': '{"us-east-1":["iad6","iad7","iad12"],"us-west-2":["pdx1", "pdx4", "pdx2"]}'}), cloud_configurations={'AWS': AwsOrgConfiguration(provider='AWS')})
...]

Run SDK Samples

In this section we will walk you through the steps to run the sample code for vSphere and VMware Cloud on AWS APIs.

First, set PYTHONPATH to use SDK helper methods

  • Linux/Mac:

    export PYTHONPATH=${PWD}:$PYTHONPATH

  • Windows:

    set PYTHONPATH=%cd%;%PYTHONPATH%

Run VMware Cloud on AWS Samples

$ python samples/vmc/orgs/organization_operations.py -r <refresh_token>

Run vSphere Samples

A vSphere test environment is required with the following configuration:

  • 1 vCenter Server
  • 2 ESX hosts
  • 1 NFS Datastore with at least 3GB of free capacity

Note Please have the details of these available but do not have any configuration pre-created on vCenter server or ESXi Hosts, for example there should be no existing datacenters, clusters or attached hosts on the vCenter server.

Running the SDK Sample Setup Script

Before executing the samples we'll need to setup the vSphere test environment using one of the sample scripts (samples/vsphere/vcenter/setup/main.py). The script will perform the following:

  • Create 2 test Datacenters
  • Create a test Cluster
  • Create Test Folders for VM Storage
  • Attach the hosts
  • Create a Distributed Switch
  • Create a Distributed Portgroup
  • Attach the NFS datastore (if Selected) to the hosts
  • Copy the Photon OS ISO image downloaded from VMware's bintray server to the datastore
  • Create directories to add sample ports

First, edit settings in samples/vsphere/vcenter/setup/testbed.py and replace everything in < > brackets with your environment information. Leave the rest of the settings in this file at their default values.

config["SERVER"]    = "<vcenter_hostname_or_ip>"
config["USERNAME"]  = "<vsphere_username>"
config["PASSWORD"]  = "<vsphere_password>"

config["ESX_HOST1"] = "<ESX_host1_ipaddress>"
config["ESX_HOST2"] = "<ESX_host2_ipaddress>"
config["ESX_USER"]  = "<esx_username>"
config["ESX_PASS"]  = "<esx_password>"

config["USE_NFS"]   = True
config["NFS_HOST"]  = "<nfs_ipaddress>"
config["NFS_REMOTE_PATH"] = "/store1"

At this point, we're ready to run the setup script:

$ python samples/vsphere/vcenter/setup/main.py -sv

After completion you will see from the output and also the vSphere Client that the environment has now been fully setup and is ready to easily run further samples.

To view other available command-line options:

$ python samples/vsphere/vcenter/setup/main.py -h

Run the vAPI vCenter sample suite:

$ python samples/vsphere/vcenter/setup/main.py -riv

Run a specific sample in a standalone mode:

$ python samples/vsphere/vcenter/vm/list_vms.py -v

API Documentation

vSphere API Documentation

VMware Cloud on AWS API Documentation

NSX API Documentation

Troubleshooting

Common issues you may run into while installing the sdk and running samples are listed here

Support

For official support, users with Active - Premium SDK Support, Standard SDK Support, Premier/Success 360, and VMware Select Support can reach out to VMware Global Support for any issues in line with our SDK and API Support policy. For community support, please open a Github issue or start a Discussion.

Repository Administrator Resources

Board Members

Board members are volunteers from the SDK community and VMware staff members, board members are not held responsible for any issues which may occur from running of samples from this repository.

Members:

  • Ankit Agrawal (VMware)
  • Jobin George (VMware)
  • Martin Tsvetanov (VMware)
  • Shweta Purohit (VMware)
  • Kunal Singh (VMware)

VMware Resources

vsphere-automation-sdk-python's People

Contributors

aagrawal3 avatar ajoyka avatar alanrenouf avatar amanpriyad avatar anusha94 avatar bhagatp10 avatar chandrashekh-vmw avatar ggoodvmw avatar jobingeo avatar karaatanassov avatar khnazaretyan avatar kmruddy avatar kunalpmj avatar mariolenz avatar pgbidkar avatar shwetapurohit avatar strefethen avatar sumitagrawal007 avatar tianhao64 avatar travisfinch avatar triptiattavar avatar vanditsmehta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vsphere-automation-sdk-python's Issues

Please update Readme

I ran pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///build/vsphere-automation-sdk-python/lib
and got errors.

Looked for requirements.txt, found /build/vsphere-automation-sdk-python/

Apparently, I also was supposed to install vapi-client-bindings BEFORE running this command

Erroneous import in vmware/vapi/vmc/client.py from vapi-vmc-client==2.9.0 package

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:
$ pip freeze | grep vapi
vapi-common-client==2.9.0
vapi-runtime==2.9.0
vapi-vmc-client==2.9.0
  • python version:
$ python --version
Python 2.7.13

Steps or code snippet to reproduce + Actual behavior

$ ipython -c 'from vmware.vapi.vmc.client import create_vmc_client'
---------------------------------------------------------------------------                                                                                                 ImportError                               Traceback (most recent call last)
<ipython-input-1-fad65e76a271> in <module>()                                                                                                                                ----> 1 from vmware.vapi.vmc.client import create_vmc_client
                                                                                                                                                                            /home/lucas_cimon/.local/share/virtualenvs/infralib-py2/lib/python2.7/site-packages/vmware/vapi/vmc/client.py in <module>()
      8 import requests                                                                                                                                                           9
---> 10 from com.vmware.vmc_client import StubFactory                                                                                                                            11 from vmware.vapi.bindings.stub import ApiClient
     12 from vmware.vapi.lib.connect import get_requests_connector                                                                                                          
ImportError: No module named com.vmware.vmc_client

Expected behavior

No ImportError raised.

Resolution

Simply replace the 2 following lines in vmware/vapi/vmc/client.py:

from com.vmware.vmc.client import StubFactory
from vmware.vapi.bindings.stub import ApiClient

By:

from vmware.vapi.bindings.stub import ApiClient, StubFactory

vapi-vmc-client as an undeclared dependency on vapi-common-client

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:
    (vapi-runtime is an explicit dependency of vapi-vmc-client)
$ pip freeze | grep vapi
vapi-runtime==2.9.0
vapi-vmc-client==2.9.0
  • python version:
$ python --version
Python 2.7.13

Steps or code snippet to reproduce + Actual behavior

$ ipython -c 'from vmware.vapi.vmc.client import create_vmc_client'
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-fad65e76a271> in <module>()
----> 1 from vmware.vapi.vmc.client import create_vmc_client

/home/lucas_cimon/.local/share/virtualenvs/infralib-py2/lib/python2.7/site-packages/vmware/vapi/vmc/client.py in <module>()
     10 from vmware.vapi.bindings.stub import ApiClient, StubFactory
     11 from vmware.vapi.lib.connect import get_requests_connector
---> 12 from vmware.vapi.stdlib.client.factories import StubConfigurationFactory                                                                                                 13                                                                                                                                                                          14 from .csp_filter import CSPSecurityContextFilter                                                                                                                                                                                                                                                                                                /home/lucas_cimon/.local/share/virtualenvs/infralib-py2/lib/python2.7/site-packages/vmware/vapi/stdlib/client/factories.py in <module>()                                          9 from vmware.vapi.bindings.error import VapiError                                                                                                                         10 from vmware.vapi.bindings.stub import StubConfiguration                                                                                                             ---> 11 from com.vmware.vapi.std import errors_client                                                                                                                            12
     13                                                                                                                                                                     
ImportError: No module named com.vmware.vapi.std

Expected behavior

No ImportError raised

Resolution

Installing also the vapi-common-client==2.9.0 wheel

Unable to deploy a VM from Content Library - method expects PlacementSpec but got DeployPlacementSpec

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:
    pyvmomi 6.7.1
    vapi-client-bindings 1.5.0
    vapi-common-client 2.10.2
    vapi-runtime 2.10.2
    vapi-vmc-client 2.10.2
    vmc-app-python-sdk 2.2.0.0.0.15184434
    vmc-client-bindings 1.3.0
  • python version: Python 3.7.0 and Python 2.7.15
  • vSphere version: 6.7.0

  • Operating System/Shell (used to run SDK-based apps): macOS/bash, Linux/bash

Steps or code snippet to reproduce

vsphere-automation-sdk-python % PYTHONPATH=$(pwd):$PYTHONPATH python samples/vsphere/contentlibrary/vmtemplate/deploy_vm_template.py --itemname linux-template --datacentername my-datacenter --datastorename vsan-datastore --vmname test-01 --foldername test-folder --resourcepoolname Resources -s vcenter.lab -u [email protected] -p 'censored' -v
server: vcenter.lab
Library item ID: 6971994f-e8d3-493d-b5fe-8b8280a96972
Detected folder 'test-folder' as group-v92
Selecting ResourcePool 'resgroup-79'
Datastore MoId: datastore-88
Traceback (most recent call last):
  File "/tmp/vsphere-automation-sdk-python/samples/vsphere/common/sample_base.py", line 79, in run
    attr()  # calling the method
  File "samples/vsphere/contentlibrary/vmtemplate/deploy_vm_template.py", line 146, in _execute
    self.vm_id = self.client.vmtx_service.deploy(item_id, deploy_spec)
  File "/tmp/venv/lib/python3.7/site-packages/com/vmware/vcenter/vm_template_client.py", line 2101, in deploy
    'spec': spec,
  File "/tmp/venv/lib/python3.7/site-packages/vmware/vapi/bindings/stub.py", line 317, in _invoke
    return self._api_interface.native_invoke(ctx, _method_name, kwargs)
  File "/tmp/venv/lib/python3.7/site-packages/vmware/vapi/bindings/stub.py", line 275, in native_invoke
    self._rest_converter_mode)
com.vmware.vapi.std.errors_client.InvalidArgument: {messages : [LocalizableMessage(id='vapi.invoke.input.invalid', default_message='Unable to validate input to method com.vmware.vcenter.vm_template.library_items.deploy', args=['com.vmware.vcenter.vm_template.library_items.deploy']), LocalizableMessage(id='vapi.data.structure.field.invalid', default_message='Found invalid field spec in structure.', args=['spec']), LocalizableMessage(id='vapi.data.structure.field.invalid', default_message='Found invalid field placement in structure.', args=['placement']), LocalizableMessage(id='vapi.data.optional.validate', default_message='The given OptionalValue does not match the OptionalDefinition', args=[]), LocalizableMessage(id='vapi.data.structure.name.mismatch', default_message="Name mismatch for structure.  Expected 'com.vmware.vcenter.vm_template.library_items.placement_spec', but got 'com.vmware.vcenter.vm_template.library_items.deploy_placement_spec'", args=['com.vmware.vcenter.vm_template.library_items.placement_spec', 'com.vmware.vcenter.vm_template.library_items.deploy_placement_spec'])], data : None}
Traceback (most recent call last):
  File "/tmp/vsphere-automation-sdk-python/samples/vsphere/common/sample_base.py", line 79, in run
    attr()  # calling the method
  File "samples/vsphere/contentlibrary/vmtemplate/deploy_vm_template.py", line 146, in _execute
    self.vm_id = self.client.vmtx_service.deploy(item_id, deploy_spec)
  File "/tmp/venv/lib/python3.7/site-packages/com/vmware/vcenter/vm_template_client.py", line 2101, in deploy
    'spec': spec,
  File "/tmp/venv/lib/python3.7/site-packages/vmware/vapi/bindings/stub.py", line 317, in _invoke
    return self._api_interface.native_invoke(ctx, _method_name, kwargs)
  File "/tmp/venv/lib/python3.7/site-packages/vmware/vapi/bindings/stub.py", line 275, in native_invoke
    self._rest_converter_mode)
com.vmware.vapi.std.errors_client.InvalidArgument: {messages : [LocalizableMessage(id='vapi.invoke.input.invalid', default_message='Unable to validate input to method com.vmware.vcenter.vm_template.library_items.deploy', args=['com.vmware.vcenter.vm_template.library_items.deploy']), LocalizableMessage(id='vapi.data.structure.field.invalid', default_message='Found invalid field spec in structure.', args=['spec']), LocalizableMessage(id='vapi.data.structure.field.invalid', default_message='Found invalid field placement in structure.', args=['placement']), LocalizableMessage(id='vapi.data.optional.validate', default_message='The given OptionalValue does not match the OptionalDefinition', args=[]), LocalizableMessage(id='vapi.data.structure.name.mismatch', default_message="Name mismatch for structure.  Expected 'com.vmware.vcenter.vm_template.library_items.placement_spec', but got 'com.vmware.vcenter.vm_template.library_items.deploy_placement_spec'", args=['com.vmware.vcenter.vm_template.library_items.placement_spec', 'com.vmware.vcenter.vm_template.library_items.deploy_placement_spec'])], data : None}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "samples/vsphere/contentlibrary/vmtemplate/deploy_vm_template.py", line 171, in <module>
    main()
  File "samples/vsphere/contentlibrary/vmtemplate/deploy_vm_template.py", line 167, in main
    sample.main()
  File "/tmp/vsphere-automation-sdk-python/samples/vsphere/common/sample_base.py", line 97, in main
    self.run()
  File "/tmp/vsphere-automation-sdk-python/samples/vsphere/common/sample_base.py", line 85, in run
    raise Exception(e)
Exception: {messages : [LocalizableMessage(id='vapi.invoke.input.invalid', default_message='Unable to validate input to method com.vmware.vcenter.vm_template.library_items.deploy', args=['com.vmware.vcenter.vm_template.library_items.deploy']), LocalizableMessage(id='vapi.data.structure.field.invalid', default_message='Found invalid field spec in structure.', args=['spec']), LocalizableMessage(id='vapi.data.structure.field.invalid', default_message='Found invalid field placement in structure.', args=['placement']), LocalizableMessage(id='vapi.data.optional.validate', default_message='The given OptionalValue does not match the OptionalDefinition', args=[]), LocalizableMessage(id='vapi.data.structure.name.mismatch', default_message="Name mismatch for structure.  Expected 'com.vmware.vcenter.vm_template.library_items.placement_spec', but got 'com.vmware.vcenter.vm_template.library_items.deploy_placement_spec'", args=['com.vmware.vcenter.vm_template.library_items.placement_spec', 'com.vmware.vcenter.vm_template.library_items.deploy_placement_spec'])], data : None}
disconnecting the session

Actual behavior

Error above

Expected behavior

VM deployed from template

Try to add RDM disk to VM got error "Incompatible device backing specified for device '0'".

Environment

  • sdk package version:

(vSphere_sdk_virt_env) [root@SIOVM-9 ~]# pip list | grep v
pyvmomi 6.7.1
vapi-client-bindings 1.5.0
vapi-common-client 2.10.2
vapi-runtime 2.10.2
vapi-vmc-client 2.10.2
vmc-app-python-sdk 2.2.0.0.0.15184434
vmc-client-bindings 1.3.0
(vSphere_sdk_virt_env) [root@SIOVM-9 ~]#

  • python version:

(vSphere_sdk_virt_env) [root@SIOVM-9 ~]# python --version
Python 3.5.1
(vSphere_sdk_virt_env) [root@SIOVM-9 ~]#

  • vSphere version:
    Version 6.7.0.1150 Build 8170132

  • Operating System/Shell (used to run SDK-based apps):
    Red Hat 7.3

Steps or code snippet to reproduce

I attached the sample code that i used. failed the function add_remove_vm_disk. Other functions succeeded.
vsphere_api_1.zip

Problem description:
Hi,

Trying to add device /vmfs/devices/disks/eui.57df0280647efa2de9751c5d0000000a as RDM disk to VM I do the following

  1. Create meta and flat vdmk files in the datastore_path:
    datastore_root_path = "[vm1_thick] RHEL70_thick13"
    datastore_path = datastore_root_path + '/RHEL70_thick13_2.vmdk'

by running
vdm = service_instance.content.virtualDiskManager
task = vdm.CreateVirtualDisk(
datastore_path, datacenter_mo,
vim.VirtualDiskManager.DeviceBackedVirtualDiskSpec(
diskType='rdmp', adapterType='lsiLogic',
device = "/vmfs/devices/disks/eui.57df0280647efa2de9751c5d0000000a"))
pyVim.task.WaitForTask(task)

After this call in the directory
/vmfs/volumes/vm1_thick/RHEL70_thick13 appear meta file RHEL70_thick13_2.vmdk and disk file RHEL70_thick13_2-rdmp.vmdk

  1. Run the following code adapted from https://github.com/vmware/vsphere-automation-sdk-python/tree/master/samples/vsphere/vcenter/vm/hardware/disk.py

     disk_create_spec = Disk.CreateSpec(
         type=Disk.HostBusAdapterType.SCSI,
         backing=Disk.BackingSpec(type=Disk.BackingType.VMDK_FILE,
                                  vmdk_file=datastore_path))
     disk = self.client.vcenter.vm.hardware.Disk.create(vm=self.vm, spec=disk_create_spec)
    
  2. Got the following error:
    File "/root/vmware/vsphere_api.py", line 320, in add_remove_vm_disk
    disk = self.client.vcenter.vm.hardware.Disk.create(vm=self.vm, spec=disk_create_spec)
    File "/root/vSphere_sdk_virt_env/lib/python3.5/site-packages/com/vmware/vcenter/vm/hardware_client.py", line 2634, in create
    'spec': spec,
    File "/root/vSphere_sdk_virt_env/lib/python3.5/site-packages/vmware/vapi/bindings/stub.py", line 317, in _invoke
    return self._api_interface.native_invoke(ctx, _method_name, kwargs)
    File "/root/vSphere_sdk_virt_env/lib/python3.5/site-packages/vmware/vapi/bindings/stub.py", line 275, in native_invoke
    self._rest_converter_mode)
    com.vmware.vapi.std.errors_client.InvalidArgument: {messages : [LocalizableMessage(default_message="Incompatible device backing specified for device '0'.", args=[], id='vmsg.InvalidDeviceBacking.summary')], data : None}

  3. PowerCli command
    New-HardDisk -VM RHEL70_thick13 -DiskType RawPhysical -DeviceName /vmfs/devices/disks/eui.57df0280647efa2de9751c5d0000000a

and RDM disk addition though vSphere client work OK and querying the disks shows that I gave correct parameters in the above functions.

Can you advise please what is the problem and how to solve it?
Thanks

Actual behavior

Get the following exception:
com.vmware.vapi.std.errors_client.InvalidArgument: {messages : [LocalizableMessage(default_message="Incompatible device backing specified for device '0'.", args=[], id='vmsg.InvalidDeviceBacking.summary')], data : None}

Expected behavior

Added RDM disk to VM

external_psc_sso_workflow.py : faultcode: ns0:FailedAuthentication

While running the external_psc_sso_workflow I am getting Failed Authentication Error. But the credential that I am using is correct.

#### Example: Login to vCenter server with external Platform Services Controller

Step 1: Connect to the lookup service on the Platform Services Controller node: https://w3-stras-f5lb.eng.vmware.com/lookupservice/sdk

Step 2: Discover the Single Sign-On service URL from lookup service.
Sso URL: https://w3-stras-f5lb.eng.vmware.com/sts/STSService/vsphere.local

Step 3: Connect to the Single Sign-On URL and retrieve the SAML bearer token.
Traceback (most recent call last):
  File "external_psc_sso_workflow.py", line 218, in <module>
    main()
  File "external_psc_sso_workflow.py", line 213, in main
    external_psc_sso_workflow.run()
  File "external_psc_sso_workflow.py", line 151, in run
    ssl_context=context)
  File "C:\Users\smrutim\Documents\Projects\MyPrograms\Python\vsphere-automation-sdk-python\samples\vsphere\common\sso.py", line 329, in get_bearer_saml_assertion
    ssl_context)
  File "C:\Users\smrutim\Documents\Projects\MyPrograms\Python\vsphere-automation-sdk-python\samples\vsphere\common\sso.py", line 268, in perform_request
    raise SoapException(fault, *parsed_fault)
samples.vsphere.common.sso.SoapException: SoapException:
faultcode: ns0:FailedAuthentication
faultstring: Invalid credentials
faultxml: <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"><faultcode xmlns:ns0="http://docs.oasis-open.org/ws-sx/ws-trust/200512">ns0:FailedAuthentication</faultcode><faultstring>Invalid credentials</faultstring></S:Fault></S:Body></S:Envelope>

how to get vms in folder

I am trying to get VMs fro specific folder.
my code
from com.vmware.vcenter_client import VM
vm_svc = VM(stub_config)
vm_svc.list(VM.FilterSpec(folders=set(['vm'])))
In the result I got empty list.
What am I doing wrong ?
If don't use filter I get all VMs in venter.

Minimize requirements on 3rd party libraries

Hello,

could you please consider minimizing 3rd party lib requirements? We'd really love to use the SDK rather then PyVmomi directly but currently the huge amount of 3rd party libs makes this project highly dependend on many moving parts that often break.
Currently I see at least those requirements:

certifi, urllib3, chardet, idna, requests, six, pyVmomi, suds-jurko, tabulate, setuptools, pyasn1, pyasn1-modules, pycparser, cffi, asn1crypto, cryptography, pyOpenSSL, attrs, service-identity, lxml, zope.interface, constantly, incremental, Automat, hyperlink, PyHamcrest, twisted, simplejson, werkzeug, vapi-runtime, vapi-client-bindings, vapi-vmc-client, vapi-common-client, nsx-policy-python-sdk

All of that just to deploy a VM against the SOAP API?

Also I'm not sure what's the Python 2 compatibility all about. With 6.5 we got full Python3 support in ESXi / vCenter and since Python 2 will be unsupportet with 2020, so as will be vSphere 6.0, I would imagine it will be hell alot of work to remove all the by then finally and all for good dead Python 2 workarounds. Getting rid of the six package would make PyVmomi way less dependend as well.

Just to give you an example: currently just in order to install the SDK on Windows one will require the twisted library (required by suds-jurko I believe). And installing twisted will fail if you don't have Visual Studio installed, since it needs some propriatary binaries (!) like cl.exe just to get installed.
I'm not sure how this does match up with the "open source" definition.

I mean I'm not saying everything should be done without using any 3rd party libs. But 29 3rd party libs just to make some SOAP / REST calls?

sddc_crud.py samples throws exception when waiting for task to complete.

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:

pyvmomi (6.7.0)
service-identity (17.0.0)
vapi-client-bindings (1.3.0)
vapi-common-client (2.9.0)
vapi-runtime (2.9.0)
vapi-vmc-client (2.9.0)
vmc-app-python-sdk (2.2.0.0.0.15184434)
vmc-client-bindings (1.2.0)

  • python version:

Python 3.6.3

  • vSphere version:
    VMware cloud on AWS

Steps or code snippet to reproduce

(py3) het-m03:vsphere-automation-sdk-python het$ python samples/vmc/sddc/sddc_crud.py -r $TOKEN -o $ORG -cs

Example: Create a SDDC (Sample SDDC 31) in org 058f47c4-92aa-417f-8747-87f3ed61cb45:

Wait for task 5f10f0e2-fa6e-49a1-a98d-0dd15ade56ad to finish
Checking task status every 60 seconds
Estimated time remaining: 108 minutes
Traceback (most recent call last):
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "samples/vmc/sddc/sddc_crud.py", line 200, in
main()
File "samples/vmc/sddc/sddc_crud.py", line 192, in main
sddc_operations.create_sddc()
File "samples/vmc/sddc/sddc_crud.py", line 137, in create_sddc
interval_sec=self.interval_sec)
File "/Users/het/github/vsphere-automation-sdk-python/samples/vmc/helpers/vmc_task_helper.py", line 35, in wait_for_task
task = task_client.get(org_id, task_id)
File "/Users/het/envs/py3/lib/python3.6/site-packages/com/vmware/vmc/orgs_client.py", line 521, in get
'task': task,
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 317, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 243, in native_invoke
method_result = self.invoke(ctx, method_id, data_val)
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 179, in invoke
ctx)
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/security/client/security_context_filter.py", line 99, in invoke
self, service_id, operation_id, input_value, new_ctx)
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/provider/filter.py", line 76, in invoke
service_id, operation_id, input_value, ctx)
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/rest_connector.py", line 95, in invoke
operation_rest_metadata, self._is_vapi_rest)
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/rest_connector.py", line 146, in _invoke
http_response = self._http_provider.do_request(http_request)
File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/protocol/client/rpc/requests_provider.py", line 98, in do_request
cookies=http_request.cookies, timeout=timeout)
File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/adapters.py", line 495, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

Expected behavior

Pull task every 1min until the task is finished.

Problem while creating a vm from template using the vm template create_vm_template.py"

I am trying to create a template of a vm and deploy a template using this /create_vm_template.py" but getting an error do i need specific versions to run this, can you guys help me

this is the error
com.vmware.vapi.std.errors_client.OperationNotFound: {messages : [LocalizableMessage(default_message="Cannot find service 'com.vmware.vcenter.vm_template.library_items'.", args=['com.vmware.vcenter.vm_template.library_items'], id='vapi.method.input.invalid.interface')], data : None}

Could not find a version that satisfies the requirement vapi-client-bindings==1.5.0 (from -r requirements.txt...)

Help me please:

Environment

  • sdk package version:
    [root@galaxycloud vsphere-automation-sdk-python]# pip list | grep v
    virtualenv 15.1.0

[root@galaxycloud vsphere-automation-sdk-python]# pip --version
pip 18.1 from /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pip (python 3.6)
[root@galaxycloud vsphere-automation-sdk-python]# python --version
Python 3.6.3

  • vSphere version: 6.5

  • Operating System/Shell (used to run SDK-based apps): Centos

Steps or code snippet to reproduce

I have the this error:

[root@galaxycloud vsphere-automation-sdk-python]# pip install -r requirements.txt --extra-index-url /share/vsphere-automation-sdk-python/lib/
Ignoring suds: markers 'python_version < "3"' don't match your environment
Looking in indexes: https://pypi.org/simple, /share/vsphere-automation-sdk-python/lib/
Collecting pyVmomi>=6.7 (from -r requirements.txt (line 1))
  Url '/share/vsphere-automation-sdk-python/lib/pyvmomi/' is ignored. It is either a non-existing path or lacks a specific scheme.
  Using cached https://files.pythonhosted.org/packages/ee/9a/7b24db4501e720fbd0a3578a8dde4b03d20b6fc3427e992dce19a3cf5cfc/pyvmomi-6.7.1.zip
Collecting suds-jurko (from -r requirements.txt (line 3))
  Url '/share/vsphere-automation-sdk-python/lib/suds-jurko/' is ignored. It is either a non-existing path or lacks a specific scheme.
  Using cached https://files.pythonhosted.org/packages/bd/6f/54fbf0999a606680d27c69b1ad12dfff62768ecb9fe48524cebda6eb4423/suds-jurko-0.6.tar.bz2
Collecting tabulate (from -r requirements.txt (line 4))
  Url '/share/vsphere-automation-sdk-python/lib/tabulate/' is ignored. It is either a non-existing path or lacks a specific scheme.
  Using cached https://files.pythonhosted.org/packages/12/c2/11d6845db5edf1295bc08b2f488cf5937806586afe42936c3f34c097ebdc/tabulate-0.8.2.tar.gz
Collecting vapi-client-bindings==1.5.0 (from -r requirements.txt (line 5))
  Could not find a version that satisfies the requirement vapi-client-bindings==1.5.0 (from -r requirements.txt (line 5)) (from versions: 2.5.0)
No matching distribution found for vapi-client-bindings==1.5.0 (from -r requirements.txt (line 5))
You have mail in /var/spool/mail/root

Requirements.txt:

pyVmomi >= 6.7
suds ; python_version < '3'
suds-jurko ; python_version >= '3.0'
tabulate
vapi-client-bindings == 1.5.0
vmc-client-bindings
vapi-vmc-client
nsx-policy-python-sdk
vmc-app-python-sdk 

Permissions to access appliance_client.Monitoring

According to https://pubs.vmware.com/vsphere-6-5/index.jsp#com.vmware.vsphere.vcsapg-rest.doc/GUID-D7469D6F-5778-48B7-9AEB-865EC3E2226F.html I've added my account to "ComponentManager.Administrator" vCenter Single Sign-On Group. But it still throws error:
{messages : [LocalizableMessage(id='vapi.security.authorization.invalid', default_message='Unable to authorize user', args=[])], data : None}
But it works when I add account to SystemConfiguration.Administrators group.
Relevant part of code:

monitoring = appliance_client.Monitoring(config)
items = monitoring.list()

'com.vmware.vcenter.vm' where is it?

from com.vmware.vcenter.vm.hardware.boot_client import Device as BootDevice

from com.vmware.vcenter.vm.hardware_client import (
    Disk, Ethernet)

from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec

from com.vmware.vcenter.vm_client import (Power)

from com.vmware.vcenter_client import VM

where are these modules?

New API for license manager

Hello,

I am currently using license Manager using the pyvmomi library on my python code and I am using the following methods: UpdateAssignedLicense() and QueryAssignedLicenses(). According to the following link: https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.LicenseAssignmentManager.html

These methods are deprecated and it wants me to use cis.license.management.SystemManagementService. I want to use the new APIs but I dont how to call them from pyvmomi. Documentation online does not help. Any ideas on how to use these new APIs?

list_vms.py does not

Traceback (most recent call last):
File "./list_vms.py", line 61, in
main()
File "./list_vms.py", line 57, in main
run()
File "./list_vms.py", line 46, in run
list_of_vms = vm_svc.list()
File "/usr/lib/python2.7/site-packages/com/vmware/vcenter_client.py", line 3077, in list
'filter': filter,
File "/usr/lib/python2.7/site-packages/vmware/vapi/bindings/stub.py", line 238, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "/usr/lib/python2.7/site-packages/vmware/vapi/bindings/stub.py", line 197, in native_invoke
self._config.resolver)
com.vmware.vapi.std.errors_client.OperationNotFound: {data : None, messages : [LocalizableMessage(default_message="Cannot find service 'com.vmware.vcenter.VM'.", args=['com.vmware.vcenter.VM'], id='vapi.method.input.invalid.interface')]}

public_ip_crud.py throws error

  • I am using the [latest SDK version]
  • This API is compatible with my vCenter version 6.7 VMC on AWS
  • I have searched existing issues

Environment

  • sdk package version:
    javapackages (1.0.0)
    pyudev (0.21.0)
    pyvmomi (6.7.0)
    service-identity (17.0.0)
    vapi-client-bindings (1.3.1)
    vapi-common-client (2.9.0)
    vapi-runtime (2.9.0)
    vapi-vmc-client (2.9.0)
    virtualenv (1.10.1)
    vmc-app-python-sdk (2.2.0.0.0.15184434)
    vmc-client-bindings (1.2.0)

  • python version:
    Python 2.7.5

  • vSphere version:
    vSphere version 6..7

  • Operating System/Shell (used to run SDK-based apps):
    RHEL 7.4

Steps or code snippet to reproduce

python samples/vmc/networks/public_ip_crud.py -r -o -s

Actual behavior

Throws below error:
Traceback (most recent call last):
File "samples/vmc/networks/public_ip_crud.py", line 23, in
from samples.vmc.helpers.vmc_task_helper import wait_for_task
ImportError: No module named samples.vmc.helpers.vmc_task_helper

Expected behavior

It should list MGW public IPs

Setup issue during prereq installation via requirements.txt

I'm hitting issues on CentOS and IOSX, while trying to install the prereqs from the requirements.txt:

[00:43][asulikeri:/Documents/vsphere-automation-sdk-python-master]$ source SDKDemo/bin/activate
(SDKDemo) [00:44][asulikeri:
/Documents/vsphere-automation-sdk-python-master]$ pip3 install -r requirements.txt
Ignoring suds: markers ‘python_version =6.5 (from -r requirements.txt (line 1))
Downloading pyvmomi-6.5.0.2017.5-1.tar.gz (252kB)
100% |████████████████████████████████| 256kB 1.8MB/s
Collecting suds-jurko (from -r requirements.txt (line 3))
Downloading suds-jurko-0.6.tar.bz2 (143kB)
100% |████████████████████████████████| 153kB 3.8MB/s
Collecting vapi-client-bindings (from -r requirements.txt (line 4))
Could not find a version that satisfies the requirement vapi-client-bindings (from -r requirements.txt (line 4)) (from versions: )
No matching distribution found for vapi-client-bindings (from -r requirements.txt (line 4))

And after that when I try to run the script I hit the following issues:

(SDKDemo) [00:44][asulikeri:~/Documents/vsphere-automation-sdk-python-master]$ python samples/vsphere/vcenter/setup/main.py
Traceback (most recent call last):
File “samples/vsphere/vcenter/setup/main.py”, line 25, in
import pyVim.connect
ModuleNotFoundError: No module named ‘pyVim’

Any idea if I’m missing out on anything.

problem to install vsphere-automation-sdk-python exception occurs at vapi-client-bindings

  • [v ] I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:
    [root@python01 vsphere-automation-sdk-python]# pip list | grep v
    pyudev 0.15
    pyvmomi 6.7.0
    virtualenv 15.2.0
    pip 10.0.0

  • python version:
    Python 2.7.5

  • vSphere version:
    6.0

Steps or code snippet to reproduce

clone vsphere-automation-sdk-python was successful.
It cloned under root folder
[root@python01 vsphere-automation-sdk-python]# pwd
/root/vsphere-automation-sdk-python

[root@python01 vsphere-automation-sdk-python]# pip install -r requirements.txt --extra-index-url file:///pwd/lib

Actual behavior

Ignoring suds-jurko: markers 'python_version >= "3.0"' don't match your environment
Looking in indexes: https://pypi.python.org/simple, file:////root/vsphere-automation-sdk-python/lib
Requirement already satisfied: pyVmomi>=6.5 in /usr/lib/python2.7/site-packages (from -r requirements.txt (line 1)) (6.7.0)
Collecting suds (from -r requirements.txt (line 2))
Url 'file:////root/vsphere-automation-sdk-python/lib/suds/' is ignored: it is neither a file nor a directory.
Using cached https://files.pythonhosted.org/packages/bc/d6/960acce47ee6f096345fe5a7d9be7708135fd1d0713571836f073efc7393/suds-0.4.tar.gz
Collecting tabulate (from -r requirements.txt (line 4))
Url 'file:////root/vsphere-automation-sdk-python/lib/tabulate/' is ignored: it is neither a file nor a directory.
Using cached https://files.pythonhosted.org/packages/12/c2/11d6845db5edf1295bc08b2f488cf5937806586afe42936c3f34c097ebdc/tabulate-0.8.2.tar.gz
Collecting vapi-client-bindings==1.2.0 (from -r requirements.txt (line 5))
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/_internal/basecommand.py", line 228, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 291, in run
resolver.resolve(requirement_set)
File "/usr/lib/python2.7/site-packages/pip/_internal/resolve.py", line 103, in resolve
self._resolve_one(requirement_set, req)
File "/usr/lib/python2.7/site-packages/pip/_internal/resolve.py", line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python2.7/site-packages/pip/_internal/resolve.py", line 210, in _get_abstract_dist_for
self.require_hashes
File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 243, in prepare_linked_requirement
req.populate_link(finder, upgrade_allowed, require_hashes)
File "/usr/lib/python2.7/site-packages/pip/_internal/req/req_install.py", line 307, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python2.7/site-packages/pip/_internal/index.py", line 484, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python2.7/site-packages/pip/_internal/index.py", line 442, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python2.7/site-packages/pip/_internal/index.py", line 587, in _get_pages
page = self._get_page(location)
File "/usr/lib/python2.7/site-packages/pip/_internal/index.py", line 705, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python2.7/site-packages/pip/_internal/index.py", line 814, in get_page
"Cache-Control": "max-age=600",
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/_internal/download.py", line 397, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 658, in send
r.content
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/models.py", line 823, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/models.py", line 756, in generate
chunk = self.raw.read(chunk_size)
AttributeError: 'exceptions.OSError' object has no attribute 'read'

python code failed to read module. from vmware.vapi.vsphere.client import create_vsphere_client is not working

Expected behavior

from vmware.vapi.vsphere.client import create_vsphere_client should work and python code allow to connect vcenter server.

Can anyone tell me what I have done wrong?

Thank you

Use tags to filter list vms

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Hello.

I was wondering, is there any way to list vms/datastores/others stuff with a filter on tags ?

I wish to do it like in PowerCli (for example: $VMs = Get-VM -Tag "PreProd") but I didn't see any information to do it with Python SDK.

I'm a beggenner so maybe I miss something.

Best regards

ImportError: No module named samples.vsphere.common.sample_base

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:
    pyvmomi (6.7.0.2018.9)
    service-identity (17.0.0)
    vapi-client-bindings (1.3.1)
    vapi-common-client (2.9.0)
    vapi-runtime (2.9.0)
    vapi-vmc-client (2.9.0)
    virtualenv (16.0.0)
    vmc-app-python-sdk (2.2.0.0.0.15184434)
    vmc-client-bindings (1.2.0)

  • python version:
    Python 2.7.15rc1

  • vSphere version:
    6.0.0

  • Operating System/Shell (used to run SDK-based apps):
    Ubuntu 18.04.1

Steps or code snippet to reproduce

python tagging_workflow.py --server 'IP' --username 'LOGIN' --password 'PASSWD' --clustername 'MAQ' --categoryname 'Cat' --categorydesc 'category' --tagname 'Tag' -tagdesc 'Tag' -v

Actual behavior

Traceback (most recent call last):
File "tagging_workflow.py", line 26, in
from samples.vsphere.common.sample_base import SampleBase
ImportError: No module named samples.vsphere.common.sample_base

Expected behavior

Execution of the workflow

Installation fails on CentOS

  • [. ] I am using the latest SDK version
  • [. ] This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • [. ] I have searched existing issues

Environment

  • sdk package version:
    pyvmomi (6.7.0)
    service-identity (17.0.0)
    vapi-client-bindings (1.3.1)
    vapi-common-client (2.9.0)
    vapi-runtime (2.9.0)
    vapi-vmc-client (2.9.0)
    vmc-app-python-sdk (2.2.0.0.0.15184434)
    vmc-client-bindings (1.2.0)

  • python version:
    3.4.8

  • vSphere version:
    N/A

  • Operating System/Shell (used to run SDK-based apps):
    CentOS 7

Steps or code snippet to reproduce

Follow the instructions:
git clone https://github.com/vmware/vsphere-automation-sdk-python.git
cd vsphere-automation-sdk-python
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///<absolute_path_to_sdk>/lib

Actual behavior

While installing twisted the pip installation fails:
src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1

Resolution

Not sure about other systems, but on CentOS 7 you also need to run yum install -y python34-devel
It's just python-devel for python2.

Edit: It's also worth noting installation fails on Python 3.7 because Twisted hasn't yet been updated.

External Project (AutoREST) Finds Schema Validation Errors

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:

Latest version

  • python version:

Python 3.7

  • vSphere version:

6.5

  • Operating System/Shell (used to run SDK-based apps):

Terminal

Steps or code snippet to reproduce

Use: https://github.com/Azure/autorest + https://github.com/Azure/autorest.incubator

Run:
autorest [email protected]/autorest.incubator@preview --powershell --input-file=vcenter.json --output-folder=./GeneratedModules/vcenter

Actual behavior

PS C:\Temp> autorest [email protected]/autorest.incubator@preview --powershell --input-file=vcenter.json --output-folder=./GeneratedModules/vcenter
AutoRest code generation utility [version: 2.0.4283; node: v8.11.1]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\Kyle Ruddy\.autorest\@[email protected]\node_modules\@microsoft.azure\autorest-core\dist' (2.0.4289)
   Loading AutoRest extension '@microsoft.azure/autorest.incubator' (preview->1.0.132)
ERROR: Schema violation: Data does not match any schemas from 'anyOf'
    - file:///C:/Temp/vcenter.json:10656:20 ($.definitions["vcenter.inventory.network.find_result"].properties.value.items)
ERROR: Schema violation: Data does not match any schemas from 'anyOf'
    - file:///C:/Temp/vcenter.json:10606:20 ($.definitions["vcenter.inventory.datastore.find_result"].properties.value.items)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Temp/vcenter.json:1252:16 ($.paths["/vcenter/deployment/install/initial-config/remote-psc/thumbprint"].get.parameters)
FATAL: swagger-document/individual/schema-validator - FAILED
FATAL: Error: [OperationAbortedException] Error occurred. Exiting.
Process() cancelled due to exception : [OperationAbortedException] Error occurred. Exiting.
PS C:\Temp> autorest [email protected]/autorest.incubator@preview --powershell --input-file=appliance.json --output
-folder=./GeneratedModules/appliance
AutoRest code generation utility [version: 2.0.4283; node: v8.11.1]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\Kyle Ruddy\.autorest\@[email protected]\node_modules\@microsoft.azure\autorest-core\dist' (2.0.4289)
   Loading AutoRest extension '@microsoft.azure/autorest.incubator' (preview->1.0.132)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Temp/appliance.json:3574:16 ($.paths["/appliance/update/pending"].get.parameters)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Temp/appliance.json:2430:16 ($.paths["/appliance/recovery/backup/system-name/{system_name}/archives/{archive}"].get.parameters)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Temp/appliance.json:2374:16 ($.paths["/appliance/recovery/backup/system-name/{system_name}/archives"].get.parameters)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Temp/appliance.json:2374:16 ($.paths["/appliance/recovery/backup/system-name/{system_name}/archives"].get.parameters)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Temp/appliance.json:2334:16 ($.paths["/appliance/recovery/backup/system-name"].get.parameters)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Temp/appliance.json:875:16 ($.paths["/appliance/monitoring/query"].get.parameters)
FATAL: swagger-document/individual/schema-validator - FAILED
FATAL: Error: [OperationAbortedException] Error occurred. Exiting.
Process() cancelled due to exception : [OperationAbortedException] Error occurred. Exiting.
PS C:\Temp>

Expected behavior

Successful completion of the AutoREST code generation.

vmconf = vim.vm.ConfigSpec(numCPUs=1, memoryMB=mem)

Hi,
i'm trying to add vm , i put user name , password, vcenter IP adress and name of VM . and error appear .
please how to correct this problem:
Traceback (most recent call last):
File "C:/Users/khalil/PycharmProjects/vmware/finalScript/pyvmomicreateVM.py", line 34, in
vmconf = vim.vm.ConfigSpec(numCPUs=1, memoryMB=mem)
AttributeError: 'module' object has no attribute 'vm'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "C:\Python27\lib\atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
WindowsError: [Error 32] Le processus ne peut pas acc�der au fichier car ce fichier est utilis� par un autre processus: 'c:\users\khalil\appdata\local\temp\tmp4xh6zd.py'
Error in sys.exitfunc:
Traceback (most recent call last):
File "C:\Python27\lib\atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
WindowsError: [Error 32] Le processus ne peut pas acc�der au fichier car ce fichier est utilis� par un autre processus: 'c:\users\khalil\appdata\local\temp\tmp4xh6zd.py'

com.vmware.vapi.std.errors_client.OperationNotFound

Hi,

I went to create virtual machine in VMWARE VCENTER with python script. I tested scripts in this link : https://github.com/vmware/vsphere-automation-sdk-python/tree/master/samples/vsphere/vcenter/vm i tested create create_exhaustive_vm and delete_vm , error appear with create : com.vmware.vapi.std.errors_client.OperationNotFound: {data : None, messages : [LocalizableMessage(default_message="Cannot find service 'com.vmware.vcenter.VM'.", args=['com.vmware.vcenter.VM'], id='vapi.method.input.invalid.interface')]}

Error in delete vm : com.vmware.vapi.std.errors_client.OperationNotFound: {data : None, messages : [LocalizableMessage(default_message="Cannot find service 'com.vmware.vcenter.VM'.", args=['com.vmware.vcenter.VM'], id='vapi.method.input.invalid.interface')]}

Same error , please how to resolve this problem.

how to get vms in folder

I am trying to get VMs from specific folder and subfolders.
I've opened issue 85, but the solution doesn't provide with vms in subfolder.
Is it not possible to get vms in subfolders ?

ModuleNotFoundError: No module named 'vmware.vapi.vsphere'

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:

master

  • python version:

python 3.6.3

  • vSphere version:

  • Operating System/Shell (used to run SDK-based apps):
    Centos 7.5

Steps or code snippet to reproduce

Actual behavior

pip3 install --upgrade --force-reinstall -r requirements.txt --extra-index-url file://$PWD/lib install successfully` :

Successfully installed Automat-0.7.0 PyHamcrest-1.9.0 asn1crypto-0.24.0 attrs-18.1.0 certifi-2018.8.24 cffi-1.11.5 chardet-3.0.4 constantly-15.1.0 cryptography-2.3.1 hyperlink-18.0.0 idna-2.7 incremental-17.5.0 lxml-4.2.4 nsx-policy-python-sdk-2.2.0.0.0.15184434 pyOpenSSL-18.0.0 pyVmomi-6.7.0 pyasn1-0.4.4 pyasn1-modules-0.2.2 pycparser-2.18 requests-2.19.1 service-identity-17.0.0 setuptools-40.2.0 simplejson-3.16.0 six-1.11.0 suds-jurko-0.6 tabulate-0.8.2 twisted-18.7.0 urllib3-1.23 vapi-client-bindings-2.5.0 vapi-common-client-2.9.0 vapi-runtime-2.9.0 vapi-vmc-client-2.9.0 vmc-app-python-sdk-2.2.0.0.0.15184434 vmc-client-bindings-1.2.0 werkzeug-0.14.1 zope.interface-4.5.0

Test as guide sample but get below error :

>>> import requests
>>> import urllib3
>>> from vmware.vapi.vsphere.client import create_vsphere_client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'vmware.vapi.vsphere'

Expected behavior

List tag name and description

Hello,

This is not an issue, but just a question.

I am new to this SDK. I need to list all the tag's and categories. I get the tag ID, but not name or description from the following code. Any idea how can I extract this ?

vmware/pyvmomi#307

Create Tagging services

tag_svc = Tag(stub_config)
category_svc = Category(stub_config)
tag_association = TagAssociation(stub_config)

print('List all the existing categories user has access to...')
categories = category_svc.list()

if len(categories) > 0:
for category in categories:
print('Found Category: {0}'.format(category))
else:
print('No Tag Category Found...')
print('List all the existing tags user has access to...')

tags = tag_svc.list()
print(tags[0])

if len(tags) > 0:
for tag in tags:
print('Found Tag: {0}'.format(tag))
else:
print('No Tag Found...')

Thanks Again

Shyam

PyPI Package

Would it be possible to package this SDK into a PyPI package so it's easier to pip install and define in a requirements.txt file, rather than having to download this repo and "hand install" it?

'vapi-client-bindings does not satisfy requirements'

  • I am using the latest SDK version
  • This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • I have searched existing issues

Environment

  • sdk package version:
  • python version:
  • vSphere version: 6.5

Steps or code snippet to reproduce

pip install of current master sdk on Windows host with Python 3.6.5, no prior install of automation sdk.

Actual behavior

Error: Could not find a version that satisfies the requirement vapi-client-bindings==1.3.1 (from -r requirements.txt (line5)) (from versions:2.5.0) matching distribution found for vapi-client-bindings==1.3.1 (from -r requirements.txt (line 5))

Expected behavior

Install SDK

com.vmware.vapi.std.errors_client.OperationNotFound

code:
import requests
import urllib3

from vmware.vapi.vsphere.client import create_vsphere_client
session = requests.session()

Disable cert verification for demo purpose.

This is not recommended in a production environment.

session.verify = False

Disable the secure connection warning for demo purpose.

This is not recommended in a production environment.

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Connect to a vCenter Server using username and password

vsphere_client = create_vsphere_client(server='192.168.8.85', username='[email protected]', password='1qaz@WSX', session=session)

List all VMs inside the vCenter Server

print(vsphere_client.vcenter.VM.list())

but error under

Traceback (most recent call last):
File "ml_vmuuid.py", line 29, in
print(vsphere_client.vcenter.Datacenter.list(None))
File "C:\Users\15470\AppData\Roaming\Python\Python36\site-packages\com\vmware\vcenter_client.py", line 619, in list
'filter': filter,
File "C:\Users\15470\AppData\Roaming\Python\Python36\site-packages\vmware\vapi\bindings\stub.py", line 317, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "C:\Users\15470\AppData\Roaming\Python\Python36\site-packages\vmware\vapi\bindings\stub.py", line 275, in native_invoke
self._rest_converter_mode)
com.vmware.vapi.std.errors_client.OperationNotFound: {messages : [LocalizableMessage(id='vapi.method.input.invalid.interface', default_message='æ\x89¾ä¸\x8då\x88°æ\x9c\x8då\x8a¡â\x80\x9ccom.vmware.vcenter.datacenterâ\x80\x9dã\x80\x82', args=['com.vmware.vcenter.datacenter'])], data : None}

G:\eclipse_work\python-test-one\src\com\ml>

task_client.list(org_id) returns AttributeError: 'StructValue' object has no attribute 'value'

From the Python SDK for VMC:

>>> from com.vmware.vmc.model_client import Task
>>> from vmware.vapi.vmc.client import create_vmc_client
>>> import requests
>>> session = requests.Session()
>>> vmc_client = create_vmc_client("_expunged_",session)
>>> import atexit
>>> atexit.register(session.close)
<bound method Session.close of <requests.sessions.Session object at 0x7f844dd6c630>>
>>> task_client=vmc_client.orgs.Tasks
>>> org_id = '_expunged_from_this_issue_report_'
>>> task_client.list(org_id)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/com/vmware/vmc/orgs_client.py", line 493, in list
    'filter': filter,
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 317, in _invoke
    return self._api_interface.native_invoke(ctx, _method_name, kwargs)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 258, in native_invoke
    self._rest_converter_mode)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 1079, in convert_to_python
    binding_type.accept(visitor)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/type.py", line 40, in accept
    visitor.visit(self)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 617, in visit_list
    for elt_value in in_value]
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 617, in <listcomp>
    for elt_value in in_value]
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 604, in _visit_list_element
    self.visit(typ)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 841, in visit_reference
    self.visit(typ.resolved_type)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 727, in visit_struct
    in_value.get_field(field_name), field_type)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 683, in _visit_struct_field
    self.visit(typ)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 984, in visit_optional
    self.visit(typ.element_type)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 617, in visit_list
    for elt_value in in_value]
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 617, in <listcomp>
    for elt_value in in_value]
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 604, in _visit_list_element
    self.visit(typ)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 841, in visit_reference
    self.visit(typ.resolved_type)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 727, in visit_struct
    in_value.get_field(field_name), field_type)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 683, in _visit_struct_field
    self.visit(typ)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/lib/visitor.py", line 43, in visit
    return method(value)
  File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/converter.py", line 527, in visit_string
    self._out_value = str(self._in_value.value)
AttributeError: 'StructValue' object has no attribute 'value'
>>>

This function was working without issue a couple of days ago on the same identical org_id, but now is persistently failing.

[embedded_psc_sso_workflow.py] socket.gaierror: [Errno 11001] getaddrinfo failed

Hi

I am trying to run the Sample code of embedded_psc_sso_workflow.py but I am getting the following error.

#### Example: Login to vCenter server with embedded Platform Services Controller

Step 1: Connect to the Single Sign-On URL and retrieve the SAML bearer token.
Traceback (most recent call last):
  File "embedded_psc_sso_workflow.py", line 134, in <module>
    main()
  File "embedded_psc_sso_workflow.py", line 129, in main
    embedded_psc_sso_workflow.run()
  File "embedded_psc_sso_workflow.py", line 71, in run
    ssl_context=context)
  File "C:\Users\smrutim\Documents\Projects\MyPrograms\Python\vsphere-automation-sdk-python\samples\vsphere\common\sso.py", line 329, in get_bearer_saml_assertion
    ssl_context)
  File "C:\Users\smrutim\Documents\Projects\MyPrograms\Python\vsphere-automation-sdk-python\samples\vsphere\common\sso.py", line 255, in perform_request
    webservice.endheaders()
  File "C:\Python27\lib\httplib.py", line 1038, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 882, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 844, in send
    self.connect()
  File "C:\Users\smrutim\Documents\Projects\MyPrograms\Python\vsphere-automation-sdk-python\samples\vsphere\common\sso.py", line 167, in connect
    six.moves.http_client.HTTPSConnection.connect(self)
  File "C:\Python27\lib\httplib.py", line 1255, in connect
    HTTPConnection.connect(self)
  File "C:\Python27\lib\httplib.py", line 821, in connect
    self.timeout, self.source_address)
  File "C:\Python27\lib\socket.py", line 557, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11001] getaddrinfo failed

But if i use ,

context = ssl._create_unverified_context()
si = connect.SmartConnect(host=host,
                                          user=username,
                                          pwd=password,
                                          port=443, sslContext=context)

I am able to login and get the service instance. So there is no problem with address resolution.

How to access instanceUuid

  • I am using the [latest SDK version]

  • This API is compatible with my vCenter version

  • I have searched [existing issues]

  • sdk package version:
    pyvmomi 6.7.0
    service-identity 17.0.0
    vapi-client-bindings 1.3.1
    vapi-common-client 2.9.0
    vapi-runtime 2.9.0
    vapi-vmc-client 2.9.0
    vmc-app-python-sdk 2.2.0.0.0.15184434
    vmc-client-bindings 1.2.0

  • python version:
    Python 2.7.12

  • vSphere version:
    6.5.0

  • Operating System/Shell (used to run SDK-based apps):
    Ubuntu 16.04

vapi_runtime>=2.5.0 error

I cloned this repo as mentioned in the Readme.md

  • sdk package version:
    pip3 list | grep v
    ubuntu-drivers-common (0.0.0)
    unity-scope-colourlovers (0.1)
    unity-scope-devhelp (0.1)
    unity-scope-gdrive (0.7)
    unity-scope-virtualbox (0.1)

  • python version:
    python --version
    Python 3.4.3

Steps or code snippet to reproduce

sudo pip3 install --upgrade --force-reinstall -r requirements.txt --extra-index-url file://pwd/lib

When I ran the above command with the original requirements.txt file, it stopped at vapi-client-bindings, saying that no distributions at all found.
So in the requirements.txt file, I removed all the version constraints. Now it installs its 2.5.0 version, but gives the same error for vapi-runtime.

Actual behavior

Downloading/unpacking pyVmomi>=6.7 (from -r requirements.txt (line 1))
  Downloading pyvmomi-6.7.0-py2.py3-none-any.whl (249kB): 249kB downloaded
Downloading/unpacking suds-jurko (from -r requirements.txt (line 2))
  Downloading suds-jurko-0.6.tar.bz2 (143kB): 143kB downloaded
  Running setup.py (path:/tmp/pip_build_root/suds-jurko/setup.py) egg_info for package suds-jurko
Downloading/unpacking tabulate (from -r requirements.txt (line 3))
  Downloading tabulate-0.8.2.tar.gz (45kB): 45kB downloaded
  Running setup.py (path:/tmp/pip_build_root/tabulate/setup.py) egg_info for package tabulate
Downloading/unpacking vapi-client-bindings (from -r requirements.txt (line 4))
  Downloading vapi_client_bindings-2.5.0.tar.gz (159kB): 159kB downloaded
  Running setup.py (path:/tmp/pip_build_root/vapi-client-bindings/setup.py) egg_info for package vapi-client-bindings
Downloading/unpacking vmc-client-bindings (from -r requirements.txt (line 5))
Downloading/unpacking vapi-vmc-client (from -r requirements.txt (line 6))
Downloading/unpacking nsx-policy-python-sdk (from -r requirements.txt (line 7))
Downloading/unpacking vmc-app-python-sdk (from -r requirements.txt (line 8))
Downloading/unpacking six>=1.7.3 (from pyVmomi>=6.7->-r requirements.txt (line 1))
  Downloading six-1.11.0-py2.py3-none-any.whl
Downloading/unpacking requests>=2.3.0 (from pyVmomi>=6.7->-r requirements.txt (line 1))
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB): 88kB downloaded
Downloading/unpacking setuptools (from vapi-client-bindings->-r requirements.txt (line 4))
  Downloading setuptools-39.2.0-py2.py3-none-any.whl (567kB): 567kB downloaded
Downloading/unpacking vapi_runtime>=2.5.0 (from vapi-client-bindings->-r requirements.txt (line 4))
  Could not find any downloads that satisfy the requirement vapi_runtime>=2.5.0 (from vapi-client-bindings->-r requirements.txt (line 4))
Cleaning up...
No distributions at all found for vapi_runtime>=2.5.0 (from vapi-client-bindings->-r requirements.txt (line 4))
Storing debug log for failure in /home/policybat/.pip/pip.log

Traceback during pip install

Environment

  • sdk package version:
    $ pip list | grep v
    pyvmomi 6.7.1

  • python version:

python --version
Python 2.7.15+
  • vSphere version: N/A (but it is 6.7update1)

  • Operating System/Shell (used to run SDK-based apps):
    Debian 9
    pipenv:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]

[packages]
ansible = "*"
pyvmomi = "*"
google-auth = "*"
apache-libcloud = "*"
ansible-lint = "*"
pycrypto = "*"
markupsafe = "*"

[requires]
python_version = "2.7"

Steps or code snippet to reproduce

pipenv install
pipenv shell
git clone https://github.com/vmware/vsphere-automation-sdk-python.git
cd vsphere-automation-sdk-python
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:////home/bhundven/Projects/work/vsphere-automation-sdk-python/lib

Actual behavior

$ pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:////home/bhundven/Projects/work/vsphere-automation-sdk-python/lib
Ignoring suds-jurko: markers 'python_version >= "3.0"' don't match your environment
Looking in indexes: https://pypi.org/simple, file://home/bhundven/Projects/work/vsphere-automation-sdk-python/lib
Collecting pyVmomi>=6.7 (from -r requirements.txt (line 1))
  Url 'file:////home/bhundven/Projects/work/vsphere-automation-sdk-python/lib/pyvmomi/' is ignored: it is neither a file nor a directory.
  Using cached https://files.pythonhosted.org/packages/ee/9a/7b24db4501e720fbd0a3578a8dde4b03d20b6fc3427e992dce19a3cf5cfc/pyvmomi-6.7.1.zip
Collecting suds (from -r requirements.txt (line 2))
  Url 'file:////home/bhundven/Projects/work/vsphere-automation-sdk-python/lib/suds/' is ignored: it is neither a file nor a directory.
  Using cached https://files.pythonhosted.org/packages/bc/d6/960acce47ee6f096345fe5a7d9be7708135fd1d0713571836f073efc7393/suds-0.4.tar.gz
Collecting tabulate (from -r requirements.txt (line 4))
  Url 'file:////home/bhundven/Projects/work/vsphere-automation-sdk-python/lib/tabulate/' is ignored: it is neither a file nor a directory.
  Using cached https://files.pythonhosted.org/packages/12/c2/11d6845db5edf1295bc08b2f488cf5937806586afe42936c3f34c097ebdc/tabulate-0.8.2.tar.gz
Collecting vapi-client-bindings==1.5.0 (from -r requirements.txt (line 5))
Exception:
Traceback (most recent call last):
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 318, in run
    resolver.resolve(requirement_set)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/resolve.py", line 102, in resolve
    self._resolve_one(requirement_set, req)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/resolve.py", line 256, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/resolve.py", line 209, in _get_abstract_dist_for
    self.require_hashes
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 218, in prepare_linked_requirement
    req.populate_link(finder, upgrade_allowed, require_hashes)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/req/req_install.py", line 164, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/index.py", line 572, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/index.py", line 530, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/index.py", line 675, in _get_pages
    page = self._get_page(location)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/index.py", line 793, in _get_page
    return _get_html_page(link, session=self.session)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/index.py", line 144, in _get_html_page
    "Cache-Control": "max-age=0",
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 525, in get
    return self.request('GET', url, **kwargs)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_internal/download.py", line 396, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 662, in send
    r.content
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_vendor/requests/models.py", line 827, in content
    self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
  File "/home/bhundven/.local/share/virtualenvs/ansible-it-ZGtxbozQ/local/lib/python2.7/site-packages/pip/_vendor/requests/models.py", line 760, in generate
    chunk = self.raw.read(chunk_size)
AttributeError: 'exceptions.OSError' object has no attribute 'read'

Expected behavior

The package installs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.