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

Commit

Permalink
require --sku for private-cloud create (#17)
Browse files Browse the repository at this point in the history
* require --sku for private-cloud create

* remove extra
  • Loading branch information
ctaggart authored Mar 6, 2020
1 parent 4149c8c commit e625791
Show file tree
Hide file tree
Showing 9 changed files with 466 additions and 237 deletions.
1 change: 1 addition & 0 deletions azext_vmware/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def load_arguments(self, _):

with self.argument_context('vmware private-cloud create') as c:
c.argument('name', options_list=['--name', '-n'], help='Name of the private cloud.')
c.argument('sku', help='The product SKU.')
c.argument('internet', help='Connectivity to internet. Specify "Enabled" or "Disabled".')
c.argument('vcenter_password', help='vCenter admin password.')
c.argument('nsxt_password', help='NSX-T Manager password.')
Expand Down
6 changes: 3 additions & 3 deletions azext_vmware/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def privatecloud_list(cmd, client: VirtustreamClient, resource_group_name=None):
def privatecloud_show(cmd, client: VirtustreamClient, resource_group_name, name):
return client.private_clouds.get(resource_group_name, name)

def privatecloud_create(cmd, client: VirtustreamClient, resource_group_name, name, location, 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
def privatecloud_create(cmd, client: VirtustreamClient, 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
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, properties=cloudProps, tags=tags)
cloud = PrivateCloud(location=location, sku=Sku(name=sku), properties=cloudProps, tags=tags)
if internet is not None:
cloud.properties.internet = internet
if vcenter_password is not None:
Expand Down
621 changes: 389 additions & 232 deletions azext_vmware/tests/latest/recordings/test_vmware.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion azext_vmware/tests/latest/test_vmware_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def test_vmware(self):
self.assertEqual(count, 0, 'private cloud count expected to be 0')

# create a private cloud
self.cmd('vmware private-cloud create -g {rg} -n {privatecloud} --location {loc} --cluster-size 4 --network-block 192.168.48.0/22 --nsxt-password 5rqdLj4GF3cePUe6( --vcenter-password UpfBXae9ZquZSDXk( ')
self.cmd('vmware private-cloud create -g {rg} -n {privatecloud} --location {loc} --sku he --cluster-size 4 --network-block 192.168.48.0/22 --nsxt-password 5rqdLj4GF3cePUe6( --vcenter-password UpfBXae9ZquZSDXk( ')

count = len(self.cmd('vmware private-cloud list -g {rg}').get_output_in_json())
self.assertEqual(count, 1, 'private cloud count expected to be 1')
Expand Down
3 changes: 3 additions & 0 deletions azext_vmware/vendored_sdks/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .circuit_py3 import Circuit
from .endpoints_py3 import Endpoints
from .identity_source_py3 import IdentitySource
from .sku_py3 import Sku
from .default_cluster_properties_py3 import DefaultClusterProperties
from .private_cloud_properties_py3 import PrivateCloudProperties
from .private_cloud_py3 import PrivateCloud
Expand All @@ -33,6 +34,7 @@
from .circuit import Circuit
from .endpoints import Endpoints
from .identity_source import IdentitySource
from .sku import Sku
from .default_cluster_properties import DefaultClusterProperties
from .private_cloud_properties import PrivateCloudProperties
from .private_cloud import PrivateCloud
Expand Down Expand Up @@ -60,6 +62,7 @@
'Circuit',
'Endpoints',
'IdentitySource',
'Sku',
'DefaultClusterProperties',
'PrivateCloudProperties',
'PrivateCloud',
Expand Down
4 changes: 4 additions & 0 deletions azext_vmware/vendored_sdks/models/private_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class PrivateCloud(TrackedResource):
:type location: str
:param tags: Resource tags
:type tags: dict[str, str]
:param sku: The private cloud SKU
:type sku: ~vendored_sdks.models.Sku
:param properties: The properties of a private cloud resource
:type properties: ~vendored_sdks.models.PrivateCloudProperties
"""
Expand All @@ -40,9 +42,11 @@ class PrivateCloud(TrackedResource):
'type': {'key': 'type', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'sku': {'key': 'sku', 'type': 'Sku'},
'properties': {'key': 'properties', 'type': 'PrivateCloudProperties'},
}

def __init__(self, **kwargs):
super(PrivateCloud, self).__init__(**kwargs)
self.sku = kwargs.get('sku', None)
self.properties = kwargs.get('properties', None)
6 changes: 5 additions & 1 deletion azext_vmware/vendored_sdks/models/private_cloud_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class PrivateCloud(TrackedResource):
:type location: str
:param tags: Resource tags
:type tags: dict[str, str]
:param sku: The private cloud SKU
:type sku: ~vendored_sdks.models.Sku
:param properties: The properties of a private cloud resource
:type properties: ~vendored_sdks.models.PrivateCloudProperties
"""
Expand All @@ -40,9 +42,11 @@ class PrivateCloud(TrackedResource):
'type': {'key': 'type', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'sku': {'key': 'sku', 'type': 'Sku'},
'properties': {'key': 'properties', 'type': 'PrivateCloudProperties'},
}

def __init__(self, *, location: str=None, tags=None, properties=None, **kwargs) -> None:
def __init__(self, *, location: str=None, tags=None, sku=None, properties=None, **kwargs) -> None:
super(PrivateCloud, self).__init__(location=location, tags=tags, **kwargs)
self.sku = sku
self.properties = properties
30 changes: 30 additions & 0 deletions azext_vmware/vendored_sdks/models/sku.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class Sku(Model):
"""The resource model definition representing SKU.
All required parameters must be populated in order to send to Azure.
:param name: Required. The name of the SKU.
:type name: str
"""

_validation = {
'name': {'required': True},
}

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
}

def __init__(self, **kwargs):
super(Sku, self).__init__(**kwargs)
self.name = kwargs.get('name', None)
30 changes: 30 additions & 0 deletions azext_vmware/vendored_sdks/models/sku_py3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class Sku(Model):
"""The resource model definition representing SKU.
All required parameters must be populated in order to send to Azure.
:param name: Required. The name of the SKU.
:type name: str
"""

_validation = {
'name': {'required': True},
}

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
}

def __init__(self, *, name: str, **kwargs) -> None:
super(Sku, self).__init__(**kwargs)
self.name = name

0 comments on commit e625791

Please sign in to comment.