1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-22 01:39:58 -05:00

Merge pull request #218 from anusha94/master

New bindings and samples for vSphere 7.0
This commit is contained in:
Anusha Hegde 2020-04-14 11:59:36 +05:30 committed by GitHub
commit 0936957864
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 932 additions and 230 deletions

View File

@ -21,11 +21,11 @@ samples require the vSphere Management SDK packages (pyVmomi) to be installed on
The samples have been developed to work with python 2.7.x and 3.3+
## Supported OnPrem vCenter Releases
vCenter 6.0, 6.5 and 6.7.
vCenter 6.0, 6.5, 6.7 and 7.0.
Certain APIs and samples that are introduced in 6.5 release, such as vCenter, Virtual Machine and Appliance Management. Please refer to the notes in each sample for detailed compatibility information.
## Supported NSX-T Releases
NSX-T 2.2, 2.3, 2.5, VMC 1.7
NSX-T 2.2, 2.3, 3.0 and VMC 1.7, 1.8, 1.9
## VMware Cloud on AWS Support
The VMware Cloud on AWS API and samples are currently available as a preview and are subject to change in the future.
@ -214,16 +214,17 @@ $ python samples/vsphere/vcenter/vm/list_vms.py -v
### vSphere API Documentation
* [VMware Cloud on AWS vSphere (latest version)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/cloud/index.html)
* [vSphere 6.7.1 (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.7.1/)
* Previous releases: [6.7.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.7.0) [6.6.1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.6.1) [6.5](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.5) [6.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.0)
* [vSphere 7.0 (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.0.1/)
* Previous releases: [6.7.1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.7.1/) [6.7.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.7.0) [6.6.1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.6.1) [6.5](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.5) [6.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/6.0)
### VMware Cloud on AWS API Documentation
* [VMware Cloud on AWS Console API](https://vmware.github.io/vsphere-automation-sdk-python/vmc/index.html)
* [VMware Cloud on AWS Disaster Recovery as a Service (DRaaS) API](https://vmware.github.io/vsphere-automation-sdk-python/vmc-draas/index.html)
### NSX API Documentation
### NSX API Documentation
* [NSX-T Data Center](https://docs.vmware.com/en/VMware-NSX-T-Data-Center/index.html)
* [NSX Manager APIs](https://vmware.github.io/vsphere-automation-sdk-python/nsx/nsx/index.html) - API for managing NSX-T cluster and transport nodes for on-prem customers
* [NSX Policy](https://vmware.github.io/vsphere-automation-sdk-python/nsx/nsx_policy/index.html) - primary API for managing logical networks for on-prem customers
* [NSX VMC Policy](https://vmware.github.io/vsphere-automation-sdk-python/nsx/nsx_vmc_policy/index.html) - primary API for managing logical networks for VMC customers
@ -240,7 +241,7 @@ Common issues you may run into while installing the sdk and running samples are
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:
* Tianhao He (VMware)
* Anusha Hegde (VMware)
* Pavan Bidkar (VMware)
## VMware Resources

View File

@ -1 +1 @@
<a href='vapi_client_bindings-3.2.0-py2.py3-none-any.whl'>vapi_client_bindings-3.2.0-py2.py3-none-any.whl</a><br />
<a href='vapi_client_bindings-3.3.0-py2.py3-none-any.whl'>vapi_client_bindings-3.3.0-py2.py3-none-any.whl</a><br />

View File

@ -1 +1 @@
<a href='vapi_common_client-2.14.0-py2.py3-none-any.whl'>vapi_common_client-2.14.0-py2.py3-none-any.whl</a><br />
<a href='vapi_common_client-2.15.0-py2.py3-none-any.whl'>vapi_common_client-2.15.0-py2.py3-none-any.whl</a><br />

View File

@ -1 +1 @@
<a href='vapi_runtime-2.14.0-py2.py3-none-any.whl'>vapi_runtime-2.14.0-py2.py3-none-any.whl</a><br />
<a href='vapi_runtime-2.15.0-py2.py3-none-any.whl'>vapi_runtime-2.15.0-py2.py3-none-any.whl</a><br />

View File

@ -2,7 +2,7 @@ lxml >= 4.3.0
pyVmomi >= 6.7
suds ; python_version < '3'
suds-jurko ; python_version >= '3.0'
vapi-client-bindings == 3.2.0
vapi-client-bindings == 3.3.0
vmc-client-bindings
nsx-python-sdk
nsx-policy-python-sdk

View File

@ -1,106 +0,0 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
import os
import requests
from com.vmware.vcenter.system_config_client import DeploymentType
from samples.vsphere.common import sample_cli, sample_util
from samples.vsphere.common.ssl_helper import get_unverified_session
from vmware.vapi.core import ApplicationContext
from vmware.vapi.lib.constants import SHOW_UNRELEASED_APIS
from vmware.vapi.lib.connect import get_connector, get_requests_connector
from vmware.vapi.stdlib.client.factories import StubConfigurationFactory
from vmware.vapi.security.client.security_context_filter import \
LegacySecurityContextFilter, ApiProviderFilter
from vmware.vapi.security.user_password import \
create_user_password_security_context
class SampleConverge(object):
"""
Sample demonstrating vCenter External to Embedded Convergence operation
Sample Prerequisites:
vCenter on linux platform with external Platform Services Controller
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
parser.add_argument(
'-a', '--sso_admin_username', action='store', required=True,
default='Sample_PSC_username',
help='Platform Services Controller admin username')
parser.add_argument(
'-w', '--sso_admin_password', action='store', required=True,
default='Sample_PSC_Admin_Password',
help='Platform Services Controller admin password')
args = sample_util.process_cli_args(parser.parse_args())
self.username = args.username
self.password = args.password
self.sso_admin_username = args.sso_admin_username
self.sso_admin_password = args.sso_admin_password
self.server = args.server
self.skipverification = args.skipverification
def run(self):
"""
Converges the external PSC into the Management Node without shutting
down the Platform Services Controller.
"""
session = get_unverified_session() if self.skipverification else None
sec_ctx = create_user_password_security_context(
self.username, self.password)
# TODO The following line to be deleted when API is changed to
# @Release type. As of now this is only for testing
app_ctx = ApplicationContext({SHOW_UNRELEASED_APIS: "True"})
connector = get_requests_connector(
session=session,
msg_protocol='json',
url='https://{0}:5480/api'.format(self.server),
provider_filter_chain=[
LegacySecurityContextFilter(
security_context=sec_ctx)])
connector.set_application_context(app_ctx)
stub_config = StubConfigurationFactory.new_std_configuration(connector)
deployment_type = DeploymentType(stub_config)
"""
Running convergence task precheck.
Remove the line ", only_precheck = True" to perform convergence.
"""
convergence_task = deployment_type.convert_to_vcsa_embedded_task(
DeploymentType.ConvergenceSpec(DeploymentType.PscInfo(
sso_admin_username=self.sso_admin_username,
sso_admin_password=self.sso_admin_password),
only_precheck=True))
print('Converge operation started with task ID: \n{0}'.format(
convergence_task.get_task_id()))
def main():
"""
Entry point for the sample client
"""
converge = SampleConverge()
converge.run()
if __name__ == '__main__':
main()

View File

@ -1,110 +0,0 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
import requests
from com.vmware.vcenter.topology_client import Pscs
from samples.vsphere.common import sample_cli, sample_util
from samples.vsphere.common.ssl_helper import get_unverified_session
from vmware.vapi.lib.connect import get_connector, get_requests_connector
from vmware.vapi.stdlib.client.factories import StubConfigurationFactory
from vmware.vapi.security.user_password import \
create_user_password_security_context
from vmware.vapi.core import ApplicationContext
from vmware.vapi.lib.constants import SHOW_UNRELEASED_APIS
class SampleDecommission(object):
"""
Demonstrates Decommission operation for external PSC
Sample Prerequisites:
Embedded vCenter on linux platform with replication to Platform Services
Controller to be decommissioned
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
parser.add_argument(
'-psc_h', '--psc_host_name', action='store',
default='Sample_PSC_hostname',
help='Platform Services Controller FQDN / IP as per configuration')
parser.add_argument(
'-a', '--sso_admin_username', action='store',
default='Sample_PSC_username',
help='Platform Services Controller admin username')
parser.add_argument(
'-w', '--sso_admin_password', action='store',
default='Sample_PSC_Admin_Password',
help='Platform Services Controller admin password')
args = sample_util.process_cli_args(parser.parse_args())
self.psc_hostname = args.psc_host_name
self.username = args.username
self.password = args.password
self.sso_admin_username = args.sso_admin_username
self.sso_admin_password = args.sso_admin_password
self.server = args.server
self.skipverification = args.skipverification
def run(self):
"""
Decommissions a PSC node from a Management Node
"""
session = get_unverified_session() if self.skipverification else None
sec_ctx = create_user_password_security_context(
self.username, self.password)
# TODO The following line to be deleted when API is changed to
# @Release type. As of now this is only for testing
app_ctx = ApplicationContext({SHOW_UNRELEASED_APIS: "True"})
connector = get_requests_connector(
session=session,
msg_protocol='json',
url='https://{0}:5480/api'.format(self.server))
connector.set_security_context(sec_ctx)
connector.set_application_context(app_ctx)
stub_config = StubConfigurationFactory.new_std_configuration(connector)
pscs_obj = Pscs(stub_config)
"""
Running decommission task precheck.
Remove the line ", only_precheck = True" to perform decommission.
"""
decommission_task = pscs_obj.decommission_task(
self.psc_hostname,
Pscs.DecommissionSpec(
sso_admin_username=self.sso_admin_username,
sso_admin_password=self.sso_admin_password),
only_precheck=True)
print(
'Decommission operation started with task ID: \n%s',
decommission_task.get_task_id())
def main():
"""
Entry point for the sample client
"""
decommision_obj = SampleDecommission()
decommision_obj.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,66 @@
This directory contains samples for the Discovery and Plan APIs. Discovery and Plan is a new feature for the VCSA. VMware Discovery and Plan solution consists of vSphere, vSAN, esx, drivers frimware, 2nd party products (NSX, VRA, ETC) and 3rd party products. Though it's a tightly integrated software stack, it's complex process to patch software for Clusters, including ESXi hosts and vCenter.
For more information, please review the official release notes.
Discovery and Plan having the followings APIs:
* Discovery: Provides the user options to choose from, to add VMware products manually
* Report: To download the report generated by the interop, precheck, etc operations.
* Update client: Listing all available updates and upgrades for the products installed in the user( at the Moment we only do it for ESX and vCenter). Later on the user can select one of the patches available and can plan an actual patch or upgrade for the selected version.
Overview of the directory code samples:
* discovery_sample.py - running a simple workflow to discover the products . It's having below APIs.
GET https://{server}/lcm/rest/vcenter/lcm/discovery/product-catalog
GET https://{server}/lcm/rest/vcenter/lcm/discovery/associated-products
POST https://{server}/lcm/rest/vcenter/lcm/discovery/associated-products. Create spec as below.
CreateSpec {
/**
* The name of the product.
*/
String productName;
/**
* Current product version.
*/
String version;
/**
* The list of hostname/IPs of the instances of the VMware products
* deployed in the customer environment.
*/
Optional<List<String>> deployments;
}
GET https://{server}/lcm/rest/vcenter/lcm/discovery/associated-products/{product-id}
PATCH https://{server}/lcm/rest/vcenter/lcm/discovery/associated-products/{product-id}. Update spec as below.
UpdateSpec {
/**
* The list of hostname/IPs of the instances of the VMware products
* deployed in the customer environment.
*/
Optional<List<String>> deployments;
}
DELETE https://{server}/lcm/rest/vcenter/lcm/discovery/associated-products/{product-id}
* lcm_sample.py - running a simple workflow to download report.
GET https://{server}/lcm/rest/vcenter/lcm/reports/{report}
* update_sample.py - running a simple workflow to find updates and upgrades
GET https://{server}/lcm/rest/vcenter/lcm/update/pending
GET https://{server}/lcm/rest/vcenter/lcm/update/pending/{version}
POST https://{server}/rest/vcenter/lcm/update/pending/{version}/pre-upgrade-checks
To view the available command-line options:
$ python discovery_sample.py --help
$ python lcm_sample.py --help
$ python update_sample.py --help
Running the samples:
$ python discovery_sample.py --server <vCenter Server IP> --username <username> --password <password> --skipverification
$ python lcm_sample.py --server <vCenter Server IP> --username <username> --password <password> --skipverification
$ python update_sample.py --server <vCenter Server IP> --username <username> --password <password> --skipverification
Testbed Requirement:
* 1 vCenter Server appliance version 7.0 or above are supported.

View File

@ -0,0 +1,26 @@
"""
* *******************************************************
* Copyright VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2019 VMware, Inc. All rights reserved.'
# Required to distribute different parts of this
# package as multiple distribution
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__) # @ReservedAssignment

View File

@ -0,0 +1,84 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from com.vmware.vcenter.lcm.discovery_client import ProductCatalog, AssociatedProducts
from samples.vsphere.common import sample_cli, sample_util
from samples.vsphere.common.ssl_helper import get_unverified_session
from samples.vsphere.vcenter.hcl.utils import get_configuration
class SampleDiscovery(object):
"""
Sample demonstrating vCenter LCM Discovery APIs
Sample Prerequisites:
vCenter on linux platform
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
args = sample_util.process_cli_args(parser.parse_args())
session = get_unverified_session() if args.skipverification else None
stub_config = get_configuration(
args.server, args.username, args.password,
session)
self.product_client = ProductCatalog(stub_config)
self.associated_products_client = AssociatedProducts(stub_config)
def run(self):
"""
Access the Discovery APIs to list available products and associated products
"""
# Product Catlog
product_catlog = self.product_client.list()
print("Product Catlog list: \n", product_catlog)
# Associated Products
associated_products = self.associated_products_client.list()
print("Associated Products list : \n", associated_products)
# Add product
spec = {'product_name': 'VMware Identity Manager', 'version': '3.3', 'deployments': '3'}
add_associated_product = self.associated_products_client.create(spec)
print('Added new product. \n', add_associated_product)
associated_products = self.associated_products_client.list()
print("Associated Products after adding the product: \n", associated_products)
# Update product
update_spec = {'deployments': '9'}
update_associated_product = self.associated_products_client.update(add_associated_product, update_spec)
associated_products = self.associated_products_client.list()
print("Associated Products after updating the product: \n", associated_products)
# Delete product
delete_associated_product = self.associated_products_client.delete(add_associated_product)
associated_products = self.associated_products_client.list()
print("Associated Products after deleting the product: \n{0}", associated_products)
def main():
"""
Entry point for the sample client
"""
discovery = SampleDiscovery()
discovery.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,61 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019-2020. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from com.vmware.vcenter.lcm_client import Reports
from samples.vsphere.common import sample_cli, sample_util
from samples.vsphere.common.ssl_helper import get_unverified_session
from samples.vsphere.vcenter.hcl.utils import get_configuration
class SampleLcm(object):
"""
Sample demonstrating vCenter LCM Update APIs
Sample Prerequisites:
vCenter on linux platform
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
parser.add_argument('-f', '--file_name',
help='Provide csv report file name.')
args = sample_util.process_cli_args(parser.parse_args())
self.csv_report = args.file_name
session = get_unverified_session() if args.skipverification else None
stub_config = get_configuration(
args.server, args.username, args.password,
session)
self.report_client = Reports(stub_config)
def run(self):
"""
Access to download the interop report APIs by providing csv_report name
"""
report_details = self.report_client.get(self.csv_report)
print("Report Details - ", report_details)
def main():
"""
Entry point for the sample client
"""
lcm = SampleLcm()
lcm.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,66 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from com.vmware.vcenter.lcm.update_client import Pending, PrecheckReport
from samples.vsphere.common import sample_cli, sample_util
from samples.vsphere.common.ssl_helper import get_unverified_session
from samples.vsphere.vcenter.hcl.utils import get_configuration
class SampleUpdate(object):
"""
Sample demonstrating vCenter LCM Update APIs
Sample Prerequisites:
vCenter on linux platform
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
args = sample_util.process_cli_args(parser.parse_args())
session = get_unverified_session() if args.skipverification else None
stub_config = get_configuration(
args.server, args.username, args.password,
args.skipverification)
self.pending_client = Pending(stub_config)
self.precheck_client = PrecheckReport(stub_config)
def run(self):
"""
Access the Update APIs to list available patches and details
"""
available_updates = self.pending_client.list()
print("vCenter available updates - ", available_updates)
if available_updates.updates:
target_version = available_updates.updates[0].version
update_details = self.pending_client.get(target_version)
print("vCenter available update details - ", update_details)
# precheck API's
precheck_result = self.precheck_client.create_task(target_version)
print("Pre upgrade checks task id started with: \n{0}".format(precheck_result.get_task_id()))
def main():
"""
Entry point for the sample client
"""
update = SampleUpdate()
update.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,33 @@
This directory contains samples for the ESXi Hardware Compatibility APIs. ESXi Hardware Compatibility feature generates a hardware compatibility report for a given ESXi against a target ESXi version.
For more information, please review the official release notes.
The feature is realized with the following APIs:
* Compatibility Data Download: Updates the local compatibility data on the vCenter based on the latest version in the VMware Official repository.
* Compatibility Data Status: Provides information about when the compatibility Datastore on the vCenter was last synced with VMware Official Repository.
* Compatibility Releases : Lists the available ESXi releases for a given host that can be used to generate a compatibility report.
* Compatibility Report: Generates a compatibility report for the source host against the target version.
Overview of the directory code samples:
* compatibility_data_update_sample.py - Corresponds to Compatibiliy Data download operation as mentioned above.
* compatibility_data_status_sample.py - Corresponds to Compatibiliy Data status as mentioned above.
* compatibility_releases_sample.py - Corresponds to Compatibility Releases operation as mentioned above.
* compatibility_report_sample.py - Corresponds to Compatibility Report operation as mentioned above.
To view the available command-line options:
$ python compatibility_data_update_sample.py --help
$ python compatibility_data_status_sample.py --help
$ python compatibility_releases_sample.py --help
$ python compatibility_report_sample.py --help
Running the samples:
$ python compatibility_data_update_sample.py --server <vCenter Server IP> --username <username> --password <password> --skipverification
$ python compatibility_data_status_sample.py --server <vCenter Server IP> --username <username> --password <password> --skipverification
$ python compatibility_releases_sample.py --server <vCenter Server IP> --username <username> --password <password> --host <MOID of the host> --skipverification
$ python compatibility_report_sample.py --server <vCenter Server IP> --username <username> --password <password> --host <MOID of the host> --release <Target ESXi release> --skipverification
Testbed Requirement:
* 1 vCenter Server appliance version 7.0 or above are supported.

View File

@ -0,0 +1,25 @@
"""
* *******************************************************
* Copyright VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
# Required to distribute different parts of this
# package as multiple distribution
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__) # @ReservedAssignment

View File

@ -0,0 +1,58 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from com.vmware.esx.hcl_client import CompatibilityData
from samples.vsphere.vcenter.hcl.utils import get_configuration
from samples.vsphere.common import sample_cli, sample_util
class CompatibilityDataStatusSample(object):
"""
Sample demonstrating vCenter HCL Compatibility Data Status Check Operation
Sample Prerequisites:
vCenter on linux platform
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
args = sample_util.process_cli_args(parser.parse_args())
config = get_configuration(args.server, args.username,
args.password,
args.skipverification)
self.api_client = CompatibilityData(config)
def run(self):
"""
Invokes the HCL Compatibility Data Status GET API to get information
about when the compatibility data was last updated
"""
data_status_info = self.api_client.get()
print("Compatibility Data Status : ", data_status_info)
def main():
"""
Entry point for the CompatibilityDataStatusSample client
"""
dataStatusSample = CompatibilityDataStatusSample()
dataStatusSample.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,56 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from com.vmware.esx.hcl_client import CompatibilityData
from samples.vsphere.vcenter.hcl.utils import get_configuration
from samples.vsphere.common import sample_cli, sample_util
class CompatibilityDataUpdateSample(object):
"""
Sample demonstrating vCenter HCL Compatibility Data Update Operation
Sample Prerequisites:
vCenter on linux platform
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
args = sample_util.process_cli_args(parser.parse_args())
config = get_configuration(args.server, args.username,
args.password,
args.skipverification)
self.api_client = CompatibilityData(config)
def run(self):
"""
Calls the HCL Compatibility Data Update POST API to update the HCL Datastore on the vCenter
"""
data_update_info = self.api_client.update_task()
print("Compatibility Data Update Task ID : ", data_update_info.get_task_id())
def main():
"""
Entry point for the CompatibilityDataUpdateSample client
"""
dataUpdateSample = CompatibilityDataUpdateSample()
dataUpdateSample.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,61 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from com.vmware.esx.hcl.hosts_client import CompatibilityReleases
from samples.vsphere.vcenter.hcl.utils import get_configuration
from samples.vsphere.common import sample_cli, sample_util
class CompatibilityReleasesSample(object):
"""
Sample demonstrating vCenter HCL Get Compatibility Releases Operation
Sample Prerequisites:
vCenter on linux platform
The vCenter should have HCL DataStore(Compatibility Data) Populated
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
parser.add_argument('-id', '--host',
required=True,
help='MOID of the source host for eg "host-13"')
args = sample_util.process_cli_args(parser.parse_args())
self.host_id = args.host
config = get_configuration(args.server, args.username,
args.password,
args.skipverification)
self.api_client = CompatibilityReleases(config)
def run(self):
"""
Invokes the HCL Compatibility Releases GET API to get list of available releases for the source ESXi host
"""
releases_info = self.api_client.list(self.host_id)
print("Compatibility Releases Info : ", releases_info)
def main():
"""
Entry point for the CompatibilityReleasesSample client
"""
releasesSample = CompatibilityReleasesSample()
releasesSample.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,66 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from com.vmware.esx.hcl.hosts_client import CompatibilityReport
from samples.vsphere.vcenter.hcl.utils import get_configuration
from samples.vsphere.common import sample_cli, sample_util
class CompatibilityReportSample(object):
"""
Sample demonstrating vCenter HCL Get Compatibility Report Operation
Sample Prerequisites:
vCenter on linux platform
The vCenter should have HCL DataStore(Compatibility Data) Populated
"""
def __init__(self):
parser = sample_cli.build_arg_parser()
parser.add_argument('-id', '--host',
required=True,
help='MOID of the source host for eg "host-13"')
parser.add_argument('-r', '--release',
required=True,
help='Target Release against which you want to generate the report for eg "ESXi 6.7"')
args = sample_util.process_cli_args(parser.parse_args())
self.host_id = args.host
self.targetRelease = args.release
config = get_configuration(args.server, args.username,
args.password,
args.skipverification)
self.api_client = CompatibilityReport(config)
def run(self):
"""
Access the HCL Compatibility Report GET API to get the task id
"""
report_info = self.api_client.create_task(self.host_id,
CompatibilityReport.Spec(self.targetRelease))
print("Compatibility Report API Task ID : ", report_info.get_task_id())
def main():
"""
Entry point for the CompatibilityReportSample client
"""
reportSample = CompatibilityReportSample()
reportSample.run()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,59 @@
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
import requests
from com.vmware.cis_client import Session
from samples.vsphere.common.ssl_helper import get_unverified_session
from vmware.vapi.security.session import create_session_security_context
from vmware.vapi.lib.connect import get_requests_connector
from vmware.vapi.stdlib.client.factories import StubConfigurationFactory
from vmware.vapi.security.client.security_context_filter import \
LegacySecurityContextFilter
from vmware.vapi.security.user_password import \
create_user_password_security_context
"""
Creates a session and returns the stub configuration
"""
def get_configuration(server, username, password, skipVerification):
session = get_unverified_session() if skipVerification else None
if not session:
session = requests.Session()
host_url = "https://{}/api".format(server)
sec_ctx = create_user_password_security_context(username,
password)
session_svc = Session(
StubConfigurationFactory.new_std_configuration(
get_requests_connector(
session=session, url=host_url,
provider_filter_chain=[
LegacySecurityContextFilter(
security_context=sec_ctx)])))
session_id = session_svc.create()
print("Session ID : ", session_id)
sec_ctx = create_session_security_context(session_id)
stub_config = StubConfigurationFactory.new_std_configuration(
get_requests_connector(
session=session, url=host_url,
provider_filter_chain=[
LegacySecurityContextFilter(
security_context=sec_ctx)]))
return stub_config

View File

@ -0,0 +1,20 @@
This directory contains samples for getting vCenter Server replication status and node information
The samples are compatible with vSPhere 7.0+
### vCenter server node topology information List/Get operations
Sample | Description
----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
get_node.py | Demonstrates getting the vCenter Server or Platform service controler node information.
list_nodes.py | Demonstrates listing of the vCenter Server or Platform service controller node's information in Link Mode in an SSO Domain.
list_embedded_nodes.py | Demonstrates listing of Embedded vCenter Server node's information in an SSO Domain.
### vCenter server Replication Status List operations
Sample | Description
----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------
list_replication_status.py | Demonstrates listing of replication status of all vCenter Server's in an SSO Domain.
list_node_replication_status.py | Demonstrates status of replication for a vCenter Server.
### Testbed Requirement:
- 1 vCenter Server on version 7.0+
- The username being used to run the sample should have System.Read privilege for the operation to be performed.

View File

@ -0,0 +1,49 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2020. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from vmware.vapi.vsphere.client import create_vsphere_client
from samples.vsphere.common import (sample_cli, sample_util)
from samples.vsphere.common.ssl_helper import get_unverified_session
"""
Description: Demonstrates getting the vCenter Server or Platform service
controler node information.
Sample Prerequisites:
- The user invoking the API should have the System.Read privilege.
"""
parser = sample_cli.build_arg_parser()
parser.add_argument('--node',
required=True,
help='Identifier of the vCenter or Platform Services'
' Controller node. Identifier should be DNS'
' resolvable name of the node')
args = sample_util.process_cli_args(parser.parse_args())
session = get_unverified_session() if args.skipverification else None
# Login to vCenter
vsphere_client = create_vsphere_client(server=args.server,
username=args.username,
password=args.password,
session=session)
print(vsphere_client.vcenter.topology.Nodes.get(args.node))

View File

@ -0,0 +1,47 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2020. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from vmware.vapi.vsphere.client import create_vsphere_client
from com.vmware.vcenter.topology_client import Nodes
from samples.vsphere.common import (sample_cli, sample_util)
from samples.vsphere.common.ssl_helper import get_unverified_session
"""
Description: Demonstrates listing of Embedded vCenter Server node's information
in an SSO Domain.
Sample Prerequisites:
- The user invoking the API should have the System.Read privilege.
"""
parser = sample_cli.build_arg_parser()
args = sample_util.process_cli_args(parser.parse_args())
session = get_unverified_session() if args.skipverification else None
# Login to vCenter
vsphere_client = create_vsphere_client(server=args.server,
username=args.username,
password=args.password,
session=session)
filter_spec = Nodes.FilterSpec({Nodes.ApplianceType.VCSA_EMBEDDED})
print(vsphere_client.vcenter.topology.Nodes.list(filter_spec))

View File

@ -0,0 +1,52 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2020. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from vmware.vapi.vsphere.client import create_vsphere_client
from com.vmware.vcenter.topology_client import ReplicationStatus
from samples.vsphere.common import (sample_cli, sample_util)
from samples.vsphere.common.ssl_helper import get_unverified_session
"""
Description: Demonstrates listing of replication status for a vCenter Server.
Sample Prerequisites:
- The user invoking the API should have the System.Read privilege.
"""
parser = sample_cli.build_arg_parser()
parser.add_argument('--node',
required=True,
help='Identifier of the vCenter or Platform Services'
' Controller node. Identifier should be DNS'
' resolvable name of the node')
args = sample_util.process_cli_args(parser.parse_args())
session = get_unverified_session() if args.skipverification else None
# Login to vCenter
vsphere_client = create_vsphere_client(server=args.server,
username=args.username,
password=args.password,
session=session)
filter_spec = ReplicationStatus.FilterSpec({args.node})
print(vsphere_client.vcenter.topology.ReplicationStatus.list(filter_spec))

View File

@ -0,0 +1,44 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2020. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from vmware.vapi.vsphere.client import create_vsphere_client
from samples.vsphere.common import (sample_cli, sample_util)
from samples.vsphere.common.ssl_helper import get_unverified_session
"""
Description: Demonstrates listing of the vCenter server or Platform service
controller nodes in Link Mode in an SSO Domain.
Sample Prerequisites:
- The user invoking the API should have the System.Read privilege.
"""
parser = sample_cli.build_arg_parser()
args = sample_util.process_cli_args(parser.parse_args())
session = get_unverified_session() if args.skipverification else None
# Login to vCenter
vsphere_client = create_vsphere_client(server=args.server,
username=args.username,
password=args.password,
session=session)
print(vsphere_client.vcenter.topology.Nodes.list())

View File

@ -0,0 +1,44 @@
#!/usr/bin/env python
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2020. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '7.0+'
from vmware.vapi.vsphere.client import create_vsphere_client
from samples.vsphere.common import (sample_cli, sample_util)
from samples.vsphere.common.ssl_helper import get_unverified_session
"""
Description: Demonstrates listing of the vCenter Server or Platform service
controller node's information in Link Mode in an SSO Domain.
Sample Prerequisites:
- The user invoking the API should have the System.Read privilege.
"""
parser = sample_cli.build_arg_parser()
args = sample_util.process_cli_args(parser.parse_args())
session = get_unverified_session() if args.skipverification else None
# Login to vCenter
vsphere_client = create_vsphere_client(server=args.server,
username=args.username,
password=args.password,
session=session)
print(vsphere_client.vcenter.topology.ReplicationStatus.list())

View File

@ -5,7 +5,7 @@ import os
from setuptools import setup
setup(name='vSphere Automation SDK',
version='1.24.0',
version='1.25.0',
description='VMware vSphere Automation SDK for Python',
url='https://github.com/vmware/vsphere-automation-sdk-python',
author='VMware, Inc.',
@ -15,9 +15,9 @@ setup(name='vSphere Automation SDK',
'suds ; python_version < "3"',
'suds-jurko ; python_version >= "3.0"',
'pyVmomi >= 6.7',
'vapi-runtime @ file://localhost/{}/lib/vapi-runtime/vapi_runtime-2.14.0-py2.py3-none-any.whl'.format(os.getcwd()),
'vapi-client-bindings @ file://localhost/{}/lib/vapi-client-bindings/vapi_client_bindings-3.2.0-py2.py3-none-any.whl'.format(os.getcwd()),
'vapi-common-client @ file://localhost/{}/lib/vapi-common-client/vapi_common_client-2.14.0-py2.py3-none-any.whl'.format(os.getcwd()),
'vapi-runtime @ file://localhost/{}/lib/vapi-runtime/vapi_runtime-2.15.0-py2.py3-none-any.whl'.format(os.getcwd()),
'vapi-client-bindings @ file://localhost/{}/lib/vapi-client-bindings/vapi_client_bindings-3.3.0-py2.py3-none-any.whl'.format(os.getcwd()),
'vapi-common-client @ file://localhost/{}/lib/vapi-common-client/vapi_common_client-2.15.0-py2.py3-none-any.whl'.format(os.getcwd()),
'vmc-client-bindings @ file://localhost/{}/lib/vmc-client-bindings/vmc_client_bindings-1.24.0-py2.py3-none-any.whl'.format(os.getcwd()),
'nsx-python-sdk @ file://localhost/{}/lib/nsx-python-sdk/nsx_python_sdk-2.5.1.0.1.15419398-py2.py3-none-any.whl'.format(os.getcwd()),
'nsx-policy-python-sdk @ file://localhost/{}/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-2.5.1.0.1.15419398-py2.py3-none-any.whl'.format(os.getcwd()),