mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-21 17:29:59 -05:00
commit
0e0b932112
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2023 VMware, Inc.
|
||||
Copyright (c) 2016-2024 Broadcom, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
17
README.md
17
README.md
@ -3,7 +3,7 @@
|
||||
|
||||
## Table of Contents
|
||||
- [Abstract](#abstract)
|
||||
- [Supported vCenter Releases](#supported-vcenter-releases)
|
||||
- [Supported vCenter Releases](#supported-onprem-vcenter-releases)
|
||||
- [Supported NSX-T Releases](#supported-nsx-t-releases)
|
||||
- [VMware Cloud on AWS Support](#vmware-cloud-on-aws-support)
|
||||
- [Quick Start Guide](#quick-start-guide)
|
||||
@ -22,11 +22,11 @@ samples require the vSphere Management SDK packages (pyVmomi) to be installed on
|
||||
The samples have been developed to work with python 3.8+
|
||||
|
||||
## Supported OnPrem vCenter Releases
|
||||
vCenter 7.0, 7.0U1, 7.0U2, 7.0U3 , 8.0, 8.0U1, 8.0U2
|
||||
vCenter 7.0, 7.0U1, 7.0U2, 7.0U3 , 8.0, 8.0U1, 8.0U2, 8.0U3
|
||||
Please refer to the notes in each sample for detailed compatibility information.
|
||||
|
||||
## Supported NSX-T Releases
|
||||
NSX-T 2.2 - 4.1.2 and VMC 1.7 - 1.24
|
||||
NSX-T 2.2 - 4.2.0 and VMC 1.7 - 1.24
|
||||
|
||||
## Latest VMware Cloud on AWS Release:
|
||||
VMC M24 (1.24) ([Release Notes](https://docs.vmware.com/en/VMware-Cloud-on-AWS/0/rn/vmc-on-aws-relnotes.html))
|
||||
@ -264,9 +264,10 @@ $ 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 U2 Python APIs (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.2.0/)
|
||||
* Previous Releases: vSphere [8.0 U1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.1.0/)
|
||||
* [VMware vSphere REST API Reference documentation](https://developer.broadcom.com/xapis/vsphere-automation-api/latest/)
|
||||
* [vSphere 8.0 U3 Python APIs (latest)](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.3.0/)
|
||||
* Previous Releases: vSphere [8.0 U2](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.2.0/)
|
||||
[8.0 U1](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.1.0/)
|
||||
[8.0 GA](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.1/)
|
||||
[8.0.0.0](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/8.0.0.0/),
|
||||
[7.0 U3](https://vmware.github.io/vsphere-automation-sdk-python/vsphere/7.0.3.0/)
|
||||
@ -274,7 +275,7 @@ $ python samples/vsphere/vcenter/vm/list_vms.py -v
|
||||
|
||||
### VMware Cloud on AWS API Documentation
|
||||
|
||||
* [VMware Cloud on AWS REST APIs](http://developers.eng.vmware.com/docs/vmc/latest/)
|
||||
* [VMware Cloud on AWS REST APIs](https://developer.broadcom.com/xapis/vmware-cloud-on-aws-api-reference/latest/)
|
||||
* [VMware Cloud on AWS Console Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/vmc/index.html)
|
||||
* [VMware Cloud on AWS Disaster Recovery as a Service (DRaaS) Python APIs](https://vmware.github.io/vsphere-automation-sdk-python/vmc-draas/index.html)
|
||||
|
||||
@ -313,5 +314,5 @@ Members:
|
||||
* [VMware Sample Exchange](https://code.vmware.com/samples) It is highly recommended to add any and all submitted samples to the VMware Sample Exchange
|
||||
* [VMware Code](https://code.vmware.com/home)
|
||||
* [VMware Developer Community](https://communities.vmware.com/community/vmtn/developer)
|
||||
* VMware vSphere [REST API Reference documentation](https://developer.vmware.com/docs/vsphere-automation/latest/).
|
||||
* VMware vSphere [REST API Reference documentation](https://developer.broadcom.com/xapis/vsphere-automation-api/latest/).
|
||||
* [VMware Python forum](https://code.vmware.com/forums/7508/vsphere-automation-sdk-for-python)
|
||||
|
@ -4,11 +4,8 @@ For python developers, client libraries are supplied for testing and development
|
||||
|
||||
Name | Description
|
||||
------------------------------------| -------------
|
||||
vapi_runtime | vAPI runtime responsible for serialization/de-serialization of objects and wire protocol
|
||||
vcenter_bindings | Client stubs for vSphere Automation APIs
|
||||
vmwarecloud_aws | Client stubs for VMware Cloud on AWS Console APIs
|
||||
vmwarecloud_draas | Client stubs for VMware Cloud (VMC) Disaster Recovery as a Service (DRaaS) APIs
|
||||
nsx-python-sdk | Client stubs for VMware NSX-T APIs
|
||||
nsx-vmc-policy-python-sdk | Client stubs for VMware NSX-T on VMC Policy APIs
|
||||
nsx-vmc-aws-integration-python-sdk | Client stubs for VMware NSX-T AWS integration app APIs (for AWS underlay management)
|
||||
vapi-common-client | Common client code libraries
|
||||
|
@ -3,10 +3,8 @@
|
||||
<meta name='api-version' value='2'/>
|
||||
</head>
|
||||
<body>
|
||||
<a href='vcenter-bindings/'>vcenter-bindings</a><br/>
|
||||
<a href='vmwarecloud-aws/'>vmwarecloud-aws</a><br/>
|
||||
<a href='vmwarecloud-draas/'>vmwarecloud-draas</a><br/>
|
||||
<a href='vapi-runtime/'>vapi-runtime</a><br/>
|
||||
<a href='nsx-python-sdk/'>nsx-python-sdk</a><br/>
|
||||
<a href='nsx-policy-python-sdk/'>nsx-policy-python-sdk</a><br/>
|
||||
<a href='nsx-vmc-policy-python-sdk/'>nsx-vmc-policy-python-sdk</a><br/>
|
||||
|
@ -1 +1 @@
|
||||
<a href='nsx_policy_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'>nsx_policy_python_sdk-4.1.2.0.0-py2.py3-none-any.whl</a><br />
|
||||
<a href='nsx_policy_python_sdk-4.2.0-py2.py3-none-any.whl'>nsx_policy_python_sdk-4.2.0-py2.py3-none-any.whl</a><br />
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
<a href='nsx_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'>nsx_python_sdk-4.1.2.0.0-py2.py3-none-any.whl</a><br />
|
||||
<a href='nsx_python_sdk-4.2.0-py2.py3-none-any.whl'>nsx_python_sdk-4.2.0-py2.py3-none-any.whl</a><br />
|
||||
|
Binary file not shown.
BIN
lib/nsx-python-sdk/nsx_python_sdk-4.2.0-py2.py3-none-any.whl
Normal file
BIN
lib/nsx-python-sdk/nsx_python_sdk-4.2.0-py2.py3-none-any.whl
Normal file
Binary file not shown.
@ -1 +1 @@
|
||||
<a href='nsx_vmc_aws_integration_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'>nsx_vmc_aws_integration_python_sdk-4.1.2.0.0-py2.py3-none-any.whl</a><br />
|
||||
<a href='nsx_vmc_aws_integration_python_sdk-4.1.2.0.1-py2.py3-none-any.whl'>nsx_vmc_aws_integration_python_sdk-4.1.2.0.1-py2.py3-none-any.whl</a><br />
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
<a href='nsx_vmc_policy_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'>nsx_vmc_policy_python_sdk-4.1.2.0.0-py2.py3-none-any.whl</a><br />
|
||||
<a href='nsx_vmc_policy_python_sdk-4.1.2.0.1-py2.py3-none-any.whl'>nsx_vmc_policy_python_sdk-4.1.2.0.1-py2.py3-none-any.whl</a><br />
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/src/vmwarecloud-aws/vmwarecloud_aws-1.64.1.zip
Normal file
BIN
lib/src/vmwarecloud-aws/vmwarecloud_aws-1.64.1.zip
Normal file
Binary file not shown.
Binary file not shown.
BIN
lib/src/vmwarecloud-draas/vmwarecloud_draas-1.23.1.zip
Normal file
BIN
lib/src/vmwarecloud-draas/vmwarecloud_draas-1.23.1.zip
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
<a href='vmwarecloud_aws-1.64.0-py2.py3-none-any.whl'>vmwarecloud_aws-1.64.0-py2.py3-none-any.whl</a><br />
|
||||
<a href='vmwarecloud_aws-1.64.1-py2.py3-none-any.whl'>vmwarecloud_aws-1.64.1-py2.py3-none-any.whl</a><br />
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
<a href='vmwarecloud_draas-1.23.0-py2.py3-none-any.whl'>vmwarecloud_draas-1.23.0-py3.py3-none-any.whl</a><br />
|
||||
<a href='vmwarecloud_draas-1.23.1-py2.py3-none-any.whl'>vmwarecloud_draas-1.23.1-py3.py3-none-any.whl</a><br />
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,5 @@
|
||||
###### Common requirements ######
|
||||
lxml >= 4.3.0
|
||||
pyVmomi >=6.7
|
||||
six (>=1.12)
|
||||
|
||||
requests (>=2.27.1)
|
||||
@ -8,7 +7,8 @@ pyOpenSSL (>=22.0.0)
|
||||
cryptography (>=37.0.2)
|
||||
setuptools (>=62.3.2)
|
||||
###### SDK requirements ######
|
||||
vcenter-bindings == 4.2.0
|
||||
pyVmomi >=8.0.3.0.1
|
||||
vmware-vcenter == 8.0.3.0
|
||||
vmwarecloud-aws
|
||||
nsx-python-sdk
|
||||
nsx-policy-python-sdk
|
||||
|
@ -1,9 +1,13 @@
|
||||
###### 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 (>=37.0.2)
|
||||
setuptools (>=62.3.2)
|
||||
setuptools (>=62.3.2)
|
||||
###### SDK requirements ######
|
||||
pyVmomi >= 8.0.3.0.1
|
||||
vmware-vcenter == 8.0.3.0
|
||||
vmware-vapi-runtime == 2.52.0
|
||||
vmware-vapi-common-client == 2.52.0
|
37
samples/vsan/snapservice/README.md
Normal file
37
samples/vsan/snapservice/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
This directory contains samples for snapservice APIs:
|
||||
1. Protection Group Create, List and Delete operations:
|
||||
Sample | Description
|
||||
-------------------------------------|---------------------------------------------------
|
||||
list_protection_groups.py | Demonstrates listing protection groups
|
||||
create_protection_group.py | Demonstrates creating protection group
|
||||
delete_protection_groups.py | Demonstrates deleting protection groups
|
||||
|
||||
2. Protection Group Snapshot Delete operations:
|
||||
Sample | Description
|
||||
-------------------------------------|---------------------------------------------------
|
||||
delete_protection_group_snapshots.py | Demonstrates deleting protection group snapshots
|
||||
|
||||
### To view the available command-line options:
|
||||
$ python protection_group/list_protection_groups.py --help
|
||||
$ python protection_group/create_protection_group.py --help
|
||||
$ python protection_group/delete_protection_groups.py --help
|
||||
$ python snapshot/delete_protection_group_snapshots.py --help
|
||||
|
||||
### Running the samples:
|
||||
Fill "Snapservice protection group creation spec" section in vcenter/setup/testbed.py when calling create_pg.py
|
||||
|
||||
$ python protection_group/list_protection_groups.py --server <vCenter Server IP> --username <username> --password <password> --snapservice <snapservice IP> --cluster <cluster name> -v
|
||||
|
||||
$ python protection_group/create_protection_group.py --server <vCenter Server IP> --username <username> --password <password> --snapservice <snapservice IP> --cluster <cluster name> -v
|
||||
$ python protection_group/create_protection_group.py --server <vCenter Server IP> --username <username> --password <password> --snapservice <snapservice IP> --cluster <cluster name> -v -c
|
||||
|
||||
$ python protection_group/delete_protection_groups.py --server <vCenter Server IP> --username <username> --password <password> --snapservice <snapservice IP> --cluster <cluster name> --pgnames <protection groups name to delete> -v
|
||||
$ python protection_group/delete_protection_groups.py --server <vCenter Server IP> --username <username> --password <password> --snapservice <snapservice IP> --cluster <cluster name> --pgnames <protection groups name to delete> -v --force
|
||||
|
||||
$ python snapshot/delete_protection_group_snapshots.py --server <vCenter Server IP> --username <username> --password <password> --snapservice <snapservice IP> --cluster <cluster name> --pgname <protection group name to delete snapshot> --remain <snapshot remain> -v
|
||||
|
||||
### Testbed Requirement:
|
||||
- vCenter Server >= 8.0.3+
|
||||
- vSAN ESA disk
|
||||
- vSAN Cluster
|
||||
- Snapservice = 8.0.3
|
25
samples/vsan/snapservice/__init__.py
Normal file
25
samples/vsan/snapservice/__init__.py
Normal file
@ -0,0 +1,25 @@
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__copyright__ = 'Copyright (c) 2024 Broadcom. 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
|
25
samples/vsan/snapservice/protection_group/__init__.py
Normal file
25
samples/vsan/snapservice/protection_group/__init__.py
Normal file
@ -0,0 +1,25 @@
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__copyright__ = 'Copyright (c) 2024 Broadcom. 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
|
@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
import time
|
||||
|
||||
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.setup import testbed
|
||||
from samples.vsan.snapservice.vsan_snapservice_client import create_snapservice_client
|
||||
|
||||
from vmware.vapi.vsphere.client import create_vsphere_client
|
||||
from com.vmware.vcenter_client import (Cluster, VM)
|
||||
from com.vmware.snapservice_client import *
|
||||
from com.vmware.snapservice.clusters_client import *
|
||||
from com.vmware.snapservice.tasks_client import Status
|
||||
|
||||
|
||||
class CreateProtectionGroup(object):
|
||||
"""
|
||||
Description: Demonstrates creating protection group.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
parser = sample_cli.build_arg_parser()
|
||||
|
||||
required_args = parser.add_argument_group(
|
||||
'snapservice required arguments')
|
||||
required_args.add_argument('--snapservice',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Snapservice IP/hostname to connect to')
|
||||
required_args.add_argument('--cluster',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Cluster where the protection group locates')
|
||||
|
||||
args = sample_util.process_cli_args(parser.parse_args())
|
||||
self.cluster = args.cluster
|
||||
self.cleardata = args.cleardata
|
||||
|
||||
skipverification = True if args.skipverification else False
|
||||
vcSession = get_unverified_session() if skipverification else None
|
||||
self.vcClient = create_vsphere_client(server=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=vcSession)
|
||||
|
||||
ssSession = get_unverified_session() if skipverification else None
|
||||
self.ssClient = create_snapservice_client(server=args.snapservice,
|
||||
vc=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=ssSession,
|
||||
skip_verification=skipverification)
|
||||
|
||||
def run(self):
|
||||
# Get cluster identifier
|
||||
cluster_spec = set([self.cluster])
|
||||
cluster_list = self.vcClient.vcenter.Cluster.list(
|
||||
Cluster.FilterSpec(names=cluster_spec))
|
||||
|
||||
clusterId = cluster_list[0].cluster
|
||||
self.clusterId = clusterId
|
||||
print("\nGot cluster '{}' id: {}".format(self.cluster, clusterId))
|
||||
|
||||
# Get vm identifier
|
||||
vm_names = set(testbed.config["VM_NAMES"].split(","))
|
||||
vm_list = self.vcClient.vcenter.VM.list(VM.FilterSpec(names=vm_names))
|
||||
|
||||
vm_ids = []
|
||||
for vm_info in vm_list:
|
||||
vm_ids.append(vm_info.vm)
|
||||
print("\nGot VM list: {}".format(vm_ids))
|
||||
|
||||
# Get vm formats
|
||||
vm_formats = testbed.config["VM_FORMATS"].split(",")
|
||||
|
||||
# Build protection group Spec
|
||||
target_entities = TargetEntities(vm_name_patterns=vm_formats, vms=set(vm_ids))
|
||||
snapshot_policies = [SnapshotPolicy(name='policy1',
|
||||
schedule=SnapshotSchedule(
|
||||
TimeUnit(testbed.config["SCHEDULE_UNIT"]),
|
||||
testbed.config["SCHEDULE"]),
|
||||
retention=RetentionPeriod(
|
||||
TimeUnit(testbed.config["RETENTION_UNIT"]),
|
||||
testbed.config["RETENTION"]))]
|
||||
locked = testbed.config["LOCK"]
|
||||
|
||||
spec = ProtectionGroupSpec(name=testbed.config["PG_NAME"],
|
||||
target_entities=target_entities,
|
||||
snapshot_policies=snapshot_policies,
|
||||
locked=locked)
|
||||
print("\n###Creating protection group with spec:\n")
|
||||
print(spec)
|
||||
|
||||
# Wait for task to complete.
|
||||
task = self.ssClient.snapservice.clusters.ProtectionGroups.create_task(clusterId, spec=spec)
|
||||
|
||||
while True:
|
||||
task_info = self.ssClient.snapservice.Tasks.get(task.get_task_id())
|
||||
|
||||
if task_info.status == Status.SUCCEEDED:
|
||||
print("\n###Creation task {} succeeds.".format(task_info.description.id))
|
||||
return
|
||||
elif task_info.status == Status.FAILED:
|
||||
print("\n###Creation task {} fails.\nError:\n".format(task_info.description.id))
|
||||
print(task_info.error)
|
||||
return
|
||||
else:
|
||||
print("\n###Creation task {} progress: {}".format(task_info.description.id,
|
||||
task_info.progress.completed))
|
||||
time.sleep(5)
|
||||
|
||||
def cleanup(self):
|
||||
pgs_info = self.ssClient.snapservice.clusters.ProtectionGroups.list(self.clusterId)
|
||||
|
||||
for pg_info in pgs_info.items:
|
||||
if pg_info.info.name == testbed.config["PG_NAME"] and not testbed.config["LOCK"]:
|
||||
print("\n###Deleting created PG {}".format(testbed.config["PG_NAME"]))
|
||||
self.ssClient.snapservice.clusters.ProtectionGroups.delete_task(
|
||||
self.clusterId, pg_info.pg, ProtectionGroups.DeleteSpec(force=True))
|
||||
|
||||
|
||||
def main():
|
||||
create_pg = CreateProtectionGroup()
|
||||
create_pg.run()
|
||||
if create_pg.cleardata:
|
||||
create_pg.cleanup()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
import time
|
||||
|
||||
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.vsan.snapservice.vsan_snapservice_client import create_snapservice_client
|
||||
|
||||
from vmware.vapi.vsphere.client import create_vsphere_client
|
||||
from com.vmware.vcenter_client import Cluster
|
||||
from com.vmware.snapservice_client import *
|
||||
from com.vmware.snapservice.clusters_client import *
|
||||
from com.vmware.snapservice.tasks_client import Status
|
||||
|
||||
|
||||
class DeleteProtectionGroups(object):
|
||||
"""
|
||||
Description: Demonstrates deleting protection groups.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
parser = sample_cli.build_arg_parser()
|
||||
|
||||
required_args = parser.add_argument_group(
|
||||
'snapservice required arguments')
|
||||
required_args.add_argument('--snapservice',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Snapservice IP/hostname to connect to')
|
||||
required_args.add_argument('--cluster',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Cluster where the protection group locates')
|
||||
required_args.add_argument('--pgnames',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Protection groups to delete, separate with comma.')
|
||||
|
||||
parser.add_argument_group('snapservice optional arguments')\
|
||||
.add_argument('--force',
|
||||
action='store_true',
|
||||
help='Whether delete protection group snapshots')
|
||||
|
||||
args = sample_util.process_cli_args(parser.parse_args())
|
||||
self.cluster = args.cluster
|
||||
self.pgnames = args.pgnames
|
||||
self.force = True if args.force else False
|
||||
|
||||
skipverification = True if args.skipverification else False
|
||||
vcSession = get_unverified_session() if skipverification else None
|
||||
self.vcClient = create_vsphere_client(server=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=vcSession)
|
||||
|
||||
ssSession = get_unverified_session() if skipverification else None
|
||||
self.ssClient = create_snapservice_client(server=args.snapservice,
|
||||
vc=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=ssSession,
|
||||
skip_verification=skipverification)
|
||||
|
||||
def run(self):
|
||||
# Get cluster identifier
|
||||
cluster_spec = set([self.cluster])
|
||||
cluster_list = self.vcClient.vcenter.Cluster.list(
|
||||
Cluster.FilterSpec(names=cluster_spec))
|
||||
|
||||
clusterId = cluster_list[0].cluster
|
||||
print("\nGot cluster '{}' id: {}".format(self.cluster, clusterId))
|
||||
|
||||
pg_names = self.pgnames.split(",")
|
||||
pgs_info = self.ssClient.snapservice.clusters.ProtectionGroups.list(clusterId)
|
||||
tasks = []
|
||||
for pg_info in pgs_info.items:
|
||||
if pg_info.info.name in pg_names:
|
||||
if pg_info.info.locked:
|
||||
print("\nProtection group '{}' is mutabl, skip the deletion."
|
||||
.format(pg_info.info.name))
|
||||
|
||||
elif pg_info.info.status == ProtectionGroupStatus.MARKED_FOR_DELETE:
|
||||
print("\nProtection group '{}' is marked as deleted, skip the "
|
||||
"deletion.".format(pg_info.info.name))
|
||||
|
||||
else:
|
||||
print("\nDeleting protection group '{}' : '{}'"
|
||||
.format(pg_info.info.name, pg_info.pg))
|
||||
|
||||
task = self.ssClient.snapservice.clusters.ProtectionGroups.delete_task(
|
||||
clusterId, pg_info.pg, ProtectionGroups.DeleteSpec(force=self.force))
|
||||
print("Task id: {}\n".format(task.get_task_id()))
|
||||
tasks.append(task.get_task_id())
|
||||
|
||||
taskCompleted = 0
|
||||
while True:
|
||||
|
||||
for taskId in tasks:
|
||||
task_info = self.ssClient.snapservice.Tasks.get(taskId)
|
||||
|
||||
if task_info.status == Status.SUCCEEDED:
|
||||
print("\n###Deletion task {} succeeds.".format(task_info.description.id))
|
||||
taskCompleted += 1
|
||||
elif task_info.status == Status.FAILED:
|
||||
print("\n###Deletion task {} fails.\nError:\n".format(task_info.description.id))
|
||||
print(task_info.getResult())
|
||||
taskCompleted += 1
|
||||
else:
|
||||
print("\n###Deletion task {} progress: ".format(task_info.description.progress))
|
||||
|
||||
if taskCompleted >= len(tasks):
|
||||
print("\n\n###All protection group deletion jobs are completed")
|
||||
break
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
def main():
|
||||
delete_pg = DeleteProtectionGroups()
|
||||
delete_pg.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
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.vsan.snapservice.vsan_snapservice_client import create_snapservice_client
|
||||
|
||||
from vmware.vapi.vsphere.client import create_vsphere_client
|
||||
from com.vmware.vcenter_client import Cluster
|
||||
from com.vmware.snapservice_client import *
|
||||
from com.vmware.snapservice.clusters_client import *
|
||||
|
||||
|
||||
class ListProtectionGroups(object):
|
||||
"""
|
||||
Description: Demonstrates listing protection groups.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
parser = sample_cli.build_arg_parser()
|
||||
|
||||
required_args = parser.add_argument_group(
|
||||
'snapservice required arguments')
|
||||
required_args.add_argument('--snapservice',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Snapservice IP/hostname to connect to')
|
||||
required_args.add_argument('--cluster',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Cluster where the protection group locates')
|
||||
|
||||
args = sample_util.process_cli_args(parser.parse_args())
|
||||
self.cluster = args.cluster
|
||||
|
||||
skipverification = True if args.skipverification else False
|
||||
vcSession = get_unverified_session() if skipverification else None
|
||||
self.vcClient = create_vsphere_client(server=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=vcSession)
|
||||
|
||||
ssSession = get_unverified_session() if skipverification else None
|
||||
self.ssClient = create_snapservice_client(server=args.snapservice,
|
||||
vc=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=ssSession,
|
||||
skip_verification=skipverification)
|
||||
|
||||
def run(self):
|
||||
# Get cluster identifier
|
||||
cluster_spec = set([self.cluster])
|
||||
cluster_list = self.vcClient.vcenter.Cluster.list(
|
||||
Cluster.FilterSpec(names=cluster_spec))
|
||||
|
||||
clusterId = cluster_list[0].cluster
|
||||
print("\nGot cluster '{}' id: {}".format(self.cluster, clusterId))
|
||||
|
||||
pgs_info = self.ssClient.snapservice.clusters.ProtectionGroups.list(clusterId)
|
||||
print("\n\nList of protection groups:\n")
|
||||
for pg_info in pgs_info.items:
|
||||
print(pg_info)
|
||||
print("----------------------------------------\n")
|
||||
|
||||
|
||||
def main():
|
||||
list_pg = ListProtectionGroups()
|
||||
list_pg.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
25
samples/vsan/snapservice/snapshot/__init__.py
Normal file
25
samples/vsan/snapservice/snapshot/__init__.py
Normal file
@ -0,0 +1,25 @@
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__copyright__ = 'Copyright (c) 2024 Broadcom. 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
|
@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
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.vsan.snapservice.vsan_snapservice_client import create_snapservice_client
|
||||
|
||||
from vmware.vapi.vsphere.client import create_vsphere_client
|
||||
from com.vmware.vcenter_client import Cluster
|
||||
from com.vmware.snapservice_client import *
|
||||
from com.vmware.snapservice.clusters_client import *
|
||||
|
||||
|
||||
class DeleteProtectionGroupSnapshots(object):
|
||||
"""
|
||||
Description: Demonstrates deleting protection group snapshots.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
parser = sample_cli.build_arg_parser()
|
||||
|
||||
required_args = parser.add_argument_group(
|
||||
'snapservice required arguments')
|
||||
required_args.add_argument('--snapservice',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Snapservice IP/hostname to connect to')
|
||||
required_args.add_argument('--cluster',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Cluster where the protection group locates')
|
||||
required_args.add_argument('--pgname',
|
||||
action='store',
|
||||
required=True,
|
||||
help='Protection group to delete snapshot')
|
||||
|
||||
parser.add_argument_group('snapservice optional arguments')\
|
||||
.add_argument('--remain',
|
||||
action='store',
|
||||
help='How many protection group snapshots to leave')
|
||||
|
||||
args = sample_util.process_cli_args(parser.parse_args())
|
||||
self.cluster = args.cluster
|
||||
self.pgname = args.pgname
|
||||
self.remain = int(args.remain) if int(args.remain) > 0 else 0
|
||||
|
||||
skipverification = True if args.skipverification else False
|
||||
vcSession = get_unverified_session() if skipverification else None
|
||||
self.vcClient = create_vsphere_client(server=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=vcSession)
|
||||
|
||||
ssSession = get_unverified_session() if skipverification else None
|
||||
self.ssClient = create_snapservice_client(server=args.snapservice,
|
||||
vc=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=ssSession,
|
||||
skip_verification=skipverification)
|
||||
|
||||
def run(self):
|
||||
# Get cluster identifier
|
||||
cluster_spec = set([self.cluster])
|
||||
cluster_list = self.vcClient.vcenter.Cluster.list(
|
||||
Cluster.FilterSpec(names=cluster_spec))
|
||||
|
||||
clusterId = cluster_list[0].cluster
|
||||
print("\nGot cluster '{}' id: {}".format(self.cluster, clusterId))
|
||||
|
||||
# Get protection group identifier
|
||||
pgs_info = self.ssClient.snapservice.clusters.ProtectionGroups.list(clusterId)
|
||||
pgId = 0
|
||||
for pg_info in pgs_info.items:
|
||||
if pg_info.info.name == self.pgname:
|
||||
pgId = pg_info.pg
|
||||
print("\nProtection groups '{}': '{}'\n".format(self.pgname, pgId))
|
||||
|
||||
# Get protection group snapshots
|
||||
snapshots_info = self.ssClient.snapservice.clusters.protection_groups\
|
||||
.Snapshots.list(clusterId, pgId)
|
||||
print("\n\nGet snapshots:\n{}".format(snapshots_info))
|
||||
|
||||
# Get snapshot to delete
|
||||
snapshotTimeMap = {}
|
||||
for snapshot in snapshots_info.snapshots:
|
||||
snapshotTimeMap[snapshot.info.expires_at] = snapshot.snapshot
|
||||
|
||||
timeToDel = []
|
||||
if self.remain == 0:
|
||||
timeToDel = sorted(snapshotTimeMap)
|
||||
elif self.remain < len(snapshotTimeMap):
|
||||
timeToDel = sorted(snapshotTimeMap)[0:-self.remain]
|
||||
else:
|
||||
print("\n\n No snapshot to delete.\n")
|
||||
|
||||
for time in timeToDel:
|
||||
print("\n\n##Deleting pg snapshot '{}' which will expire at '{}'"
|
||||
.format(snapshotTimeMap[time], time))
|
||||
task = self.ssClient.snapservice.clusters.protection_groups\
|
||||
.Snapshots.delete(clusterId, pgId, snapshotTimeMap[time])
|
||||
|
||||
|
||||
def main():
|
||||
delete_pg_snapshot = DeleteProtectionGroupSnapshots()
|
||||
delete_pg_snapshot.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
137
samples/vsan/snapservice/vsan_snapservice_client.py
Normal file
137
samples/vsan/snapservice/vsan_snapservice_client.py
Normal file
@ -0,0 +1,137 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. 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__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
import requests
|
||||
import ssl
|
||||
from pyVim import sso
|
||||
|
||||
from com.vmware.snapservice.clusters_client import StubFactory as clusters_factory
|
||||
from com.vmware.snapservice.info_client import StubFactory as info_factory
|
||||
from com.vmware.snapservice.tasks_client import StubFactory as tasks_factory
|
||||
|
||||
from vmware.vapi.bindings.stub import ApiClient
|
||||
from vmware.vapi.bindings.stub import StubFactoryBase
|
||||
from vmware.vapi.lib.connect import get_requests_connector
|
||||
from vmware.vapi.security.client.security_context_filter import \
|
||||
LegacySecurityContextFilter
|
||||
from vmware.vapi.security.sso import create_saml_bearer_security_context
|
||||
from vmware.vapi.stdlib.client.factories import StubConfigurationFactory
|
||||
|
||||
JSON_RPC_ENDPOINT = '/api'
|
||||
|
||||
|
||||
class StubFactory(StubFactoryBase):
|
||||
|
||||
def __init__(self, stub_config):
|
||||
StubFactoryBase.__init__(self, stub_config)
|
||||
self.snapservice.clusters = clusters_factory(stub_config)
|
||||
self.snapservice.info = info_factory(stub_config)
|
||||
self.snapservice.tasks = tasks_factory(stub_config)
|
||||
|
||||
_attrs = {
|
||||
'snapservice': 'com.vmware.snapservice_client.StubFactory',
|
||||
}
|
||||
|
||||
|
||||
class SnapserviceClient(ApiClient):
|
||||
"""
|
||||
Snapservice Client class that provides access to stubs for all services in
|
||||
the snapservice API
|
||||
"""
|
||||
|
||||
def __init__(self, session, server, bearer_token):
|
||||
"""
|
||||
Initialize SnapserviceClient by creating a parent stub factory instance
|
||||
of all snapservice components.
|
||||
|
||||
:type session: :class:`requests.Session`
|
||||
:param session: Requests HTTP session instance. If not specified,
|
||||
then one is automatically created and used
|
||||
:type server: :class:`str`
|
||||
:param server: snapservice appliance host name or IP address
|
||||
:type bearer_token: :class:`str`
|
||||
:param bearer_token: SAML Bearer Token
|
||||
"""
|
||||
if not session:
|
||||
session = requests.Session()
|
||||
self.session = session
|
||||
|
||||
host_url = "https://" + server + JSON_RPC_ENDPOINT
|
||||
|
||||
if bearer_token is None:
|
||||
raise "Please provide bearer_token to authenticate snapservice"
|
||||
sec_ctx = create_saml_bearer_security_context(bearer_token)
|
||||
|
||||
stub_config = StubConfigurationFactory.new_std_configuration(
|
||||
get_requests_connector(
|
||||
session=session, url=host_url,
|
||||
provider_filter_chain=[
|
||||
LegacySecurityContextFilter(
|
||||
security_context=sec_ctx)]))
|
||||
|
||||
stub_factory = StubFactory(stub_config)
|
||||
ApiClient.__init__(self, stub_factory)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.__del__()
|
||||
|
||||
def __del__(self):
|
||||
if hasattr(self, 'session'):
|
||||
self.session.close()
|
||||
|
||||
|
||||
def create_snapservice_client(server, vc, username, password, session,
|
||||
skip_verification=True):
|
||||
"""
|
||||
Helper method to create an instance of the snapservice client.
|
||||
Currently, snapservice only support bearer token to authenticate. So
|
||||
acqure bearer token from sso and then create the snapservice client.
|
||||
|
||||
:type server: :class:`str`
|
||||
:param server: snapservice appliance host name or IP address
|
||||
:type vc: :class:`str`
|
||||
:param vc: vCenter server host name or IP address
|
||||
:type username: :class:`str`
|
||||
:param username: username to the vCenter server
|
||||
:type password: :class:`str`
|
||||
:param password: password of the username
|
||||
:type session: :class:`requests.Session` or ``None``
|
||||
:param session: Requests HTTP session instance. If not specified,
|
||||
then one is automatically created and used
|
||||
"""
|
||||
# Acquire token from sso.
|
||||
sso_url = 'https://' + vc + '/sts/STSService'
|
||||
authenticator = sso.SsoAuthenticator(sso_url)
|
||||
|
||||
context = None
|
||||
if skip_verification:
|
||||
if hasattr(ssl, '_create_unverified_context'):
|
||||
context = ssl._create_unverified_context()
|
||||
|
||||
# The token lifetime is 30 minutes.
|
||||
print("\n\nAcquire SAML token from PSC.\n")
|
||||
saml_token = authenticator.get_bearer_saml_assertion(username,
|
||||
password,
|
||||
token_duration=30 * 60,
|
||||
delegatable=True,
|
||||
ssl_context=context)
|
||||
|
||||
return SnapserviceClient(session=session, server=server, bearer_token=saml_token)
|
@ -1,6 +1,8 @@
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) VMware, Inc. 2013. All Rights Reserved.
|
||||
* Copyright (c) 2013, 2024 Broadcom. All Rights Reserved.
|
||||
* The term "Broadcom" refers to Broadcom Inc.
|
||||
* and/or its subsidiaries.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* *******************************************************
|
||||
*
|
||||
@ -11,13 +13,14 @@
|
||||
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
"""
|
||||
|
||||
__author__ = 'VMware, Inc.'
|
||||
__copyright__ = 'Copyright 2013 VMware, Inc. All rights reserved.'
|
||||
__author__ = 'Broadcom, Inc.'
|
||||
__copyright__ = 'Copyright 2013, 2024 Broadcom, Inc. All rights reserved.'
|
||||
|
||||
import os
|
||||
from deprecated import deprecated
|
||||
from suds.client import Client
|
||||
|
||||
|
||||
@deprecated(version='8.0U3', reason='Use well-known endpoint URLs instead of looking them up.')
|
||||
class LookupServiceHelper(object):
|
||||
def __init__(self, wsdl_url, soap_url, skip_verification):
|
||||
self.wsdl_url = wsdl_url
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) VMware, Inc. 2013, 2016. All Rights Reserved.
|
||||
* Copyright (c) 2024 Broadcom. All Rights Reserved.
|
||||
* Broadcom Confidential. The term "Broadcom" refers to Broadcom Inc.
|
||||
* and/or its subsidiaries.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* *******************************************************
|
||||
*
|
||||
@ -11,8 +13,10 @@
|
||||
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
"""
|
||||
|
||||
__author__ = 'VMware, Inc.'
|
||||
__copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.'
|
||||
__author__ = 'Broadcom, Inc.'
|
||||
__copyright__ = 'Copyright 2013, 2016, 2024 Broadcom, Inc. All rights reserved.'
|
||||
|
||||
from deprecated import deprecated
|
||||
|
||||
from vmware.vapi.security.sso import create_saml_bearer_security_context
|
||||
from samples.vsphere.common import sso
|
||||
@ -20,7 +24,7 @@ from samples.vsphere.common.lookup_service_helper import LookupServiceHelper
|
||||
|
||||
from samples.vsphere.common.ssl_helper import get_unverified_context
|
||||
|
||||
|
||||
@deprecated(version='8.0U3', reason='External PSC is no longer supported since vCenter 7.0. Use well-known endpoint URLs instead of looking them up.')
|
||||
class PlatformServiceController(object):
|
||||
"""
|
||||
Manages services on the infrastructure node (e.g. lookup service, SSO etc.)
|
||||
|
37
samples/vsphere/hardwaretpm/README.md
Normal file
37
samples/vsphere/hardwaretpm/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
This directory contains sample for getting TPM information using Trust Authority APIs added in __vcenter_version__ = '8.0+'
|
||||
* Get ESX TPM information - tpm_info.py
|
||||
|
||||
Running the samples
|
||||
$ python <sample-dir>/<sample>.py --server <vCenter Server IP> --username <username> --password <password> <additional-sample-parameters>
|
||||
|
||||
* Testbed Requirement:
|
||||
- 1 vCenter Server
|
||||
- 1 ESX host with TPM enabled
|
||||
|
||||
* Sample output
|
||||
python samples/vsphere/hardwaretpm/tpm_info.py -s <vCenter Server IP> -u <username> -p <password> --skipverification
|
||||
vcenter server = <ip>
|
||||
vc username = <username>
|
||||
----------------------------
|
||||
TPM Information
|
||||
----------------------------
|
||||
'major_version: 2'
|
||||
'minor_version: 0'
|
||||
'active: True'
|
||||
'manufacturer: NTC'
|
||||
'model: rls'
|
||||
'firmware_version: 1.3.1.0'
|
||||
----------------------------
|
||||
----------------------------
|
||||
TPM Endorsement key
|
||||
----------------------------
|
||||
('-----BEGIN PUBLIC KEY-----\n'
|
||||
'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1I65uMJU5MugQzl3K6yg\n'
|
||||
'Zjzed6aP7MX1Cl670NsvMSXs4FRdNZ1wkJHFUHrSG6ihBmHoziqWKhMjv3g9qrmJ\n'
|
||||
'tGR6uGsDi2nFsjn0/AK5epDQsQC6FffE6OotqAMtx+MocuU6XOacZ0lyjUcVGZRX\n'
|
||||
'RLK1TmRL3ugupFDe0XLcQZPNzv4cYNLub3prYEgEcpac89xVEn/TCyRK/nMGTHxs\n'
|
||||
'Z1oMI+FjpKMh5Vj/6c2gwhoX7tYQFXZOLy6S9prok5fWgHssZAjQNLjp1rihVpp3\n'
|
||||
'6BIkCBRw+LSEdz47naOsZN7NEYO78It3JGlPt2fpYVJ6+/8ObUa5Sv8svzFOb0Qq\n'
|
||||
'rQIDAQAB\n'
|
||||
'-----END PUBLIC KEY-----\n')
|
||||
----------------------------
|
96
samples/vsphere/hardwaretpm/tpm_info.py
Normal file
96
samples/vsphere/hardwaretpm/tpm_info.py
Normal file
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. All Rights Reserved.
|
||||
* Broadcom Confidential. The term "Broadcom" refers to Broadcom Inc.
|
||||
* and/or its subsidiaries.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* *******************************************************
|
||||
"""
|
||||
|
||||
__author__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '8.0+'
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
from com.vmware.vcenter.trusted_infrastructure.hosts.hardware_client import Tpm
|
||||
from com.vmware.vcenter.trusted_infrastructure.hosts.hardware.tpm_client import EndorsementKeys
|
||||
from vmware.vapi.vsphere.client import create_vsphere_client
|
||||
|
||||
from samples.vsphere.common import sample_cli
|
||||
from samples.vsphere.common import sample_util
|
||||
from samples.vsphere.common import vapiconnect
|
||||
from samples.vsphere.common.ssl_helper import get_unverified_session
|
||||
|
||||
|
||||
class TPMInfo(object):
|
||||
"""
|
||||
Demonstrates how to get TPM Information for the Host
|
||||
attached to vCenter.
|
||||
|
||||
Sample Prerequisites:
|
||||
vCenter/ESX(TPM enabled)
|
||||
"""
|
||||
def __init__(self):
|
||||
self.stub_config = None
|
||||
self.hostId = None
|
||||
|
||||
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 vSphere client to get attached Host information.
|
||||
self.client = create_vsphere_client(server=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=session)
|
||||
for host in self.client.vcenter.Host.list():
|
||||
self.hostId = host.host
|
||||
|
||||
# Connect to the trusted infrastructure services.
|
||||
self.stub_config = vapiconnect.connect(host=args.server,
|
||||
user=args.username,
|
||||
pwd=args.password,
|
||||
skip_verification=args.skipverification)
|
||||
self.tpm_svc = Tpm(self.stub_config)
|
||||
self.ek_svc = EndorsementKeys(self.stub_config)
|
||||
|
||||
def run(self):
|
||||
tpmList = self.tpm_svc.list(self.hostId)
|
||||
for tpm in tpmList:
|
||||
tpmId = tpm.tpm
|
||||
tpmInfo = self.tpm_svc.get(self.hostId, tpmId)
|
||||
print("----------------------------")
|
||||
print("TPM Information")
|
||||
print("----------------------------")
|
||||
pprint("major_version: %s" % tpmInfo.major_version)
|
||||
pprint("minor_version: %s" % tpmInfo.minor_version)
|
||||
pprint("active: %s" % tpmInfo.active)
|
||||
if tpmInfo.manufacturer:
|
||||
pprint("manufacturer: %s" % tpmInfo.manufacturer)
|
||||
if tpmInfo.model:
|
||||
pprint("model: %s" % tpmInfo.model)
|
||||
if tpmInfo.firmware_version:
|
||||
pprint("firmware_version: %s" % tpmInfo.firmware_version)
|
||||
print("----------------------------")
|
||||
|
||||
eksList = self.ek_svc.list(self.hostId, tpmId)
|
||||
for ek in eksList:
|
||||
keyId = ek.key
|
||||
ekInfo = self.ek_svc.get(self.hostId, tpmId, keyId)
|
||||
if ekInfo.public_key:
|
||||
print("----------------------------")
|
||||
print("TPM Endorsement key")
|
||||
print("----------------------------")
|
||||
pprint(ekInfo.public_key)
|
||||
print("----------------------------")
|
||||
|
||||
|
||||
def main():
|
||||
tpm_info = TPMInfo()
|
||||
tpm_info.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -11,3 +11,17 @@ $ python external_psc_sso_workflow.py --lsurl https://<server>/lookupservice/sdk
|
||||
```
|
||||
* Testbed Requirement:
|
||||
- 1 vCenter Server
|
||||
|
||||
### Deprecation Notice
|
||||
Starting vCenter server release 7.0, External Platform Services Controller (PSC) is no longer supported. All PSC services are consolidated into vCenter Server.
|
||||
https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vcenter.configuration.doc/GUID-135F2607-DA51-47A5-BB7A-56AD141113D4.html
|
||||
In view of the above, related samples (ex: external_psc_sso_workflow) and other related files are deprecated and will be removed in next major SDK release.
|
||||
|
||||
Consequently, lookupservice WSDL files will also be removed in next major SDK release. Use well known URL path (https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-apis-sdks-introduction/GUID-B625C8FE-5E15-4918-98C0-69313E5880FB.html) instead of lookupservice.
|
||||
|
||||
For SSO, service endpoint is: "https://{domain}/sts/STSService"
|
||||
https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-apis-sdks-introduction/GUID-5384662C-CD05-4CAE-894E-972F14A7ECB7.html
|
||||
|
||||
### Package Dependency Note
|
||||
To run the deprecated samples, users need "Deprecated" package installed in their environment.
|
||||
https://pypi.org/project/Deprecated/
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) VMware, Inc. 2017, 2018. All Rights Reserved.
|
||||
* Copyright (c) 2024 Broadcom. All Rights Reserved.
|
||||
* The term "Broadcom" refers to Broadcom Inc.
|
||||
* and/or its subsidiaries.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* *******************************************************
|
||||
*
|
||||
@ -13,11 +15,12 @@
|
||||
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
"""
|
||||
|
||||
__author__ = 'VMware, Inc.'
|
||||
__author__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '6.0+'
|
||||
|
||||
import os
|
||||
import argparse
|
||||
from deprecated import deprecated
|
||||
|
||||
from six.moves.urllib import request, parse
|
||||
|
||||
@ -30,6 +33,7 @@ from samples.vsphere.common.ssl_helper import get_unverified_context
|
||||
from samples.vsphere.common.ssl_helper import get_unverified_session
|
||||
|
||||
|
||||
@deprecated(version='8.0U3', reason='External PSC is no longer supported since vCenter 7.0. Use well-known endpoint URLs instead of looking them up.')
|
||||
class ExternalPscSsoWorkflow(object):
|
||||
"""
|
||||
Demonstrates how to Login to vCenter vAPI service with
|
||||
|
@ -86,6 +86,15 @@ config["FLOPPY_DATACENTER_NAME"] = config["VM_DATACENTER_NAME"]
|
||||
config["FLOPPY_DATASTORE_ROOT_PATH"] = config["BACKENDS_DATASTORE_ROOT_PATH"] + "/floppy"
|
||||
config["FLOPPY_DATASTORE_PATH"] = config["FLOPPY_DATASTORE_ROOT_PATH"] + "/fdboot.img"
|
||||
|
||||
# Snapservice protection group creation spec
|
||||
config["PG_NAME"] = "PG_NAME"
|
||||
config["VM_NAMES"] = "VM_NAME1,VM_NAME2,..."
|
||||
config["VM_FORMATS"] = "VM_FORMAT1,VM_FORMAT2,..."
|
||||
config["SCHEDULE_UNIT"] = "MINUTE"
|
||||
config["SCHEDULE"] = 30
|
||||
config["RETENTION_UNIT"] = "HOUR"
|
||||
config["RETENTION"] = 6
|
||||
config["LOCK"] = False
|
||||
|
||||
class Testbed(object):
|
||||
def __init__(self):
|
||||
|
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. All Rights Reserved.
|
||||
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
|
||||
* 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__ = 'Broadcom'
|
||||
__copyright__ = 'Copyright (c) 2024 Broadcom. All Rights Reserved.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
from pyVim.connect import SmartConnect
|
||||
|
||||
from samples.vsphere.common import sample_cli
|
||||
from samples.vsphere.common import sample_util
|
||||
from vmware.vapi.vsphere.client import create_vsphere_client
|
||||
|
||||
from samples.vsphere.common.ssl_helper import get_unverified_session
|
||||
|
||||
"""
|
||||
With the single session functionality introduction,
|
||||
in version 8.0.3, users are enabled to login only once and reuse
|
||||
the session in vAPI and pyVmomi.
|
||||
|
||||
Demonstrates transfer of an authenticated session from pyVmomi
|
||||
to a vAPI stub. The sample includes post transfer verification
|
||||
via invocation of `vcenter.compute.Policies.list` operation,
|
||||
which requires authenticated access.
|
||||
|
||||
Sample Prerequisites:
|
||||
- vCenter
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = sample_cli.build_arg_parser()
|
||||
args = sample_util.process_cli_args(parser.parse_args())
|
||||
|
||||
# Login with pyvmomi
|
||||
si = SmartConnect(host=args.server,
|
||||
user=args.username,
|
||||
pwd=args.password,
|
||||
disableSslCertValidation=args.skipverification)
|
||||
print("Logged in through pyVmomi")
|
||||
|
||||
# Acquire session_id
|
||||
session_id = si._GetStub().GetSessionId()
|
||||
print("Session ID acquired")
|
||||
|
||||
# Reuse session_id in create_vsphere_client
|
||||
# A login will not be attempted when session_id is provided
|
||||
session = get_unverified_session() if args.skipverification else None
|
||||
client = create_vsphere_client(args.server,
|
||||
session=session,
|
||||
session_id=session_id)
|
||||
print("Created vAPI client utilizing the pyVmomi session")
|
||||
|
||||
result = client.vcenter.compute.Policies.list()
|
||||
if type(result) is list:
|
||||
print("Session has been successfully reused")
|
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. All Rights Reserved.
|
||||
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
|
||||
* 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__ = 'Broadcom'
|
||||
__copyright__ = 'Copyright (c) 2024 Broadcom. All Rights Reserved.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
from pyVim.connect import SmartConnect
|
||||
|
||||
from samples.vsphere.common import sample_cli
|
||||
from samples.vsphere.common import sample_util
|
||||
from vmware.vapi.vsphere.client import create_vsphere_client
|
||||
|
||||
from samples.vsphere.common.ssl_helper import get_unverified_session
|
||||
|
||||
"""
|
||||
With the single session functionality introduction,
|
||||
in version 8.0.3, users are enabled to login only once and reuse
|
||||
the session in vAPI and pyVmomi.
|
||||
|
||||
Demonstrates transfer of an authenticated session from vAPI to
|
||||
a pyVmomi stub. The sample includes post transfer verification
|
||||
via invocation of `sessionManager.SessionIsActive` operation,
|
||||
which requires authenticated access.
|
||||
|
||||
Sample Prerequisites:
|
||||
- vCenter
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = sample_cli.build_arg_parser()
|
||||
args = sample_util.process_cli_args(parser.parse_args())
|
||||
|
||||
# Create session through vAPI
|
||||
session = get_unverified_session() if args.skipverification else None
|
||||
client = create_vsphere_client(server=args.server,
|
||||
username=args.username,
|
||||
password=args.password,
|
||||
session=session)
|
||||
print("Logged in through vAPI vSphere client")
|
||||
|
||||
# Acquire session_id
|
||||
session_id = client.get_session_id()
|
||||
print("Session ID acquired")
|
||||
|
||||
# Reuse session_id in SmartConnect
|
||||
# A login will not be attempted when session_id is provided
|
||||
si = SmartConnect(host=args.server,
|
||||
disableSslCertValidation=args.skipverification,
|
||||
sessionId=session_id)
|
||||
print("Created pyVmomi stub utilizing the vAPI session")
|
||||
|
||||
content = si.RetrieveContent()
|
||||
reused_session = content.sessionManager.currentSession
|
||||
result = content.sessionManager.SessionIsActive(reused_session.key, args.username)
|
||||
if result:
|
||||
print("Session has been successfully reused")
|
@ -0,0 +1,26 @@
|
||||
# vLCM/Cluster/Installed_Images
|
||||
|
||||
This directory contains samples of the cluster-level vLCM installed images API
|
||||
|
||||
The installed images API provides a way to easily see the software running on hosts in a given cluster. This API will scan the hosts in the target cluster and generate a report detailing what images are being run. These images are organized into three categories: "highest versioned image", "most widely used image", and "hostImageList" which just contains the rest of the images.
|
||||
|
||||
## APIs
|
||||
POST
|
||||
- The extract POST method triggers the installed images workflow, which is an asynchronous operation. This API returns a task ID which can be used to monitor the progress of the task.
|
||||
|
||||
GET
|
||||
- This GET method is a synchronous operation and it returns the most recently generated installed images report for the cluster corresponding to the provided MoID.
|
||||
|
||||
## Running the samples
|
||||
|
||||
To view the available command-line options:
|
||||
|
||||
```
|
||||
python samples/vsphere/vcenter/vlcm/cluster/installed_images/installed_images.py -h
|
||||
```
|
||||
|
||||
To run the sample:
|
||||
|
||||
```
|
||||
$ python samples/vsphere/vcenter/vlcm/cluster/installed_images/installed_images.py -v -s <vCenter server IP> -u <username> -p <password> --cluster <cluster MoID>
|
||||
```
|
@ -0,0 +1,21 @@
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. All Rights Reserved.
|
||||
* Broadcom Confidential. The term "Broadcom" refers to Broadcom Inc.
|
||||
* and/or its subsidiaries.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* *******************************************************
|
||||
"""
|
||||
|
||||
__author__ = 'Broadcom, Inc.'
|
||||
__copyright__ = 'Copyright 2024 Broadcom, 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
|
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
* *******************************************************
|
||||
* Copyright (c) 2024 Broadcom. All Rights Reserved.
|
||||
* Broadcom Confidential. The term "Broadcom" refers to Broadcom Inc.
|
||||
* and/or its subsidiaries.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* *******************************************************
|
||||
"""
|
||||
|
||||
__author__ = 'Broadcom, Inc.'
|
||||
__vcenter_version__ = '8.0.3+'
|
||||
|
||||
import time
|
||||
|
||||
from com.vmware.esx.settings.clusters_client import InstalledImages
|
||||
from samples.vsphere.common import sample_cli, sample_util
|
||||
from samples.vsphere.vcenter.hcl.utils import get_configuration
|
||||
|
||||
SUCCEEDED_KEY = "SUCCEEDED"
|
||||
FAILED_KEY = "FAILED"
|
||||
|
||||
# With a 1 second sleep this is equal to roughly 5 minutes
|
||||
TIME_OUT_ITERATIONS = 300
|
||||
|
||||
|
||||
class InstalledImagesSvc:
|
||||
"""
|
||||
Demonstrates triggering the "extract" workflow for the cluster Installed Images
|
||||
feature, waiting for the task to complete, and getting the result.
|
||||
|
||||
Prerequisites:
|
||||
- A datacenter
|
||||
- A vSAN cluster with at least one host
|
||||
"""
|
||||
def __init__(self):
|
||||
parser = sample_cli.build_arg_parser()
|
||||
parser.add_argument("--cluster",
|
||||
required=True,
|
||||
help="MoID of the target cluster")
|
||||
args = sample_util.process_cli_args(parser.parse_args())
|
||||
|
||||
self.cluster = args.cluster
|
||||
|
||||
config = get_configuration(args.server, args.username,
|
||||
args.password,
|
||||
args.skipverification)
|
||||
|
||||
self.apiClient = InstalledImages(config)
|
||||
|
||||
def run(self):
|
||||
task = self.apiClient.extract_task(self.cluster)
|
||||
|
||||
if self.waitForTask(task):
|
||||
print("Successfully got installed images report:")
|
||||
print(self.apiClient.get(self.cluster))
|
||||
|
||||
def waitForTask(self, task):
|
||||
i = 0
|
||||
try:
|
||||
while True:
|
||||
i += 1
|
||||
status = task.get_info().status
|
||||
if status == SUCCEEDED_KEY or status == FAILED_KEY:
|
||||
return True
|
||||
if i > TIME_OUT_ITERATIONS:
|
||||
print("Timeout reached waiting for task--cancelling operation")
|
||||
return False
|
||||
|
||||
time.sleep(1)
|
||||
except Exception as e:
|
||||
print(f"Error occurred waiting for task: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
installedImagesSvc = InstalledImagesSvc()
|
||||
installedImagesSvc.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
24
setup.py
24
setup.py
@ -5,23 +5,23 @@ import os
|
||||
from setuptools import setup
|
||||
|
||||
setup(name='vsphere-automation-sdk',
|
||||
version='1.86.0',
|
||||
version='1.87.0',
|
||||
description='VMware vSphere Automation SDK for Python',
|
||||
url='https://github.com/vmware/vsphere-automation-sdk-python',
|
||||
author='VMware, Inc.',
|
||||
author='Broadcom, Inc.',
|
||||
license='MIT',
|
||||
packages=[],
|
||||
install_requires=[
|
||||
'lxml >= 4.3.0',
|
||||
'pyVmomi >=6.7',
|
||||
'vapi-runtime @ file://localhost/{}/lib/vapi-runtime/vapi_runtime-2.44.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'vcenter-bindings @ file://localhost/{}/lib/vcenter-bindings/vcenter_bindings-4.2.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'vapi-common-client @ file://localhost/{}/lib/vapi-common-client/vapi_common_client-2.44.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'vmwarecloud-aws @ file://localhost/{}/lib/vmwarecloud-aws/vmwarecloud_aws-1.64.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-python-sdk @ file://localhost/{}/lib/nsx-python-sdk/nsx_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-policy-python-sdk @ file://localhost/{}/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-vmc-policy-python-sdk @ file://localhost/{}/lib/nsx-vmc-policy-python-sdk/nsx_vmc_policy_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-vmc-aws-integration-python-sdk @ file://localhost/{}/lib/nsx-vmc-aws-integration-python-sdk/nsx_vmc_aws_integration_python_sdk-4.1.2.0.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'vmwarecloud-draas @ file://localhost/{}/lib/vmwarecloud-draas/vmwarecloud_draas-1.23.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'pyVmomi == 8.0.3.0.1',
|
||||
'vmware-vapi-runtime == 2.52.0',
|
||||
'vmware-vcenter == 8.0.3.0',
|
||||
'vmware-vapi-common-client == 2.52.0',
|
||||
'vmwarecloud-aws @ file://localhost/{}/lib/vmwarecloud-aws/vmwarecloud_aws-1.64.1-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-python-sdk @ file://localhost/{}/lib/nsx-python-sdk/nsx_python_sdk-4.2.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-policy-python-sdk @ file://localhost/{}/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-4.2.0-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-vmc-policy-python-sdk @ file://localhost/{}/lib/nsx-vmc-policy-python-sdk/nsx_vmc_policy_python_sdk-4.1.2.0.1-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'nsx-vmc-aws-integration-python-sdk @ file://localhost/{}/lib/nsx-vmc-aws-integration-python-sdk/nsx_vmc_aws_integration_python_sdk-4.1.2.0.1-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
'vmwarecloud-draas @ file://localhost/{}/lib/vmwarecloud-draas/vmwarecloud_draas-1.23.1-py2.py3-none-any.whl'.format(os.getcwd()),
|
||||
]
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user