Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
update to the 2020-03-20 API (#31)
Browse files Browse the repository at this point in the history
* generate python from latest 2020-03-20-preview API

* properties are flattened

* added identity-source and hcx-enterprise-site sub-commands

* updated to latest spec

* added vmware authorization, undid vmware identity-source

* fix param help

* update to latest spec which remove read-only ids in private cloud

* AVSClient

* restore commands
lost in 7c2a62e

* remove PrivateCloudProperties

* authorization create and hcxexterprisesite_create should now send {}

* remove async in tests

* add workaround for autorest generation of empty objects

* switch to CloudError

* use type: object to set empty body

* schema update for checkTrialAvailability

* GA spec drops "-preview"

* patch updates

* locations.check_quota_availability

* use PrivateCloudUpdate

* added properties back in for updates

* add sku to Cluster

* listadmincredentials uses -c for private-cloud

* remove host & port from default vcr match_on

* comment out listadmincredentials

* do not forget query

* size not an arg in hcx create

* move hcxCloudManager to endpoints

* add hcx-enterprise-site tests

* spelling correction

* add tags to PrivateCloudUpdate

* add vmware location checktrialavailability

* bump to 0.7.0
  • Loading branch information
cataggar authored Jul 21, 2020
1 parent 8251f6c commit 96a1429
Show file tree
Hide file tree
Showing 60 changed files with 7,888 additions and 2,370 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ swagger.resourceprovider.yaml
swagger.json
examples/
errors.txt
/*.json

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ verify_ssl = true

[dev-packages]
pylint = "*"
colorama = "*"
azure-cli-core = "*"
# https://github.com/Azure/azure-cli-dev-tools/releases
azdev = "==0.1.13"

# [packages]
# azure-cli = "*"
# azure-cli-testsdk = { git = "https://github.com/Azure/azure-cli", subdirectory = "src/azure-cli-testsdk" }

# [requires]
# python_version = "3.7"
226 changes: 122 additions & 104 deletions Pipfile.lock

Large diffs are not rendered by default.

72 changes: 61 additions & 11 deletions azext_vmware/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
short-summary: Commands to manage clusters in a private cloud.
"""

helps['vmware authorization'] = """
type: group
short-summary: Commands to manage the authorizations of an ExpressRoute Circuit for a private cloud.
"""

helps['vmware hcx-enterprise-site'] = """
type: group
short-summary: Commands to manage HCX Enterprise Sites in a private cloud.
"""

helps['vmware location'] = """
type: group
short-summary: Commands to check availability by location.
"""

helps['vmware cluster create'] = """
type: command
short-summary: Create a cluster in a private cloud. The maximum number of clusters is 4.
Expand All @@ -47,11 +62,6 @@
short-summary: Update a cluster in a private cloud.
"""

helps['vmware private-cloud addauthorization'] = """
type: command
short-summary: Add an authorization to the ExpressRoute for a private cloud.
"""

helps['vmware private-cloud addidentitysource'] = """
type: command
short-summary: Add a vCenter Single Sign On Identity Source to a private cloud.
Expand All @@ -67,11 +77,6 @@
short-summary: Delete a private cloud.
"""

helps['vmware private-cloud deleteauthorization'] = """
type: command
short-summary: Delete an authorization to the ExpressRoute for a private cloud.
"""

helps['vmware private-cloud deleteidentitysource'] = """
type: command
short-summary: Delete a vCenter Single Sign On Identity Source for a private cloud.
Expand All @@ -97,7 +102,52 @@
short-summary: Update a private cloud.
"""

helps['vmware checkquotaavailability'] = """
helps['vmware authorization create'] = """
type: command
short-summary: Create an authorization for an ExpressRoute Circuit in a private cloud.
"""

helps['vmware authorization list'] = """
type: command
short-summary: List authorizations for an ExpressRoute Circuit in a private cloud.
"""

helps['vmware authorization show'] = """
type: command
short-summary: Show details of an authorization for an ExpressRoute Circuit in a private cloud.
"""

helps['vmware authorization delete'] = """
type: command
short-summary: Delete an authorization for an ExpressRoute Circuit in a private cloud.
"""

helps['vmware hcx-enterprise-site create'] = """
type: command
short-summary: Create an HCX Enterprise Site in a private cloud.
"""

helps['vmware hcx-enterprise-site list'] = """
type: command
short-summary: List HCX Enterprise Sites in a private cloud.
"""

helps['vmware hcx-enterprise-site show'] = """
type: command
short-summary: Show details of an HCX Enterprise Site in a private cloud.
"""

helps['vmware hcx-enterprise-site delete'] = """
type: command
short-summary: Delete an HCX Enterprise Site in a private cloud.
"""

helps['vmware location checkquotaavailability'] = """
type: command
short-summary: Return quota for subscription by region.
"""

helps['vmware location checktrialavailability'] = """
type: command
short-summary: Return trial status for subscription by region.
"""
11 changes: 6 additions & 5 deletions azext_vmware/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def load_arguments(self, _):

with self.argument_context('vmware cluster') as c:
c.argument('name', options_list=['--name', '-n'], help='Name of the cluster.')
c.argument('sku', help='The product SKU.')
c.argument('size', help='Number of hosts for the cluster. Minimum of 3 and a maximum of 16.')

with self.argument_context('vmware private-cloud create') as c:
Expand All @@ -40,10 +41,7 @@ def load_arguments(self, _):
with self.argument_context('vmware private-cloud delete') as c:
c.argument('name', options_list=['--name', '-n'], help='Name of the private cloud.')

with self.argument_context('vmware private-cloud addauthorization') as c:
c.argument('name', options_list=['--name', '-n'], help='Name of the authorization.')

with self.argument_context('vmware private-cloud deleteauthorization') as c:
with self.argument_context('vmware authorization') as c:
c.argument('name', options_list=['--name', '-n'], help='Name of the authorization.')

with self.argument_context('vmware private-cloud addidentitysource') as c:
Expand All @@ -65,4 +63,7 @@ def load_arguments(self, _):

with self.argument_context('vmware private-cloud update') as c:
c.argument('name', options_list=['--name', '-n'], help='Name of the private cloud.')
c.argument('internet', help='Connectivity to internet. Specify "Enabled" or "Disabled".')
c.argument('internet', help='Connectivity to internet. Specify "Enabled" or "Disabled".')

with self.argument_context('vmware hcx-enterprise-site') as c:
c.argument('name', options_list=['--name', '-n'], help='The name of the HCX Enterprise Site.')
19 changes: 15 additions & 4 deletions azext_vmware/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def load_command_table(self, _):
g.custom_command('delete', 'privatecloud_delete')
g.custom_command('listadmincredentials', 'privatecloud_listadmincredentials')

g.custom_command('addauthorization', 'privatecloud_addauthorization')
g.custom_command('deleteauthorization', 'privatecloud_deleteauthorization')
g.custom_command('addidentitysource', 'privatecloud_addidentitysource')
g.custom_command('deleteidentitysource', 'privatecloud_deleteidentitysource')

Expand All @@ -32,5 +30,18 @@ def load_command_table(self, _):
g.custom_command('delete', 'cluster_delete')
g.custom_command('show', 'cluster_show')

with self.command_group('vmware', vmware_sdk, client_factory=cf_vmware) as g:
g.custom_command('checkquotaavailability', 'check_quota_availability')
with self.command_group('vmware authorization', vmware_sdk, client_factory=cf_vmware) as g:
g.custom_command('create', 'authorization_create')
g.custom_command('list', 'authorization_list')
g.custom_command('delete', 'authorization_delete')
g.custom_command('show', 'authorization_show')

with self.command_group('vmware hcx-enterprise-site', vmware_sdk, client_factory=cf_vmware) as g:
g.custom_command('create', 'hcxenterprisesite_create')
g.custom_command('list', 'hcxenterprisesite_list')
g.custom_command('delete', 'hcxenterprisesite_delete')
g.custom_command('show', 'hcxenterprisesite_show')

with self.command_group('vmware location', vmware_sdk, client_factory=cf_vmware) as g:
g.custom_command('checkquotaavailability', 'check_quota_availability')
g.custom_command('checktrialavailability', 'check_trial_availability')
100 changes: 57 additions & 43 deletions azext_vmware/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ def privatecloud_show(cmd, client: AVSClient, resource_group_name, name):
return client.private_clouds.get(resource_group_name, name)

def privatecloud_create(cmd, client: AVSClient, resource_group_name, name, location, sku, cluster_size, network_block, circuit_primary_subnet=None, circuit_secondary_subnet=None, internet=None, vcenter_password=None, nsxt_password=None, tags=[]):
from azext_vmware.vendored_sdks.models import PrivateCloud, PrivateCloudProperties, Circuit, DefaultClusterProperties, Sku
from azext_vmware.vendored_sdks.models import PrivateCloud, Circuit, ManagementCluster, Sku
if circuit_primary_subnet is not None or circuit_secondary_subnet is not None:
circuit = Circuit(primary_subnet=circuit_primary_subnet, secondary_subnet=circuit_secondary_subnet)
else:
circuit = None
clusterProps = DefaultClusterProperties(cluster_size=cluster_size)
cloudProps = PrivateCloudProperties(circuit=circuit, cluster=clusterProps, network_block=network_block)
cloud = PrivateCloud(location=location, sku=Sku(name=sku), properties=cloudProps, tags=tags)
management_cluster = ManagementCluster(cluster_size=cluster_size)
cloud = PrivateCloud(location=location, sku=Sku(name=sku), circuit=circuit, management_cluster=management_cluster, network_block=network_block, tags=tags)
if internet is not None:
cloud.properties.internet = internet
cloud.internet = internet
if vcenter_password is not None:
cloud.properties.vcenter_password = vcenter_password
cloud.vcenter_password = vcenter_password
if nsxt_password is not None:
cloud.properties.nsxt_password = nsxt_password
cloud.nsxt_password = nsxt_password
return client.private_clouds.create_or_update(resource_group_name, name, cloud)

def privatecloud_update(cmd, client: AVSClient, resource_group_name, name, cluster_size=None, internet=None):
cloud = privatecloud_show(cmd, client, resource_group_name, name)
from azext_vmware.vendored_sdks.models import PrivateCloudUpdate, ManagementCluster
private_cloud_update = PrivateCloudUpdate()
if cluster_size is not None:
cloud.properties.cluster.cluster_size = cluster_size
private_cloud_update.management_cluster = ManagementCluster(cluster_size=cluster_size)
if internet is not None:
cloud.properties.internet = internet
return client.private_clouds.update(resource_group_name, name, cloud)
private_cloud_update.internet = internet
return client.private_clouds.update(resource_group_name, name, private_cloud_update)

def privatecloud_delete(cmd, client: AVSClient, resource_group_name, name):
return client.private_clouds.delete(resource_group_name, name)
Expand All @@ -52,49 +52,29 @@ def privatecloud_addidentitysource(cmd, client: AVSClient, resource_group_name,
identitysource = IdentitySource(name=name, alias=alias, domain=domain, base_user_dn=base_user_dn, base_group_dn=base_group_dn, primary_server=primary_server, ssl=ssl, username=username, password=password)
if secondary_server is not None:
identitysource.secondary_server = secondary_server
pc.properties.identity_sources.append(identitysource)
return client.private_clouds.update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, private_cloud=pc)
pc.identity_sources.append(identitysource)
return client.private_clouds.create_or_update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, private_cloud=pc)

def privatecloud_deleteidentitysource(cmd, client: AVSClient, resource_group_name, name, private_cloud, alias, domain):
from azext_vmware.vendored_sdks.models import IdentitySource
pc = client.private_clouds.get(resource_group_name, private_cloud)
found = next((ids for ids in pc.properties.identity_sources
found = next((ids for ids in pc.identity_sources
if ids.name == name and ids.alias == alias and ids.domain == domain), None)
if found:
pc.properties.identity_sources.remove(found)
return client.private_clouds.update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, private_cloud=pc)
pc.identity_sources.remove(found)
return client.private_clouds.create_or_update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, private_cloud=pc)
else:
return pc

def privatecloud_addauthorization(cmd, client: AVSClient, resource_group_name, private_cloud, name):
from azext_vmware.vendored_sdks.models import ExpressRouteAuthorization
pc = client.private_clouds.get(resource_group_name, private_cloud)
auth = ExpressRouteAuthorization(name=name)
pc.properties.circuit.authorizations.append(auth)
return client.private_clouds.update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, private_cloud=pc)

def privatecloud_deleteauthorization(cmd, client: AVSClient, resource_group_name, private_cloud, name):
from azext_vmware.vendored_sdks.models import ExpressRouteAuthorization
pc = client.private_clouds.get(resource_group_name, private_cloud)
found = next((auth for auth in pc.properties.circuit.authorizations
if auth.name == name), None)
if found:
pc.properties.circuit.authorizations.remove(found)
return client.private_clouds.update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, private_cloud=pc)
else:
return pc

def cluster_create(cmd, client: AVSClient, resource_group_name, name, private_cloud, size, tags=[]):
from azext_vmware.vendored_sdks.models import Cluster, ClusterProperties
clusterProps = ClusterProperties(cluster_size=size)
cluster = Cluster(properties=clusterProps, tags=tags)
def cluster_create(cmd, client: AVSClient, resource_group_name, name, sku, private_cloud, size, tags=[]):
from azext_vmware.vendored_sdks.models import Cluster, Sku
cluster = Cluster(sku=Sku(name=sku), cluster_size=size)
return client.clusters.create_or_update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, cluster_name=name, cluster=cluster)

def cluster_update(cmd, client: AVSClient, resource_group_name, name, private_cloud, size, tags=[]):
from azext_vmware.vendored_sdks.models import Cluster, ClusterProperties
clusterProps = ClusterProperties(cluster_size=size)
cluster = Cluster(properties=clusterProps, tags=tags)
return client.clusters.update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, cluster_name=name, cluster=cluster)
from azext_vmware.vendored_sdks.models import ClusterUpdate
cluster_update = ClusterUpdate(cluster_size=size)
return client.clusters.update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, cluster_name=name, cluster_update=cluster_update)

def cluster_list(cmd, client: AVSClient, resource_group_name, private_cloud):
return client.clusters.list(resource_group_name=resource_group_name, private_cloud_name=private_cloud)
Expand All @@ -105,5 +85,39 @@ def cluster_show(cmd, client: AVSClient, resource_group_name, private_cloud, nam
def cluster_delete(cmd, client: AVSClient, resource_group_name, private_cloud, name):
return client.clusters.delete(resource_group_name=resource_group_name, private_cloud_name=private_cloud, cluster_name=name)


def check_quota_availability(cmd, client: AVSClient, location):
return client.check_quota_availability(location)
return client.locations.check_quota_availability(location)

def check_trial_availability(cmd, client: AVSClient, location):
return client.locations.check_trial_availability(location)


def authorization_create(cmd, client: AVSClient, resource_group_name, private_cloud, name):
from azext_vmware.vendored_sdks.models import ExpressRouteAuthorization
authorization = ExpressRouteAuthorization()
return client.authorizations.create_or_update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, authorization_name=name, authorization=authorization)

def authorization_list(cmd, client: AVSClient, resource_group_name, private_cloud):
return client.authorizations.list(resource_group_name=resource_group_name, private_cloud_name=private_cloud)

def authorization_show(cmd, client: AVSClient, resource_group_name, private_cloud, name):
return client.authorizations.get(resource_group_name=resource_group_name, private_cloud_name=private_cloud, authorization_name=name)

def authorization_delete(cmd, client: AVSClient, resource_group_name, private_cloud, name):
return client.authorizations.delete(resource_group_name=resource_group_name, private_cloud_name=private_cloud, authorization_name=name)


def hcxenterprisesite_create(cmd, client: AVSClient, resource_group_name, private_cloud, name):
from azext_vmware.vendored_sdks.models import HcxEnterpriseSite
hcx_enterprise_site = HcxEnterpriseSite()
return client.hcx_enterprise_sites.create_or_update(resource_group_name=resource_group_name, private_cloud_name=private_cloud, hcx_enterprise_site_name=name, hcx_enterprise_site=hcx_enterprise_site)

def hcxenterprisesite_list(cmd, client: AVSClient, resource_group_name, private_cloud):
return client.hcx_enterprise_sites.list(resource_group_name=resource_group_name, private_cloud_name=private_cloud)

def hcxenterprisesite_show(cmd, client: AVSClient, resource_group_name, private_cloud, name):
return client.hcx_enterprise_sites.get(resource_group_name=resource_group_name, private_cloud_name=private_cloud, hcx_enterprise_site_name=name)

def hcxenterprisesite_delete(cmd, client: AVSClient, resource_group_name, private_cloud, name):
return client.hcx_enterprise_sites.delete(resource_group_name=resource_group_name, private_cloud_name=private_cloud, hcx_enterprise_site_name=name)
Loading

0 comments on commit 96a1429

Please sign in to comment.