diff --git a/README.md b/README.md index 675e5b29..6957c62f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The samples have been developed to work with python 3.8+ ## Supported OnPrem vCenter Releases vCenter 6.5, 6.7, 7.0, 7.0U1, 7.0U2 and 7.0U2 mp1, 7.0U3, 7.0.3.2 -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. +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 - 4.0 and VMC 1.7 - 1.20 @@ -34,15 +34,13 @@ VMC M20 (1.20) ([Release Notes](https://docs.vmware.com/en/VMware-Cloud-on-AWS/0 ### Prepare a Python Development Environment -We recommend you to install latest [Python](http://docs.python-guide.org/en/latest/starting/installation/) and -[pip](https://pypi.python.org/pypi/pip/) on your system. +We recommend you to install latest [Python](http://docs.python-guide.org/en/latest/starting/installation/) and [pip](https://pypi.python.org/pypi/pip/) on your system. A Python virtual environment is also highly recommended. -* [Install a virtual env for Python 2](https://virtualenv.pypa.io/en/stable/) * [Install a virtual env for Python 3](https://docs.python.org/3/tutorial/venv.html) ### 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. +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 @@ -50,9 +48,13 @@ SDK package installation commands may differ depending on the environment where ##### 1. Typical Installation This is the recommended way to install the SDK. The installation is done from [PyPI](https://pypi.org/) and [Automation SDK Python Github](https://github.com/vmware/vsphere-automation-sdk-python) repositories. -Install/Update latest setuptools from PyPI +Install/Update latest pip from PyPI ```cmd -pip install --upgrade pip setuptools +pip install --upgrade pip +``` +Install/Update setuptools to version 62.0.0 +```cmd +pip install --upgrade setuptools==62.0.0 ``` Install SDK packages from Github. ```cmd @@ -256,8 +258,9 @@ $ python samples/vsphere/vcenter/vm/list_vms.py -v ### vSphere API Documentation * [VMware vSphere REST API Reference documentation](https://developer.vmware.com/docs/vsphere-automation/latest/) -* [vSphere 8.0.0.0 (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.0/) -* Previous Releases: vSphere [7.0.3.2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.2/), +* [vSphere 8.0.0.1 (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.1/) +* Previous Releases: vSphere [8.0.0.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.0/), +vSphere [7.0.3.2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.2/), [7.0 U3](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.0/) [7.0 U2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.2.0/), [7.0 U1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.1.0/), [7.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.0.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). diff --git a/lib/src/vapi-client-bindings/vapi_client_bindings-4.0.0.zip b/lib/src/vapi-client-bindings/vapi_client_bindings-4.0.0.zip new file mode 100644 index 00000000..251e6c15 Binary files /dev/null and b/lib/src/vapi-client-bindings/vapi_client_bindings-4.0.0.zip differ diff --git a/lib/src/vapi-common-client/vapi_common_client-2.37.0.zip b/lib/src/vapi-common-client/vapi_common_client-2.37.0.zip new file mode 100644 index 00000000..185c5f2d Binary files /dev/null and b/lib/src/vapi-common-client/vapi_common_client-2.37.0.zip differ diff --git a/lib/src/vapi-runtime/vapi_runtime-2.37.0.zip b/lib/src/vapi-runtime/vapi_runtime-2.37.0.zip new file mode 100644 index 00000000..7f084cc5 Binary files /dev/null and b/lib/src/vapi-runtime/vapi_runtime-2.37.0.zip differ diff --git a/lib/src/vmc-client-bindings/vmc_client_bindings-1.61.0.zip b/lib/src/vmc-client-bindings/vmc_client_bindings-1.61.0.zip index a268895b..0571daf9 100644 Binary files a/lib/src/vmc-client-bindings/vmc_client_bindings-1.61.0.zip and b/lib/src/vmc-client-bindings/vmc_client_bindings-1.61.0.zip differ diff --git a/lib/src/vmc-draas-client-bindings/vmc_draas_client_bindings-1.20.0.zip b/lib/src/vmc-draas-client-bindings/vmc_draas_client_bindings-1.20.0.zip index 40933a1b..99ccd074 100644 Binary files a/lib/src/vmc-draas-client-bindings/vmc_draas_client_bindings-1.20.0.zip and b/lib/src/vmc-draas-client-bindings/vmc_draas_client_bindings-1.20.0.zip differ diff --git a/lib/vapi-client-bindings/index.html b/lib/vapi-client-bindings/index.html index c515a109..71f19693 100644 --- a/lib/vapi-client-bindings/index.html +++ b/lib/vapi-client-bindings/index.html @@ -1 +1 @@ -vapi_client_bindings-3.9.0-py2.py3-none-any.whl
\ No newline at end of file +vapi_client_bindings-4.0.0-py2.py3-none-any.whl
\ No newline at end of file diff --git a/lib/vapi-client-bindings/vapi_client_bindings-3.9.0-py2.py3-none-any.whl b/lib/vapi-client-bindings/vapi_client_bindings-3.9.0-py2.py3-none-any.whl deleted file mode 100644 index f8dfed93..00000000 Binary files a/lib/vapi-client-bindings/vapi_client_bindings-3.9.0-py2.py3-none-any.whl and /dev/null differ diff --git a/lib/vapi-client-bindings/vapi_client_bindings-4.0.0-py2.py3-none-any.whl b/lib/vapi-client-bindings/vapi_client_bindings-4.0.0-py2.py3-none-any.whl new file mode 100644 index 00000000..9ea9da93 Binary files /dev/null and b/lib/vapi-client-bindings/vapi_client_bindings-4.0.0-py2.py3-none-any.whl differ diff --git a/requirements.txt b/requirements.txt index 3555a8e1..5f45f676 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,14 @@ +###### Common requirements ###### lxml >= 4.3.0 pyVmomi >= 6.7 -vapi-client-bindings == 3.9.0 +six (>=1.12) + +requests (==2.27.1) +pyOpenSSL (==22.0.0) +cryptography (==36.0.0) +setuptools (==62.0.0) +###### SDK requirements ###### +vapi-client-bindings == 4.0.0 vmc-client-bindings nsx-python-sdk nsx-policy-python-sdk diff --git a/requirements_pypi.txt b/requirements_pypi.txt index c2d3a25d..0cc201d3 100644 --- a/requirements_pypi.txt +++ b/requirements_pypi.txt @@ -1,2 +1,9 @@ +###### This requirements file is used for local installation where access to GitHub is restricted ###### +###### Common requirements ###### lxml >= 4.3.0 pyVmomi >= 6.7 +six (>=1.12) +requests (==2.27.1) +pyOpenSSL (==22.0.0) +cryptography (==36.0.0) +setuptools (==62.0.0) diff --git a/samples/vsphere/appliances/patching/README.md b/samples/vsphere/appliances/patching/README.md new file mode 100644 index 00000000..26dae144 --- /dev/null +++ b/samples/vsphere/appliances/patching/README.md @@ -0,0 +1,32 @@ +This Directory contains samples for Patching API - applmgmt APIs +For more information, please review the official release notes. + +Applmgmt having the followings APIs: + * Pending: Performs patching for pending updates + * Update: Status of update operation + +Overview of the directory code samples: + + * update_sample.py - running a simple workflow to update the vc/component . It's having below APIs. + GET https://{server}/rest/appliance/update/pending + GET https://{server}/rest/appliance/update/pending/{{update_id}}/components + GET https://{server}/rest/appliance/update/pending/{{update_id}}?component={component} + POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=precheck + POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=validate + POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=stage + POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=install + + +To view the available command-line options: + + $ python update_sample.py --help + +Running the samples: + + $ python update_sample.py --server --username --password --url --component --skipverification + + +Testbed Requirement: + + * vCenter Server appliance version 8.0 or above are supported for component update. + * vCenter Server appliance version 6.7 or above are supported for full patch. \ No newline at end of file diff --git a/samples/vsphere/appliances/patching/__init__.py b/samples/vsphere/appliances/patching/__init__.py new file mode 100644 index 00000000..7fb2b3c8 --- /dev/null +++ b/samples/vsphere/appliances/patching/__init__.py @@ -0,0 +1,26 @@ +""" +* ******************************************************* +* Copyright VMware, Inc. 2022. 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 2022 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 diff --git a/samples/vsphere/appliances/patching/update_sample.py b/samples/vsphere/appliances/patching/update_sample.py new file mode 100644 index 00000000..6da6dc86 --- /dev/null +++ b/samples/vsphere/appliances/patching/update_sample.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python +""" +* ******************************************************* +* Copyright (c) VMware, Inc. 2022. 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__ = '8.0' + +from com.vmware.appliance.update_client import Pending, Staged +from com.vmware.appliance_client import Update + +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 +import time + + +class SampleUpdate(object): + """ + Sample demonstrating Patching APIs + Sample Prerequisites: + vCenter on linux platform + """ + + def __init__(self): + parser = sample_cli.build_arg_parser() + parser.add_argument('-com', '--component', + action='store', + required=False, + help='Component to be updated.') + + parser.add_argument('-url', '--url', + action='store', + required=False, + help='Custom target url.') + args = sample_util.process_cli_args(parser.parse_args()) + # cis session + session = get_unverified_session() if args.skipverification else None + stub_config = get_configuration( + args.server, args.username, args.password, + session) + self.url = args.url if args.url else None + self.component = args.component if args.component else None + self.pending_client = Pending(stub_config) + self.staged_client = Staged(stub_config) + self.appliance_client = Update(stub_config) + self.password = args.password + + def run(self): + """ + Access the Pending APIs to list and do a pending update + """ + + version_list = self.pending_client.list("LOCAL_AND_ONLINE", self.url) + print("\nFull patch update list: \n", version_list) + version = version_list[0].version + + # Upgradeable Component List + if self.component: + component_list = self.pending_client.list_upgradeable_components(version) + # component = component_list[0]["component"] + print("\nUpgradeable Component list: \n", component_list) + + # get Update info + update_info = self.pending_client.get(version, self.component) + print("\nGet Information of Update: ") + ServicesToBeStopped = [x.service for x in update_info.services_will_be_stopped] + print("name: ", update_info.name) + print("services_will_be_stopped: ", ServicesToBeStopped) + print("staged: ", update_info.staged) + print("knowledge_base: ", update_info.knowledge_base) + print("priority: ", update_info.priority) + print("severity: ", update_info.severity) + print("update_type: ", update_info.update_type) + print("release_date: ", update_info.release_date) + print("reboot_required: ", update_info.reboot_required) + print("size: ", update_info.size) + + user_data = {"vmdir.password": self.password} + # Precheck Update + precheck_result = self.pending_client.precheck(version, self.component) + print("\nPrecheck result : \n", precheck_result) + for question in precheck_result.questions: + print("Please provide answer to following question") + print(question.text.default_message) + print("Question Description : ", question.description.default_message) + print("Provide your answer: ") + ans = str(input()) + user_data[question.data_item] = ans + + # Validate an Update + validate_result = self.pending_client.validate(version, user_data, self.component) + print("\nValidate result for update: \n", validate_result) + + # Stage an Update + + self.pending_client.stage(version, self.component) + print("Staging the update") + + # Monitor Stage + monitor_stage = self.appliance_client.get() + while monitor_stage.task.status == "RUNNING": + time.sleep(50) + monitor_stage = self.appliance_client.get() + + print("State: ", monitor_stage.state) + print("Status: ", monitor_stage.task.status) + if monitor_stage.task.status == "FAILED": + print("") + return + print("\nStage result: \n", monitor_stage) + + staged_result = self.staged_client.get() + print("\nStaged Update: ", staged_result) + + # Install an update + self.pending_client.install(version, user_data, self.component) + + # Monitor Install + print("Installing the update") + monitor_install = self.appliance_client.get() + while monitor_install.task.status == "RUNNING": + monitor_install = self.appliance_client.get() + print("\nInstall result: \n", monitor_install) + + +def main(): + """ + Entry point for the sample client + """ + pending_update = SampleUpdate() + pending_update.run() + + +if __name__ == '__main__': + main() diff --git a/samples/vsphere/vcenter/vlcm/README.md b/samples/vsphere/vcenter/vlcm/README.md new file mode 100644 index 00000000..487f9b80 --- /dev/null +++ b/samples/vsphere/vcenter/vlcm/README.md @@ -0,0 +1,4 @@ +This directory organizes the different types of available sample vLCM APIs. + +1. Hardware Compatibilty Details Operations: + * Get the cluster hardware compatibility details - cluster/hcl/hw_compatibility_details_sample.py diff --git a/samples/vsphere/vcenter/vlcm/__init__.py b/samples/vsphere/vcenter/vlcm/__init__.py new file mode 100644 index 00000000..f0ba1ee0 --- /dev/null +++ b/samples/vsphere/vcenter/vlcm/__init__.py @@ -0,0 +1,25 @@ +""" +* ******************************************************* +* Copyright VMware, Inc. 2022. 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 2022 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 diff --git a/samples/vsphere/vcenter/vlcm/cluster/README.md b/samples/vsphere/vcenter/vlcm/cluster/README.md new file mode 100644 index 00000000..e8d9aa8f --- /dev/null +++ b/samples/vsphere/vcenter/vlcm/cluster/README.md @@ -0,0 +1 @@ +This directory organizes the different types of cluster level sample vLCM APIs. diff --git a/samples/vsphere/vcenter/vlcm/cluster/__init__.py b/samples/vsphere/vcenter/vlcm/cluster/__init__.py new file mode 100644 index 00000000..f0ba1ee0 --- /dev/null +++ b/samples/vsphere/vcenter/vlcm/cluster/__init__.py @@ -0,0 +1,25 @@ +""" +* ******************************************************* +* Copyright VMware, Inc. 2022. 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 2022 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 diff --git a/samples/vsphere/vcenter/vlcm/cluster/hcl/README.md b/samples/vsphere/vcenter/vlcm/cluster/hcl/README.md new file mode 100644 index 00000000..4ea09a51 --- /dev/null +++ b/samples/vsphere/vcenter/vlcm/cluster/hcl/README.md @@ -0,0 +1,26 @@ +#vLCM/Cluster/HCL + +This directory contains samples of cluster level vLCM HCL APIs. + +The hardware compatibility service provides a way to ensure that the various driver and firmware components that are going to be installed on certain HW components (which are in use by vSAN) are certified against the ESXi version and present in the vSAN VCG. + +The Hardware Compatibility Details provides information such as the overall compliance status of the cluster, the base image version, pci device compliance, and storage device compliance. Within the more specific sections of the hardware compatibility details, one can find the corresponding supported devices. + +##Supported Features by Release: + + 7.0 : IO Controllers + 7.0 U3 : IO Controllers, Directly Attached Storage Devices, Storage Devices Configured With RAID Controller + 8.0 : IO Controllers, Directly Attached Storage Devices, Storage Devices Configured With RAID Controller, Intel VMD NVMe, RDMA NIC + +##APIs +GET Hardware Compatibility Details - Returns the HCL validation check detailed results. + +##Running the Samples: + +To view the available command-line options: + + $ python hw_compatibility_details_sample.py --help + +Run the samples: + + $ python hw_compatibility_details_sample.py --server --username --password --skipverification --cluster diff --git a/samples/vsphere/vcenter/vlcm/cluster/hcl/__init__.py b/samples/vsphere/vcenter/vlcm/cluster/hcl/__init__.py new file mode 100644 index 00000000..f0ba1ee0 --- /dev/null +++ b/samples/vsphere/vcenter/vlcm/cluster/hcl/__init__.py @@ -0,0 +1,25 @@ +""" +* ******************************************************* +* Copyright VMware, Inc. 2022. 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 2022 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 diff --git a/samples/vsphere/vcenter/vlcm/cluster/hcl/hw_compatibility_details_sample.py b/samples/vsphere/vcenter/vlcm/cluster/hcl/hw_compatibility_details_sample.py new file mode 100644 index 00000000..9b500a52 --- /dev/null +++ b/samples/vsphere/vcenter/vlcm/cluster/hcl/hw_compatibility_details_sample.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +""" +* ******************************************************* +* Copyright (c) VMware, Inc. 2022. 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.settings.clusters.software.reports.hardware_compatibility_client import Details +from samples.vsphere.vcenter.hcl.utils import get_configuration +from samples.vsphere.common import sample_util, sample_cli + + +class HWCompatibilityDetailsSample(object): + """ + Sample demonstrating vCenter HCL Get HW Compatibility Details 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', '--cluster', + required=True, + help='MOID of the source cluster for eg "domain-c92"') + args = sample_util.process_cli_args(parser.parse_args()) + self.cluster_id = args.cluster + config = get_configuration(args.server, args.username, + args.password, + args.skipverification) + + self.api_client = Details(config) + + def run(self): + """ + Access the HCL Hardware Compatibility Details GET API to get the task id + """ + report_info = self.api_client.get(self.cluster_id) + print("Hardware Compatibility Details : ", report_info) + print("Storage Device Details: ", report_info.storage_device_compliance) + print("PCI Device Details : ", report_info.pci_device_compliance) + + +def main(): + """ + Entry point for the CompatibilityReportSample client + """ + detailsSample = HWCompatibilityDetailsSample() + detailsSample.run() + + +if __name__ == '__main__': + main() diff --git a/samples/vsphere/vcenter/wcp/README.md b/samples/vsphere/vcenter/wcp/README.md new file mode 100644 index 00000000..eb379ac8 --- /dev/null +++ b/samples/vsphere/vcenter/wcp/README.md @@ -0,0 +1,11 @@ +This directory contains samples for WCP service APIs: + + * Enable supervisor on zones + * Get/List of supervisor's summary + +Running the samples + + $ python /.py --server --username --password + +* Testbed Requirement: + - 1 vCenter Server >= 8.0.0+ diff --git a/samples/vsphere/vcenter/wcp/enable_on_zones.py b/samples/vsphere/vcenter/wcp/enable_on_zones.py new file mode 100644 index 00000000..0ce79126 --- /dev/null +++ b/samples/vsphere/vcenter/wcp/enable_on_zones.py @@ -0,0 +1,193 @@ +#!/usr/bin/env python + +""" +* ******************************************************* +* Copyright (c) VMware, Inc. 2022. 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 2022 VMware, Inc. All rights reserved.' +__vcenter_version__ = '8.0.0+' + +import typing + +from com.vmware.vcenter.namespace_management_client import Supervisors +from com.vmware.vcenter.namespace_management.supervisors_client import ControlPlane, Workloads, SizingHint +from com.vmware.vcenter.namespace_management.networks_client import Network, VSphereNetwork, NetworkType +import com.vmware.vcenter.namespace_management.networks_client as net +import com.vmware.vcenter.namespace_management.networks.service_client as net_svc +from com.vmware.vcenter.namespace_management.networks.edges_client import Edge, HAProxyConfig, EdgeProvider, Server + +from samples.vsphere.common import sample_cli +from samples.vsphere.common import sample_util +from samples.vsphere.common.ssl_helper import get_unverified_session +from samples.vsphere.vcenter.hcl.utils import get_configuration + +NTP_SERVERS = ["pool.ntp.org"] + + +def dns_servers(args) -> typing.Optional[net_svc.DNS]: + dns_spec = None + servers = args.split(",") + if not servers: + dns_spec = net_svc.DNS(servers=servers, search_domains=[]) + return dns_spec + + +def create_zones_enable_spec(args) -> Supervisors.EnableOnZonesSpec: + """ + Creates an enablement spec for WCP across multiple zones using VDS for workload networking. + """ + control_plane_spec = ControlPlane( + size=SizingHint.TINY, # Tests assume this is set to TINY. It is later updated to SMALL. + login_banner='Welcome to Supervisor on vSphere Zones!', + storage_policy=args.control_plane_storage_policy, + floating_ip_address=args.control_plane_floating_ip_address, + network=Network( + network=NetworkType.VSPHERE, + vsphere=VSphereNetwork( + dvpg=args.control_plane_network_vsphere_dvpg + ), + services=net.Services( + dns=dns_servers(args.control_plane_network_services_dns_servers), + ntp=net_svc.NTP(servers=NTP_SERVERS) + ), + ) + ) + workload_spec = Workloads( + network=Network( + network=NetworkType.VSPHERE, + ip_management=net.IPManagement( + dhcp_enabled=False, + gateway_address="192.168.1.1/16", + ip_assignments=[ + net.IPAssignment( + assignee=net.IPAssignment.Assignment.SERVICE, + ranges=[net.IPRange( + address="172.24.0.0", + count=65536 + )] + ), + net.IPAssignment( + assignee=net.IPAssignment.Assignment.NODE, + ranges=[net.IPRange( + address="192.168.128.0", + count=256 + )] + ) + ] + ), + vsphere=VSphereNetwork( + dvpg=args.workloads_network_vsphere_dvpg + ), + services=net.Services( + dns=dns_servers(args.workloads_network_services_dns_servers), + ntp=net_svc.NTP(servers=NTP_SERVERS) + ), + ), + edge=Edge( + id="lb-1", + load_balancer_address_ranges=[net.IPRange( + address="192.168.0.1", + count=256 + )], + provider=EdgeProvider.HAPROXY, + haproxy=HAProxyConfig( + servers=[Server( + host=args.workloads_edge_haproxy_servers, + port=5556 + )], + username=args.workloads_edge_haproxy_username, + password=args.workloads_edge_haproxy_password, + certificate_authority_chain=args.workloads_edge_haproxy_certificate_authority_chain, + ) + ) + ) + return Supervisors.EnableOnZonesSpec( + name=args.name, + zones=args.zones, + control_plane=control_plane_spec, + workloads=workload_spec + ) + + +class EnableSupervisorsOnZones(object): + """ + Demonstrates enabling Supervisors on given zones. + """ + + def __init__(self): + parser = sample_cli.build_arg_parser() + parser.add_argument('--name', + required=True, + help='A user-friendly identifier for this Supervisor.') + parser.add_argument('--zones', + required=True, + help='List of consumption fault domain zones available for Supervisors and its workloads.') + + # control plane enable configuration + parser.add_argument('--control-plane-storage-policy', + required=True, + help='Identifies the storage policy backing the Supervisor Kubernetes API server.') + parser.add_argument('--control-plane-floating-ip-address', + required=True, + help='Floating IP address for supervisors') + parser.add_argument('--control-plane-network-vsphere-dvpg', + required=True, + help='The Managed Object ID of a vSphere Distributed Virtual Port Group for Control Plane.') + parser.add_argument('--control-plane-network-services-dns-servers', + required=True, + help='List of control plane DNS servers') + + # workloads enable configuration + parser.add_argument('--workloads-network-vsphere-dvpg', + required=True, + help='The Managed Object ID of a vSphere Distributed Virtual Switch for workloads.') + parser.add_argument('--workloads-network-services-dns-servers', + required=True, + help='List of workloads DNS servers.') + + # load balancer enable configuration + parser.add_argument('--workloads-edge-haproxy-servers', + required=True, + help='List of the addresses for the data plane API servers used to configure Virtual ' + 'Servers.') + parser.add_argument('--workloads-edge-haproxy-username', + required=True, + help='Used by the HAProxy Kubernetes Operator to program the HAProxy Controller.') + parser.add_argument('--workloads-edge-haproxy-password', + required=True, + help='Used for securing HAProxy username.') + parser.add_argument('--workloads-edge-haproxy-certificate-authority-chain', + required=True, + help='PEM-encoded CA chain which is used to verify x509 certificates received from the ' + 'server.') + + 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.supervisor_enable_on_zones = Supervisors(stub_config) + self.spec = create_zones_enable_spec(args) + + def run(self): + supervisor_id = self.supervisor_enable_on_zones.enable_on_zones(self.spec) + print('supervisor_id: {0}'.format(supervisor_id)) + + +def main(): + list_cl = EnableSupervisorsOnZones() + list_cl.run() + + +if __name__ == '__main__': + main() diff --git a/samples/vsphere/vcenter/wcp/get_supervisor_summary.py b/samples/vsphere/vcenter/wcp/get_supervisor_summary.py new file mode 100644 index 00000000..4f5d8a4f --- /dev/null +++ b/samples/vsphere/vcenter/wcp/get_supervisor_summary.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +""" +* ******************************************************* +* Copyright (c) VMware, Inc. 2022. 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 2022 VMware, Inc. All rights reserved.' +__vcenter_version__ = '8.0.0+' + +from com.vmware.vcenter.namespace_management.supervisors_client import Summary +from samples.vsphere.common import sample_cli +from samples.vsphere.common import sample_util +from samples.vsphere.common.ssl_helper import get_unverified_session +from samples.vsphere.vcenter.hcl.utils import get_configuration + + +class GetSupervisorsSummary(object): + """ + Demonstrates looking up a Supervisor Summary on a given Supervisor Cluster. + """ + + def __init__(self): + parser = sample_cli.build_arg_parser() + parser.add_argument('--supervisor', + required=True, + help='The MoID of the Supervisor to query.') + + 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.supervisor_summary = Summary(stub_config) + self.supervisor = args.supervisor + + def run(self): + """ + Get Supervisor Summary on vCenter Server. + """ + summary = self.supervisor_summary.get(self.supervisor) + print('name: {0}'.format(summary.name)) + print('config_status: {0}'.format(summary.config_status)) + print('kubernetes_status: {0}'.format(summary.kubernetes_status)) + print('stats: {0}\n'.format(summary.stats)) + + +def main(): + list_cl = GetSupervisorsSummary() + list_cl.run() + + +if __name__ == '__main__': + main() diff --git a/samples/vsphere/vcenter/wcp/list_supervisor_summary.py b/samples/vsphere/vcenter/wcp/list_supervisor_summary.py new file mode 100644 index 00000000..adfa7779 --- /dev/null +++ b/samples/vsphere/vcenter/wcp/list_supervisor_summary.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +""" +* ******************************************************* +* Copyright (c) VMware, Inc. 2022. 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 2022 VMware, Inc. All rights reserved.' +__vcenter_version__ = '8.0.0+' + +from com.vmware.vcenter.namespace_management.supervisors_client import \ + Summary + +from samples.vsphere.common import sample_cli +from samples.vsphere.common import sample_util +from samples.vsphere.common.ssl_helper import get_unverified_session +from samples.vsphere.vcenter.hcl.utils import get_configuration + + +class ListClusterSupervisorServices(object): + """ + Demonstrates looking up a list of Supervisor Summary. + """ + 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.supervisor_summary = Summary(stub_config) + + def run(self): + """ + List Supervisor Summary on vCenter Server. + """ + summaries = self.supervisor_summary.list() + print('items:') + for s in summaries.items: + print('- supervisor: {0}'.format(s.supervisor)) + print(' info:') + print(' name: {0}'.format(s.info.name)) + print(' config_status: {0}'.format(s.info.config_status)) + print(' kubernetes_status: {0}'.format(s.info.kubernetes_status)) + print(' stats: {0}\n'.format(s.info.stats)) + + +def main(): + list_cl = ListClusterSupervisorServices() + list_cl.run() + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 70784899..7ee44780 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import os from setuptools import setup setup(name='vSphere Automation SDK', - version='1.79.0', + version='1.80.0', description='VMware vSphere Automation SDK for Python', url='https://github.com/vmware/vsphere-automation-sdk-python', author='VMware, Inc.', @@ -15,7 +15,7 @@ setup(name='vSphere Automation SDK', 'lxml >= 4.3.0', 'pyVmomi >= 6.7', 'vapi-runtime @ file://localhost/{}/lib/vapi-runtime/vapi_runtime-2.37.0-py2.py3-none-any.whl'.format(os.getcwd()), - 'vapi-client-bindings @ file://localhost/{}/lib/vapi-client-bindings/vapi_client_bindings-3.9.0-py2.py3-none-any.whl'.format(os.getcwd()), + 'vapi-client-bindings @ file://localhost/{}/lib/vapi-client-bindings/vapi_client_bindings-4.0.0-py2.py3-none-any.whl'.format(os.getcwd()), 'vapi-common-client @ file://localhost/{}/lib/vapi-common-client/vapi_common_client-2.37.0-py2.py3-none-any.whl'.format(os.getcwd()), 'vmc-client-bindings @ file://localhost/{}/lib/vmc-client-bindings/vmc_client_bindings-1.61.0-py2.py3-none-any.whl'.format(os.getcwd()), 'nsx-python-sdk @ file://localhost/{}/lib/nsx-python-sdk/nsx_python_sdk-4.0.1.0.0-py2.py3-none-any.whl'.format(os.getcwd()),