Skip to content

Bindings, sources and samples for vSphere 8.0GA #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,25 +34,27 @@ 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

##### 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
Expand Down Expand Up @@ -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).

Expand Down
Binary file not shown.
Binary file not shown.
Binary file added lib/src/vapi-runtime/vapi_runtime-2.37.0.zip
Binary file not shown.
Binary file modified lib/src/vmc-client-bindings/vmc_client_bindings-1.61.0.zip
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/vapi-client-bindings/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<a href='vapi_client_bindings-3.9.0-py2.py3-none-any.whl'>vapi_client_bindings-3.9.0-py2.py3-none-any.whl</a><br />
<a href='vapi_client_bindings-4.0.0-py2.py3-none-any.whl'>vapi_client_bindings-4.0.0-py2.py3-none-any.whl</a><br />
Binary file not shown.
Binary file not shown.
10 changes: 9 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions requirements_pypi.txt
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 32 additions & 0 deletions samples/vsphere/appliances/patching/README.md
Original file line number Diff line number Diff line change
@@ -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 <vCenter Server IP> --username <username> --password <password> --url <customurl> --component <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.
26 changes: 26 additions & 0 deletions samples/vsphere/appliances/patching/__init__.py
Original file line number Diff line number Diff line change
@@ -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
145 changes: 145 additions & 0 deletions samples/vsphere/appliances/patching/update_sample.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions samples/vsphere/vcenter/vlcm/README.md
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions samples/vsphere/vcenter/vlcm/__init__.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions samples/vsphere/vcenter/vlcm/cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory organizes the different types of cluster level sample vLCM APIs.
25 changes: 25 additions & 0 deletions samples/vsphere/vcenter/vlcm/cluster/__init__.py
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions samples/vsphere/vcenter/vlcm/cluster/hcl/README.md
Original file line number Diff line number Diff line change
@@ -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 <Vcenter Server IP> --username <username> --password <password> --skipverification --cluster <MOID of cluster>
Loading