Skip to content

Commit 635750b

Browse files
committed
Added samples for 8.0 GA
Signed-off-by: Ankit Agrawal <[email protected]>
1 parent d92fea8 commit 635750b

16 files changed

+713
-3
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ SDK package installation commands may differ depending on the environment where
5050
##### 1. Typical Installation
5151
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.
5252

53-
Install/Update latest setuptools from PyPI
53+
Install/Update latest pip from PyPI
5454
```cmd
55-
pip install --upgrade pip setuptools
55+
pip install --upgrade pip
56+
```
57+
Install/Update setuptools to version 62.0.0 for python version > 3.6
58+
```cmd
59+
pip install --upgrade setuptools==62.0.0
60+
```
61+
for older python versions Install/Update setuptools to version 36.2.0
62+
```cmd
63+
pip install --upgrade setuptools==36.2.0
5664
```
5765
Install SDK packages from Github.
5866
```cmd

requirements_pypi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
###### This requirements file is used for local installation, where access to GitHub is restricted ######
1+
###### This requirements file is used for local installation where access to GitHub is restricted ######
22
###### Common requirements ######
33
lxml >= 4.3.0
44
pyVmomi >= 6.7
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>
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

0 commit comments

Comments
 (0)