Skip to content

Commit 294e4cb

Browse files
authored
Merge pull request #341 from aagrawal3/master
Bindings, sources and samples for vSphere 8.0GA
2 parents 5afd727 + 849ecd8 commit 294e4cb

26 files changed

+733
-13
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The samples have been developed to work with python 3.8+
2222

2323
## Supported OnPrem vCenter Releases
2424
vCenter 6.5, 6.7, 7.0, 7.0U1, 7.0U2 and 7.0U2 mp1, 7.0U3, 7.0.3.2
25-
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.
25+
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.
2626

2727
## Supported NSX-T Releases
2828
NSX-T 2.2 - 4.0 and VMC 1.7 - 1.20
@@ -34,25 +34,27 @@ VMC M20 (1.20) ([Release Notes](https://docs.vmware.com/en/VMware-Cloud-on-AWS/0
3434

3535
### Prepare a Python Development Environment
3636

37-
We recommend you to install latest [Python](http://docs.python-guide.org/en/latest/starting/installation/) and
38-
[pip](https://pypi.python.org/pypi/pip/) on your system.
37+
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.
3938

4039
A Python virtual environment is also highly recommended.
41-
* [Install a virtual env for Python 2](https://virtualenv.pypa.io/en/stable/)
4240
* [Install a virtual env for Python 3](https://docs.python.org/3/tutorial/venv.html)
4341

4442
### Installing Required Python Packages
45-
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.
43+
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.
4644
*pip* and *setuptools* are common requirements for these installation types, upgrade to the latest *pip* and *setuptools*.
4745

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

5048
##### 1. Typical Installation
5149
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.
5250

53-
Install/Update latest setuptools from PyPI
51+
Install/Update latest pip from PyPI
5452
```cmd
55-
pip install --upgrade pip setuptools
53+
pip install --upgrade pip
54+
```
55+
Install/Update setuptools to version 62.0.0
56+
```cmd
57+
pip install --upgrade setuptools==62.0.0
5658
```
5759
Install SDK packages from Github.
5860
```cmd
@@ -256,8 +258,9 @@ $ python samples/vsphere/vcenter/vm/list_vms.py -v
256258
### vSphere API Documentation
257259

258260
* [VMware vSphere REST API Reference documentation](https://developer.vmware.com/docs/vsphere-automation/latest/)
259-
* [vSphere 8.0.0.0 (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.0/)
260-
* Previous Releases: vSphere [7.0.3.2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.2/),
261+
* [vSphere 8.0.0.1 (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.1/)
262+
* Previous Releases: vSphere [8.0.0.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.0/),
263+
vSphere [7.0.3.2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.2/),
261264
[7.0 U3](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.0/)
262265
[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).
263266

Binary file not shown.
Binary file not shown.
239 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

lib/vapi-client-bindings/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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 />
1+
<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.

requirements.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
###### Common requirements ######
12
lxml >= 4.3.0
23
pyVmomi >= 6.7
3-
vapi-client-bindings == 3.9.0
4+
six (>=1.12)
5+
6+
requests (==2.27.1)
7+
pyOpenSSL (==22.0.0)
8+
cryptography (==36.0.0)
9+
setuptools (==62.0.0)
10+
###### SDK requirements ######
11+
vapi-client-bindings == 4.0.0
412
vmc-client-bindings
513
nsx-python-sdk
614
nsx-policy-python-sdk

requirements_pypi.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
###### This requirements file is used for local installation where access to GitHub is restricted ######
2+
###### Common requirements ######
13
lxml >= 4.3.0
24
pyVmomi >= 6.7
5+
six (>=1.12)
6+
requests (==2.27.1)
7+
pyOpenSSL (==22.0.0)
8+
cryptography (==36.0.0)
9+
setuptools (==62.0.0)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
This Directory contains samples for Patching API - applmgmt APIs
2+
For more information, please review the official release notes.
3+
4+
Applmgmt having the followings APIs:
5+
* Pending: Performs patching for pending updates
6+
* Update: Status of update operation
7+
8+
Overview of the directory code samples:
9+
10+
* update_sample.py - running a simple workflow to update the vc/component . It's having below APIs.
11+
GET https://{server}/rest/appliance/update/pending
12+
GET https://{server}/rest/appliance/update/pending/{{update_id}}/components
13+
GET https://{server}/rest/appliance/update/pending/{{update_id}}?component={component}
14+
POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=precheck
15+
POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=validate
16+
POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=stage
17+
POST https://{server}/rest/appliance/update/pending/{{update_id}}?action=install
18+
19+
20+
To view the available command-line options:
21+
22+
$ python update_sample.py --help
23+
24+
Running the samples:
25+
26+
$ python update_sample.py --server <vCenter Server IP> --username <username> --password <password> --url <customurl> --component <component> --skipverification
27+
28+
29+
Testbed Requirement:
30+
31+
* vCenter Server appliance version 8.0 or above are supported for component update.
32+
* vCenter Server appliance version 6.7 or above are supported for full patch.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
* *******************************************************
3+
* Copyright VMware, Inc. 2022. All Rights Reserved.
4+
* SPDX-License-Identifier: MIT
5+
* *******************************************************
6+
*
7+
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
8+
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
9+
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
10+
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
11+
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
12+
"""
13+
14+
15+
__author__ = 'VMware, Inc.'
16+
__copyright__ = 'Copyright 2022 VMware, Inc. All rights reserved.'
17+
18+
19+
# Required to distribute different parts of this
20+
# package as multiple distribution
21+
try:
22+
import pkg_resources
23+
pkg_resources.declare_namespace(__name__)
24+
except ImportError:
25+
from pkgutil import extend_path
26+
__path__ = extend_path(__path__, __name__) # @ReservedAssignment
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/usr/bin/env python
2+
"""
3+
* *******************************************************
4+
* Copyright (c) VMware, Inc. 2022. All Rights Reserved.
5+
* SPDX-License-Identifier: MIT
6+
* *******************************************************
7+
*
8+
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
9+
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
10+
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
11+
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
12+
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
13+
"""
14+
15+
__author__ = 'VMware, Inc.'
16+
__vcenter_version__ = '8.0'
17+
18+
from com.vmware.appliance.update_client import Pending, Staged
19+
from com.vmware.appliance_client import Update
20+
21+
from samples.vsphere.common import sample_cli, sample_util
22+
from samples.vsphere.common.ssl_helper import get_unverified_session
23+
from samples.vsphere.vcenter.hcl.utils import get_configuration
24+
import time
25+
26+
27+
class SampleUpdate(object):
28+
"""
29+
Sample demonstrating Patching APIs
30+
Sample Prerequisites:
31+
vCenter on linux platform
32+
"""
33+
34+
def __init__(self):
35+
parser = sample_cli.build_arg_parser()
36+
parser.add_argument('-com', '--component',
37+
action='store',
38+
required=False,
39+
help='Component to be updated.')
40+
41+
parser.add_argument('-url', '--url',
42+
action='store',
43+
required=False,
44+
help='Custom target url.')
45+
args = sample_util.process_cli_args(parser.parse_args())
46+
# cis session
47+
session = get_unverified_session() if args.skipverification else None
48+
stub_config = get_configuration(
49+
args.server, args.username, args.password,
50+
session)
51+
self.url = args.url if args.url else None
52+
self.component = args.component if args.component else None
53+
self.pending_client = Pending(stub_config)
54+
self.staged_client = Staged(stub_config)
55+
self.appliance_client = Update(stub_config)
56+
self.password = args.password
57+
58+
def run(self):
59+
"""
60+
Access the Pending APIs to list and do a pending update
61+
"""
62+
63+
version_list = self.pending_client.list("LOCAL_AND_ONLINE", self.url)
64+
print("\nFull patch update list: \n", version_list)
65+
version = version_list[0].version
66+
67+
# Upgradeable Component List
68+
if self.component:
69+
component_list = self.pending_client.list_upgradeable_components(version)
70+
# component = component_list[0]["component"]
71+
print("\nUpgradeable Component list: \n", component_list)
72+
73+
# get Update info
74+
update_info = self.pending_client.get(version, self.component)
75+
print("\nGet Information of Update: ")
76+
ServicesToBeStopped = [x.service for x in update_info.services_will_be_stopped]
77+
print("name: ", update_info.name)
78+
print("services_will_be_stopped: ", ServicesToBeStopped)
79+
print("staged: ", update_info.staged)
80+
print("knowledge_base: ", update_info.knowledge_base)
81+
print("priority: ", update_info.priority)
82+
print("severity: ", update_info.severity)
83+
print("update_type: ", update_info.update_type)
84+
print("release_date: ", update_info.release_date)
85+
print("reboot_required: ", update_info.reboot_required)
86+
print("size: ", update_info.size)
87+
88+
user_data = {"vmdir.password": self.password}
89+
# Precheck Update
90+
precheck_result = self.pending_client.precheck(version, self.component)
91+
print("\nPrecheck result : \n", precheck_result)
92+
for question in precheck_result.questions:
93+
print("Please provide answer to following question")
94+
print(question.text.default_message)
95+
print("Question Description : ", question.description.default_message)
96+
print("Provide your answer: ")
97+
ans = str(input())
98+
user_data[question.data_item] = ans
99+
100+
# Validate an Update
101+
validate_result = self.pending_client.validate(version, user_data, self.component)
102+
print("\nValidate result for update: \n", validate_result)
103+
104+
# Stage an Update
105+
106+
self.pending_client.stage(version, self.component)
107+
print("Staging the update")
108+
109+
# Monitor Stage
110+
monitor_stage = self.appliance_client.get()
111+
while monitor_stage.task.status == "RUNNING":
112+
time.sleep(50)
113+
monitor_stage = self.appliance_client.get()
114+
115+
print("State: ", monitor_stage.state)
116+
print("Status: ", monitor_stage.task.status)
117+
if monitor_stage.task.status == "FAILED":
118+
print("")
119+
return
120+
print("\nStage result: \n", monitor_stage)
121+
122+
staged_result = self.staged_client.get()
123+
print("\nStaged Update: ", staged_result)
124+
125+
# Install an update
126+
self.pending_client.install(version, user_data, self.component)
127+
128+
# Monitor Install
129+
print("Installing the update")
130+
monitor_install = self.appliance_client.get()
131+
while monitor_install.task.status == "RUNNING":
132+
monitor_install = self.appliance_client.get()
133+
print("\nInstall result: \n", monitor_install)
134+
135+
136+
def main():
137+
"""
138+
Entry point for the sample client
139+
"""
140+
pending_update = SampleUpdate()
141+
pending_update.run()
142+
143+
144+
if __name__ == '__main__':
145+
main()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This directory organizes the different types of available sample vLCM APIs.
2+
3+
1. Hardware Compatibilty Details Operations:
4+
* Get the cluster hardware compatibility details - cluster/hcl/hw_compatibility_details_sample.py
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
* *******************************************************
3+
* Copyright VMware, Inc. 2022. All Rights Reserved.
4+
* SPDX-License-Identifier: MIT
5+
* *******************************************************
6+
*
7+
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
8+
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
9+
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
10+
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
11+
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
12+
"""
13+
14+
__author__ = 'VMware, Inc.'
15+
__copyright__ = 'Copyright 2022 VMware, Inc. All rights reserved.'
16+
17+
18+
# Required to distribute different parts of this
19+
# package as multiple distribution
20+
try:
21+
import pkg_resources
22+
pkg_resources.declare_namespace(__name__)
23+
except ImportError:
24+
from pkgutil import extend_path
25+
__path__ = extend_path(__path__, __name__) # @ReservedAssignment
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory organizes the different types of cluster level sample vLCM APIs.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
* *******************************************************
3+
* Copyright VMware, Inc. 2022. All Rights Reserved.
4+
* SPDX-License-Identifier: MIT
5+
* *******************************************************
6+
*
7+
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
8+
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
9+
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
10+
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
11+
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
12+
"""
13+
14+
__author__ = 'VMware, Inc.'
15+
__copyright__ = 'Copyright 2022 VMware, Inc. All rights reserved.'
16+
17+
18+
# Required to distribute different parts of this
19+
# package as multiple distribution
20+
try:
21+
import pkg_resources
22+
pkg_resources.declare_namespace(__name__)
23+
except ImportError:
24+
from pkgutil import extend_path
25+
__path__ = extend_path(__path__, __name__) # @ReservedAssignment
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#vLCM/Cluster/HCL
2+
3+
This directory contains samples of cluster level vLCM HCL APIs.
4+
5+
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.
6+
7+
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.
8+
9+
##Supported Features by Release:
10+
11+
7.0 : IO Controllers
12+
7.0 U3 : IO Controllers, Directly Attached Storage Devices, Storage Devices Configured With RAID Controller
13+
8.0 : IO Controllers, Directly Attached Storage Devices, Storage Devices Configured With RAID Controller, Intel VMD NVMe, RDMA NIC
14+
15+
##APIs
16+
GET Hardware Compatibility Details - Returns the HCL validation check detailed results.
17+
18+
##Running the Samples:
19+
20+
To view the available command-line options:
21+
22+
$ python hw_compatibility_details_sample.py --help
23+
24+
Run the samples:
25+
26+
$ python hw_compatibility_details_sample.py --server <Vcenter Server IP> --username <username> --password <password> --skipverification --cluster <MOID of cluster>

0 commit comments

Comments
 (0)