1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-24 10:19:59 -05:00

Don't pass account link sddc config when no connected account available

This commit is contained in:
Tianhao He 2019-07-22 11:29:10 +08:00
parent c60d430a4f
commit 8799c5d6b5

View File

@ -112,8 +112,14 @@ class CreateDeleteSDDC(object):
print('\n# Example: Create a SDDC ({}) in org {}:'.format( print('\n# Example: Create a SDDC ({}) in org {}:'.format(
self.sddc_name, self.org_id)) self.sddc_name, self.org_id))
account_id = self.vmc_client.orgs.account_link.ConnectedAccounts.get( account_linking_config = None
self.org_id)[0].id
# Get connected accounts if any
account_ids = self.vmc_client.orgs.account_link.ConnectedAccounts.get(
self.org_id)
if len(account_ids) > 0 :
account_id = account_ids[0].id
vpc_map = self.vmc_client.orgs.account_link.CompatibleSubnets.get( vpc_map = self.vmc_client.orgs.account_link.CompatibleSubnets.get(
org=self.org_id, linked_account_id=account_id).vpc_map org=self.org_id, linked_account_id=account_id).vpc_map
@ -123,16 +129,16 @@ class CreateDeleteSDDC(object):
raise ValueError('No available subnet for region {}'.format( raise ValueError('No available subnet for region {}'.format(
self.region)) self.region))
account_linking_config = AccountLinkSddcConfig(
customer_subnet_ids=[customer_subnet_id],
connected_account_id=account_id)
sddc_config = AwsSddcConfig( sddc_config = AwsSddcConfig(
region=self.region, region=self.region,
name=self.sddc_name, name=self.sddc_name,
account_link_sddc_config=[ account_link_sddc_config=[account_linking_config] if account_linking_config else None,
AccountLinkSddcConfig(
customer_subnet_ids=[customer_subnet_id],
connected_account_id=account_id)
],
provider=os.environ.get('VMC_PROVIDER', SddcConfig.PROVIDER_AWS), provider=os.environ.get('VMC_PROVIDER', SddcConfig.PROVIDER_AWS),
num_hosts=1, num_hosts=4,
deployment_type=SddcConfig.DEPLOYMENT_TYPE_SINGLEAZ) deployment_type=SddcConfig.DEPLOYMENT_TYPE_SINGLEAZ)
try: try: