Skip to content

Commit

Permalink
Upgrade vmware extension to use AutoRest Python 5.6.0 (#2920)
Browse files Browse the repository at this point in the history
* private-cloud delete not working in mock env

* vendored from v5

* --override-client-name=AVSClient

* --use=@autorest/[email protected]
  • Loading branch information
cataggar authored Jan 25, 2021
1 parent bfd5ac0 commit 398effb
Show file tree
Hide file tree
Showing 88 changed files with 9,083 additions and 8,769 deletions.
11 changes: 10 additions & 1 deletion src/vmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ See [test_vmware_scenario.py](azext_vmware/tests/latest/test_vmware_scenario.py)
You can see if the extension is installed by running `az --version` or `az extension list`. You can remove the extension by running:
``` sh
az extension remove --name vmware
```
```

## AutoRust Code Generation
[AutoRest for Python](https://github.com/Azure/autorest.python) was used to generate the code in `azext_vmware\vendored_sdks` using:
``` powershell
rm ..\azure-cli-extensions\src\vmware\azext_vmware\vendored_sdks -Recurse
autorest --python --output-folder=..\azure-cli-extensions\src\vmware\azext_vmware\vendored_sdks --use=@autorest/[email protected] --tag=package-2020-03-20 --azure-arm=true --override-client-name=AVSClient specification\vmware\resource-manager\readme.md
```
It was run from a git clone of [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs).
2 changes: 1 addition & 1 deletion src/vmware/azext_vmware/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
def cf_vmware(cli_ctx, *_):

from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_vmware.vendored_sdks import AVSClient
from azext_vmware.vendored_sdks.avs_client import AVSClient
return get_mgmt_service_client(cli_ctx, AVSClient)
36 changes: 18 additions & 18 deletions src/vmware/azext_vmware/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def privatecloud_show(cmd, client: AVSClient, 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, Circuit, ManagementCluster, Sku
from azext_vmware.vendored_sdks.avs_client.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:
Expand All @@ -32,59 +32,59 @@ def privatecloud_create(cmd, client: AVSClient, resource_group_name, name, locat
cloud.vcenter_password = vcenter_password
if nsxt_password is not None:
cloud.nsxt_password = nsxt_password
return client.private_clouds.create_or_update(resource_group_name, name, cloud)
return client.private_clouds.begin_create_or_update(resource_group_name, name, cloud)


def privatecloud_update(cmd, client: AVSClient, resource_group_name, name, cluster_size=None, internet=None):
from azext_vmware.vendored_sdks.models import PrivateCloudUpdate, ManagementCluster
from azext_vmware.vendored_sdks.avs_client.models import PrivateCloudUpdate, ManagementCluster
private_cloud_update = PrivateCloudUpdate()
if cluster_size is not None:
private_cloud_update.management_cluster = ManagementCluster(cluster_size=cluster_size)
if internet is not None:
private_cloud_update.internet = internet
return client.private_clouds.update(resource_group_name, name, private_cloud_update)
return client.private_clouds.begin_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)
return client.private_clouds.begin_delete(resource_group_name, name)


def privatecloud_listadmincredentials(cmd, client: AVSClient, resource_group_name, private_cloud):
return client.private_clouds.list_admin_credentials(resource_group_name=resource_group_name, private_cloud_name=private_cloud)


def privatecloud_addidentitysource(cmd, client: AVSClient, resource_group_name, name, private_cloud, alias, domain, base_user_dn, base_group_dn, primary_server, username, password, secondary_server=None, ssl="Disabled"):
from azext_vmware.vendored_sdks.models import IdentitySource
from azext_vmware.vendored_sdks.avs_client.models import IdentitySource
pc = client.private_clouds.get(resource_group_name, private_cloud)
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.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)
return client.private_clouds.begin_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
from azext_vmware.vendored_sdks.avs_client.models import IdentitySource
pc = client.private_clouds.get(resource_group_name, private_cloud)
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.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)
return client.private_clouds.begin_create_or_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, sku, private_cloud, size, tags=[]):
from azext_vmware.vendored_sdks.models import Cluster, Sku
from azext_vmware.vendored_sdks.avs_client.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)
return client.clusters.begin_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 ClusterUpdate
from azext_vmware.vendored_sdks.avs_client.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)
return client.clusters.begin_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):
Expand All @@ -96,7 +96,7 @@ 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)
return client.clusters.begin_delete(resource_group_name=resource_group_name, private_cloud_name=private_cloud, cluster_name=name)


def check_quota_availability(cmd, client: AVSClient, location):
Expand All @@ -108,9 +108,9 @@ def check_trial_availability(cmd, client: AVSClient, location):


def authorization_create(cmd, client: AVSClient, resource_group_name, private_cloud, name):
from azext_vmware.vendored_sdks.models import ExpressRouteAuthorization
from azext_vmware.vendored_sdks.avs_client.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)
return client.authorizations.begin_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):
Expand All @@ -122,11 +122,11 @@ def authorization_show(cmd, client: AVSClient, resource_group_name, private_clou


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)
return client.authorizations.begin_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
from azext_vmware.vendored_sdks.avs_client.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)

Expand Down
Loading

0 comments on commit 398effb

Please sign in to comment.