mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-24 10:19:59 -05:00
commit
a2f0709f1b
@ -4,6 +4,7 @@
|
|||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [Abstract](#abstract)
|
- [Abstract](#abstract)
|
||||||
- [Supported vCenter Releases](#supported-vcenter-releases)
|
- [Supported vCenter Releases](#supported-vcenter-releases)
|
||||||
|
- [Supported NSX-T Releases](#supported-nsx-t-releases)
|
||||||
- [VMware Cloud on AWS Support](#vmware-cloud-on-aws-support)
|
- [VMware Cloud on AWS Support](#vmware-cloud-on-aws-support)
|
||||||
- [Quick Start Guide](#quick-start-guide)
|
- [Quick Start Guide](#quick-start-guide)
|
||||||
- [Run SDK Samples](#run-sdk-samples)
|
- [Run SDK Samples](#run-sdk-samples)
|
||||||
@ -22,6 +23,9 @@ The samples have been developed to work with python 2.7.x and 3.3+
|
|||||||
vCenter 6.0, 6.5 and 6.7.
|
vCenter 6.0, 6.5 and 6.7.
|
||||||
Certain APIs and samples that are introduced in 6.5 release, such as vCenter, Virtual Machine and Appliance Management. Please refer to the notes in each sample for detailed compatibility information.
|
Certain APIs and samples that are introduced in 6.5 release, such as vCenter, Virtual Machine and Appliance Management. Please refer to the notes in each sample for detailed compatibility information.
|
||||||
|
|
||||||
|
## Supported NSX-T Releases
|
||||||
|
NSX-T 2.2
|
||||||
|
|
||||||
## VMware Cloud on AWS Support
|
## VMware Cloud on AWS Support
|
||||||
The VMware Cloud on AWS API and samples are currently available as a preview and are subject to change in the future.
|
The VMware Cloud on AWS API and samples are currently available as a preview and are subject to change in the future.
|
||||||
|
|
||||||
|
BIN
doc/client.zip
BIN
doc/client.zip
Binary file not shown.
BIN
doc/nsx_policy_python_sdk-2.2.0.0.0.15150318-doc.zip
Normal file
BIN
doc/nsx_policy_python_sdk-2.2.0.0.0.15150318-doc.zip
Normal file
Binary file not shown.
BIN
doc/nsx_policy_python_sdk-2.2.0.0.0.15184434-doc.zip
Normal file
BIN
doc/nsx_policy_python_sdk-2.2.0.0.0.15184434-doc.zip
Normal file
Binary file not shown.
BIN
doc/vmc.zip
BIN
doc/vmc.zip
Binary file not shown.
BIN
doc/vmc_app_python_sdk-2.2.0.0.0.15150318-doc.zip
Normal file
BIN
doc/vmc_app_python_sdk-2.2.0.0.0.15150318-doc.zip
Normal file
Binary file not shown.
BIN
doc/vmc_app_python_sdk-2.2.0.0.0.15184434-doc.zip
Normal file
BIN
doc/vmc_app_python_sdk-2.2.0.0.0.15184434-doc.zip
Normal file
Binary file not shown.
@ -8,3 +8,6 @@ vapi_runtime | vAPI runtime responsible for serialization/
|
|||||||
vapi_vmc_client | Handles VMC CSP authentication process
|
vapi_vmc_client | Handles VMC CSP authentication process
|
||||||
vapi_client_bindings | Client stubs for vSphere Automation APIs
|
vapi_client_bindings | Client stubs for vSphere Automation APIs
|
||||||
vmc_client_bindings | Client stubs for VMware Cloud Services APIs
|
vmc_client_bindings | Client stubs for VMware Cloud Services APIs
|
||||||
|
nsx-policy-python-sdk | Client stubs for VMware NSX-T Policy APIs
|
||||||
|
vmc-app-python-sdk | Client stubs for VMware NSX-T VMC app APIs (for AWS underlay management)
|
||||||
|
vapi-common-client | Common client code libraries
|
||||||
|
@ -6,5 +6,7 @@
|
|||||||
<a href='vapi-client-bindings/'>vapi-client-bindings</a><br/>
|
<a href='vapi-client-bindings/'>vapi-client-bindings</a><br/>
|
||||||
<a href='vmc-client-bindings/'>vmc-client-bindings</a><br/>
|
<a href='vmc-client-bindings/'>vmc-client-bindings</a><br/>
|
||||||
<a href='vapi-runtime/'>vapi-runtime</a><br/>
|
<a href='vapi-runtime/'>vapi-runtime</a><br/>
|
||||||
|
<a href='nsx-policy-python-sdk/'>nsx-policy-python-sdk</a><br/>
|
||||||
|
<a href='vmc-app-python-sdk/'>vmc-app-python-sdk</a><br/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
1
lib/nsx-policy-python-sdk/index.html
Normal file
1
lib/nsx-policy-python-sdk/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a href='nsx_policy_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl'>nsx_policy_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl</a><br />
|
Binary file not shown.
@ -1 +1 @@
|
|||||||
<a href='vapi_client_bindings-1.2.0-py2.py3-none-any.whl'>vapi_client_bindings-1.2.0-py2.py3-none-any.whl</a><br />
|
<a href='vapi_client_bindings-1.3.0-py2.py3-none-any.whl'>vapi_client_bindings-1.3.0-py2.py3-none-any.whl</a><br />
|
||||||
|
Binary file not shown.
Binary file not shown.
1
lib/vapi-common-client/index.html
Normal file
1
lib/vapi-common-client/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a href='vapi_common_client-2.9.0-py2.py3-none-any.whl'>vapi_common_client-2.9.0-py2.py3-none-any.whl</a><br />
|
Binary file not shown.
1
lib/vmc-app-python-sdk/index.html
Normal file
1
lib/vmc-app-python-sdk/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a href='vmc_app_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl'>vmc_app_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl</a><br />
|
Binary file not shown.
@ -1 +1 @@
|
|||||||
<a href='vmc_client_bindings-1.1.0-py2.py3-none-any.whl'>vmc_client_bindings-1.1.0-py2.py3-none-any.whl</a><br />
|
<a href='vmc_client_bindings-1.2.0-py2.py3-none-any.whl'>vmc_client_bindings-1.2.0-py2.py3-none-any.whl</a><br />
|
Binary file not shown.
Binary file not shown.
@ -1,8 +1,9 @@
|
|||||||
pyVmomi >= 6.5
|
pyVmomi >= 6.7
|
||||||
suds ; python_version < '3'
|
suds ; python_version < '3'
|
||||||
suds-jurko ; python_version >= '3.0'
|
suds-jurko ; python_version >= '3.0'
|
||||||
tabulate
|
tabulate
|
||||||
vapi-client-bindings == 1.2.0
|
vapi-client-bindings == 1.3.0
|
||||||
vmc-client-bindings == 1.1.0
|
vmc-client-bindings == 1.2.0
|
||||||
vapi-vmc-client
|
vapi-vmc-client
|
||||||
|
nsx-policy-python-sdk
|
||||||
|
vmc-app-python-sdk
|
||||||
|
18
samples/vsphere/vcenter/hvc/README.md
Normal file
18
samples/vsphere/vcenter/hvc/README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
This directory contains samples for managing vSphere hybrid linked mode:
|
||||||
|
|
||||||
|
The sample were tested against vSphere 6.7
|
||||||
|
|
||||||
|
### Hybrid Linked Mode link Create/List/Delete operations
|
||||||
|
Sample | Description
|
||||||
|
----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
links_client.py | Demonstrates link Create, List, Delete operations with a foreign platform service controller in a different SSO domain.
|
||||||
|
|
||||||
|
### Hybrid Linked Mode Administrator identity source group Add/Get/Remove operations
|
||||||
|
Sample | Description
|
||||||
|
----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------
|
||||||
|
administrator_client.py | Demonstrates Add, Get, Remove operations for a given SSO group in an Identity source to the CloudAdminGroup.
|
||||||
|
|
||||||
|
### Testbed Requirement:
|
||||||
|
- 2 vCenter Server in different SSO domains. The 2nd vCenter should be on version 6.5x
|
||||||
|
- The username being used to run the sample should have the HLM.Manage privilege.
|
||||||
|
- AdministratorClient sample requires the vCenter under test to have an Identity Source added and a local group called CloudAdminGroup to be created.
|
105
samples/vsphere/vcenter/hvc/administrator_client.py
Normal file
105
samples/vsphere/vcenter/hvc/administrator_client.py
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
* *******************************************************
|
||||||
|
* Copyright (c) VMware, Inc. 2018. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
* *******************************************************
|
||||||
|
*
|
||||||
|
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
|
||||||
|
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
|
||||||
|
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
|
||||||
|
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__author__ = 'VMware, Inc.'
|
||||||
|
__vcenter_version__ = '6.6.1'
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from com.vmware.vcenter.hvc.management_client import Administrators
|
||||||
|
from com.vmware.vmc.model_client import *
|
||||||
|
|
||||||
|
from samples.vsphere.common import vapiconnect
|
||||||
|
|
||||||
|
|
||||||
|
class AdministratorClient(object):
|
||||||
|
"""
|
||||||
|
Description: Demonstrates Add, Get, Remove operations for a given
|
||||||
|
Identity Source group to the CloudAdminGroup.
|
||||||
|
Step 1: Add the given group to CloudAdminGroup.
|
||||||
|
Step 2: Get all the groups in CloudAdminGroup.
|
||||||
|
Step 3: Remove the given group from CloudAdminGroup.
|
||||||
|
|
||||||
|
Sample Prerequisites:
|
||||||
|
- The sample needs an Identity source added to the vCenter apart from the
|
||||||
|
- default ones already added during vCenter deployment.
|
||||||
|
- The Identity source should contain one SSO group.
|
||||||
|
- The user invoking the API should have the HLM.Manage privilege.
|
||||||
|
-
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
parser.add_argument('-s', '--server',
|
||||||
|
required=True,
|
||||||
|
help='vSphere service IP to connect to')
|
||||||
|
|
||||||
|
parser.add_argument('-u', '--username',
|
||||||
|
required=True,
|
||||||
|
help='Username to use when connecting to vc')
|
||||||
|
|
||||||
|
parser.add_argument('-p', '--password',
|
||||||
|
required=True,
|
||||||
|
help='Password to use when connecting to vc')
|
||||||
|
|
||||||
|
parser.add_argument('--groupname',
|
||||||
|
required=True,
|
||||||
|
help='Name of the new group to be added.')
|
||||||
|
|
||||||
|
parser.add_argument('-v', '--skipverification',
|
||||||
|
action='store_true',
|
||||||
|
help='Verify server certificate when connecting to vc.')
|
||||||
|
|
||||||
|
parser.add_argument('-c', '--cleardata',
|
||||||
|
action='store_true',
|
||||||
|
help='Clean up after sample run')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Login to vCenter
|
||||||
|
stub_config = vapiconnect.connect(host=args.server,
|
||||||
|
user=args.username,
|
||||||
|
pwd=args.password)
|
||||||
|
# Create admin stub
|
||||||
|
self.admin_client = Administrators(stub_config)
|
||||||
|
self.cleanup = args.cleardata
|
||||||
|
self.groupname = args.groupname
|
||||||
|
|
||||||
|
def add_cloud_admin_group(self):
|
||||||
|
self.admin_client.add(self.groupname)
|
||||||
|
print('Group {} added successful.'.format(self.groupname))
|
||||||
|
|
||||||
|
def list_cloud_admin_group(self):
|
||||||
|
print('Getting all the groups under CloudAdminGroup.')
|
||||||
|
groups = self.admin_client.get()
|
||||||
|
for group in groups:
|
||||||
|
print('Group: {}'.format(group))
|
||||||
|
|
||||||
|
def delete_cloud_admin_group(self):
|
||||||
|
if self.cleanup:
|
||||||
|
self.admin_client.remove(self.groupname)
|
||||||
|
print('Group {} removed successful'.format(self.groupname))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
admin_client = AdministratorClient()
|
||||||
|
admin_client.add_cloud_admin_group()
|
||||||
|
admin_client.list_cloud_admin_group()
|
||||||
|
admin_client.delete_cloud_admin_group()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
132
samples/vsphere/vcenter/hvc/links_client.py
Normal file
132
samples/vsphere/vcenter/hvc/links_client.py
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
* *******************************************************
|
||||||
|
* Copyright (c) VMware, Inc. 2018. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
* *******************************************************
|
||||||
|
*
|
||||||
|
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
|
||||||
|
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
|
||||||
|
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
|
||||||
|
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__author__ = 'VMware, Inc.'
|
||||||
|
__vcenter_version__ = '6.6.1'
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from com.vmware.vcenter.hvc_client import Links
|
||||||
|
|
||||||
|
from samples.vsphere.common import vapiconnect
|
||||||
|
|
||||||
|
|
||||||
|
class LinksClient(object):
|
||||||
|
"""
|
||||||
|
Description: Demonstrates link Create, List, Delete operations with a
|
||||||
|
foreign platform service controller (PSC) on a different SSO domain.
|
||||||
|
- Step 1: Create a link with a foreign domain.
|
||||||
|
- Step 2: List all the linked domains.
|
||||||
|
- Step 3: Delete the existing link with the foreign domain.
|
||||||
|
|
||||||
|
Sample Prerequisites:
|
||||||
|
- The sample needs a second vCenter on a different SSO domain.
|
||||||
|
- The user invoking the API should have the HLM.Manage privilege.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
parser.add_argument('-s', '--server',
|
||||||
|
required=True,
|
||||||
|
help='vSphere service IP to connect to')
|
||||||
|
|
||||||
|
parser.add_argument('-u', '--username',
|
||||||
|
required=True,
|
||||||
|
help='Username to use when connecting to vc')
|
||||||
|
|
||||||
|
parser.add_argument('-p', '--password',
|
||||||
|
required=True,
|
||||||
|
help='Password to use when connecting to vc')
|
||||||
|
|
||||||
|
parser.add_argument('--foreignhost',
|
||||||
|
required=True,
|
||||||
|
help='FOREIGN PSC HOSTNAME.')
|
||||||
|
|
||||||
|
parser.add_argument('--foreignusername',
|
||||||
|
required=True,
|
||||||
|
help='Administrator username for the foreign domain. '
|
||||||
|
'Eg - Administrator')
|
||||||
|
|
||||||
|
parser.add_argument('--foreignpassword',
|
||||||
|
required=True,
|
||||||
|
help='Administrator password for the foreign domain.')
|
||||||
|
|
||||||
|
parser.add_argument('--foreigndomain',
|
||||||
|
required=True,
|
||||||
|
help='SSO Domain name for the foreign PSC. Eg - vsphere.local')
|
||||||
|
|
||||||
|
parser.add_argument('--foreignport',
|
||||||
|
required=False,
|
||||||
|
default='443',
|
||||||
|
help='SSO Domain name for the foreign PSC. Eg - vsphere.local')
|
||||||
|
|
||||||
|
parser.add_argument('-v', '--skipverification',
|
||||||
|
action='store_true',
|
||||||
|
help='OPTIONAL: Foreign HTTPS Port. Default: 443')
|
||||||
|
|
||||||
|
parser.add_argument('-c', '--cleardata',
|
||||||
|
action='store_true',
|
||||||
|
help='Clean up after sample run')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Login to vCenter
|
||||||
|
stub_config = vapiconnect.connect(host=args.server,
|
||||||
|
user=args.username,
|
||||||
|
pwd=args.password)
|
||||||
|
|
||||||
|
# Create links stub
|
||||||
|
self.links_client = Links(stub_config)
|
||||||
|
|
||||||
|
self.foreignhost = args.foreignhost
|
||||||
|
self.foreignusername = args.foreignusername
|
||||||
|
self.foreignpassword = args.foreignpassword
|
||||||
|
self.foreigndomain = args.foreigndomain
|
||||||
|
self.foreignport = args.foreignport
|
||||||
|
self.cleanup = args.cleardata
|
||||||
|
self.linked_domain_id = None
|
||||||
|
|
||||||
|
def create_link(self):
|
||||||
|
link_spec = self.links_client.CreateSpec(psc_hostname=self.foreignhost,
|
||||||
|
domain_name=self.foreigndomain,
|
||||||
|
username=self.foreignusername,
|
||||||
|
password=self.foreignpassword,
|
||||||
|
port=self.foreignport)
|
||||||
|
|
||||||
|
self.linked_domain_id = self.links_client.create(link_spec)
|
||||||
|
print('Link successful. Link ID - {}'.format(self.linked_domain_id))
|
||||||
|
|
||||||
|
def list_linked_domains(self):
|
||||||
|
print('Getting all the links.')
|
||||||
|
links = self.links_client.list()
|
||||||
|
for link in links:
|
||||||
|
print('Link ID: {}'.format(link))
|
||||||
|
|
||||||
|
def unlink(self):
|
||||||
|
if self.cleanup:
|
||||||
|
self.links_client.delete(self.linked_domain_id)
|
||||||
|
print('Link ({}) deleted successful.'.format(self.linked_domain_id))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
links_client = LinksClient()
|
||||||
|
links_client.create_link()
|
||||||
|
links_client.list_linked_domains()
|
||||||
|
links_client.unlink()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user