diff --git a/README.md b/README.md index 2e38aa1f..cbff796a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ ## Table of Contents - [Abstract](#abstract) - [Supported vCenter Releases](#supported-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) - [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. 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 The VMware Cloud on AWS API and samples are currently available as a preview and are subject to change in the future. diff --git a/doc/client.zip b/doc/client.zip index ce1674c2..b170410d 100644 Binary files a/doc/client.zip and b/doc/client.zip differ diff --git a/doc/nsx_policy_python_sdk-2.2.0.0.0.15150318-doc.zip b/doc/nsx_policy_python_sdk-2.2.0.0.0.15150318-doc.zip new file mode 100644 index 00000000..e8cc3235 Binary files /dev/null and b/doc/nsx_policy_python_sdk-2.2.0.0.0.15150318-doc.zip differ diff --git a/doc/nsx_policy_python_sdk-2.2.0.0.0.15184434-doc.zip b/doc/nsx_policy_python_sdk-2.2.0.0.0.15184434-doc.zip new file mode 100644 index 00000000..d9127a0b Binary files /dev/null and b/doc/nsx_policy_python_sdk-2.2.0.0.0.15184434-doc.zip differ diff --git a/doc/vmc.zip b/doc/vmc.zip index 7d092949..4b00216d 100644 Binary files a/doc/vmc.zip and b/doc/vmc.zip differ diff --git a/doc/vmc_app_python_sdk-2.2.0.0.0.15150318-doc.zip b/doc/vmc_app_python_sdk-2.2.0.0.0.15150318-doc.zip new file mode 100644 index 00000000..f8a71d77 Binary files /dev/null and b/doc/vmc_app_python_sdk-2.2.0.0.0.15150318-doc.zip differ diff --git a/doc/vmc_app_python_sdk-2.2.0.0.0.15184434-doc.zip b/doc/vmc_app_python_sdk-2.2.0.0.0.15184434-doc.zip new file mode 100644 index 00000000..28769f13 Binary files /dev/null and b/doc/vmc_app_python_sdk-2.2.0.0.0.15184434-doc.zip differ diff --git a/lib/README.md b/lib/README.md index e7527cd4..d27852c6 100644 --- a/lib/README.md +++ b/lib/README.md @@ -8,3 +8,6 @@ vapi_runtime | vAPI runtime responsible for serialization/ vapi_vmc_client | Handles VMC CSP authentication process vapi_client_bindings | Client stubs for vSphere Automation 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 diff --git a/lib/index.html b/lib/index.html index b62d2eff..4e0bc08d 100644 --- a/lib/index.html +++ b/lib/index.html @@ -6,5 +6,7 @@ vapi-client-bindings
vmc-client-bindings
vapi-runtime
+nsx-policy-python-sdk
+vmc-app-python-sdk
diff --git a/lib/nsx-policy-python-sdk/index.html b/lib/nsx-policy-python-sdk/index.html new file mode 100644 index 00000000..1677e1fb --- /dev/null +++ b/lib/nsx-policy-python-sdk/index.html @@ -0,0 +1 @@ +nsx_policy_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl
diff --git a/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl b/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl new file mode 100644 index 00000000..2b924bda Binary files /dev/null and b/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl differ diff --git a/lib/vapi-client-bindings/index.html b/lib/vapi-client-bindings/index.html index 0183803b..dff4667d 100644 --- a/lib/vapi-client-bindings/index.html +++ b/lib/vapi-client-bindings/index.html @@ -1 +1 @@ -vapi_client_bindings-1.2.0-py2.py3-none-any.whl
+vapi_client_bindings-1.3.0-py2.py3-none-any.whl
diff --git a/lib/vapi-client-bindings/vapi_client_bindings-1.1.0-py2.py3-none-any.whl b/lib/vapi-client-bindings/vapi_client_bindings-1.1.0-py2.py3-none-any.whl deleted file mode 100644 index e6ba2c5d..00000000 Binary files a/lib/vapi-client-bindings/vapi_client_bindings-1.1.0-py2.py3-none-any.whl and /dev/null differ diff --git a/lib/vapi-client-bindings/vapi_client_bindings-1.2.0-py2.py3-none-any.whl b/lib/vapi-client-bindings/vapi_client_bindings-1.3.0-py2.py3-none-any.whl similarity index 87% rename from lib/vapi-client-bindings/vapi_client_bindings-1.2.0-py2.py3-none-any.whl rename to lib/vapi-client-bindings/vapi_client_bindings-1.3.0-py2.py3-none-any.whl index 7214d5b5..107bf066 100644 Binary files a/lib/vapi-client-bindings/vapi_client_bindings-1.2.0-py2.py3-none-any.whl and b/lib/vapi-client-bindings/vapi_client_bindings-1.3.0-py2.py3-none-any.whl differ diff --git a/lib/vapi-common-client/index.html b/lib/vapi-common-client/index.html new file mode 100644 index 00000000..ca97eaba --- /dev/null +++ b/lib/vapi-common-client/index.html @@ -0,0 +1 @@ +vapi_common_client-2.9.0-py2.py3-none-any.whl
diff --git a/lib/vapi-common-client/vapi_common_client-2.9.0-py2.py3-none-any.whl b/lib/vapi-common-client/vapi_common_client-2.9.0-py2.py3-none-any.whl new file mode 100644 index 00000000..98f0f6f0 Binary files /dev/null and b/lib/vapi-common-client/vapi_common_client-2.9.0-py2.py3-none-any.whl differ diff --git a/lib/vmc-app-python-sdk/index.html b/lib/vmc-app-python-sdk/index.html new file mode 100644 index 00000000..9147f52c --- /dev/null +++ b/lib/vmc-app-python-sdk/index.html @@ -0,0 +1 @@ +vmc_app_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl
diff --git a/lib/vmc-app-python-sdk/vmc_app_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl b/lib/vmc-app-python-sdk/vmc_app_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl new file mode 100644 index 00000000..7bc88b24 Binary files /dev/null and b/lib/vmc-app-python-sdk/vmc_app_python_sdk-2.2.0.0.0.15184434-py2.py3-none-any.whl differ diff --git a/lib/vmc-client-bindings/index.html b/lib/vmc-client-bindings/index.html index 319a3dfa..331028fe 100644 --- a/lib/vmc-client-bindings/index.html +++ b/lib/vmc-client-bindings/index.html @@ -1 +1 @@ -vmc_client_bindings-1.1.0-py2.py3-none-any.whl
\ No newline at end of file +vmc_client_bindings-1.2.0-py2.py3-none-any.whl
\ No newline at end of file diff --git a/lib/vmc-client-bindings/vmc_client_bindings-1.1.0-py2.py3-none-any.whl b/lib/vmc-client-bindings/vmc_client_bindings-1.1.0-py2.py3-none-any.whl deleted file mode 100644 index 3005ceb8..00000000 Binary files a/lib/vmc-client-bindings/vmc_client_bindings-1.1.0-py2.py3-none-any.whl and /dev/null differ diff --git a/lib/vmc-client-bindings/vmc_client_bindings-1.2.0-py2.py3-none-any.whl b/lib/vmc-client-bindings/vmc_client_bindings-1.2.0-py2.py3-none-any.whl new file mode 100644 index 00000000..e7e81e3f Binary files /dev/null and b/lib/vmc-client-bindings/vmc_client_bindings-1.2.0-py2.py3-none-any.whl differ diff --git a/requirements.txt b/requirements.txt index fbd75ce2..02c95c89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ -pyVmomi >= 6.5 +pyVmomi >= 6.7 suds ; python_version < '3' suds-jurko ; python_version >= '3.0' tabulate -vapi-client-bindings == 1.2.0 -vmc-client-bindings == 1.1.0 +vapi-client-bindings == 1.3.0 +vmc-client-bindings == 1.2.0 vapi-vmc-client - +nsx-policy-python-sdk +vmc-app-python-sdk diff --git a/samples/vmc/networks/expose_public_ip.py b/samples/vmc/networks/expose_public_ip.py index 2b525500..1ee64bd1 100644 --- a/samples/vmc/networks/expose_public_ip.py +++ b/samples/vmc/networks/expose_public_ip.py @@ -161,7 +161,7 @@ class ExposePublicIP(object): edge_id=self.edge_id, firewall_rules=FirewallRules([self.nfwr])) - print('# New firewall rule "{}" is added'.format(self.fw_rule_name)) + print(' # New firewall rule "{}" is added'.format(self.fw_rule_name)) def create_net_rule(self): @@ -185,7 +185,7 @@ class ExposePublicIP(object): edge_id=self.edge_id, nat_rules=NatRules([rule])) - print('# New NAT rule "{}" is added'.format(self.nat_rule_description)) + print(' # New NAT rule "{}" is added'.format(self.nat_rule_description)) def cleanup(self): if self.cleardata: diff --git a/samples/vsphere/vcenter/hvc/README.md b/samples/vsphere/vcenter/hvc/README.md new file mode 100644 index 00000000..0c5ebcd5 --- /dev/null +++ b/samples/vsphere/vcenter/hvc/README.md @@ -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. \ No newline at end of file diff --git a/samples/vsphere/vcenter/hvc/administrator_client.py b/samples/vsphere/vcenter/hvc/administrator_client.py new file mode 100644 index 00000000..938d2036 --- /dev/null +++ b/samples/vsphere/vcenter/hvc/administrator_client.py @@ -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() diff --git a/samples/vsphere/vcenter/hvc/links_client.py b/samples/vsphere/vcenter/hvc/links_client.py new file mode 100644 index 00000000..e743ac45 --- /dev/null +++ b/samples/vsphere/vcenter/hvc/links_client.py @@ -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()