Skip to content

Commit

Permalink
[connectedvmware] Added tags support and fix know bugs. (#4264)
Browse files Browse the repository at this point in the history
* Added tags support and fix know bugs.

* Addressed reviewer comment.

* Update src/connectedvmware/azext_connectedvmware/tests/latest/test_connectedvmware_scenario.py

* Update src/connectedvmware/azext_connectedvmware/tests/latest/test_arcvmware_scenario.py

* Addressed reviewer review comment.

* Removed test_arcvmware_scenario.py file.

* Run test to generate latest recording file.

Co-authored-by: Santosh Mishra <sanmishra@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
  • Loading branch information
3 people authored Jan 4, 2022
1 parent b308529 commit 3bcc340
Show file tree
Hide file tree
Showing 5 changed files with 9,804 additions and 952 deletions.
6 changes: 6 additions & 0 deletions src/connectedvmware/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

0.1.6
++++++
* Fix vm update
* Fix inventory item show
* Add support for tagging

0.1.5
++++++
* Fixed inventory item id issue.
Expand Down
28 changes: 23 additions & 5 deletions src/connectedvmware/azext_connectedvmware/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def connect_vcenter(
port=port,
extended_location=extended_location,
credentials=username_creds,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -206,14 +207,14 @@ def show_inventory_item(
inventory_item
):

return client.get(resource_group_name, vcenter, inventory_item)
return client.get(resource_group_name, vcenter.split('/')[-1], inventory_item.split('/')[-1])


def list_inventory_item(
client: InventoryItemsOperations, resource_group_name, vcenter
):

return client.list_by_v_center(resource_group_name, vcenter)
return client.list_by_v_center(resource_group_name, vcenter.split('/')[-1])


# endregion
Expand Down Expand Up @@ -283,13 +284,15 @@ def create_resource_pool(
location=location,
extended_location=extended_location,
inventory_item_id=inventory_item_id,
tags=tags
)
else:
resource_pool = ResourcePool(
location=location,
extended_location=extended_location,
v_center_id=vcenter_id,
mo_ref_id=mo_ref_id,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -391,13 +394,15 @@ def create_cluster(
location=location,
extended_location=extended_location,
inventory_item_id=inventory_item_id,
tags=tags
)
else:
cluster = Cluster(
location=location,
extended_location=extended_location,
v_center_id=vcenter_id,
mo_ref_id=mo_ref_id,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -499,13 +504,15 @@ def create_datastore(
location=location,
extended_location=extended_location,
inventory_item_id=inventory_item_id,
tags=tags
)
else:
datastore = Datastore(
location=location,
extended_location=extended_location,
v_center_id=vcenter_id,
mo_ref_id=mo_ref_id,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -607,13 +614,15 @@ def create_host(
location=location,
extended_location=extended_location,
inventory_item_id=inventory_item_id,
tags=tags
)
else:
host = Host(
location=location,
extended_location=extended_location,
v_center_id=vcenter_id,
mo_ref_id=mo_ref_id,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -715,13 +724,15 @@ def create_virtual_network(
location=location,
extended_location=extended_location,
inventory_item_id=inventory_item_id,
tags=tags
)
else:
virtual_network = VirtualNetwork(
location=location,
extended_location=extended_location,
v_center_id=vcenter_id,
mo_ref_id=mo_ref_id,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -829,13 +840,15 @@ def create_vm_template(
location=location,
extended_location=extended_location,
inventory_item_id=inventory_item_id,
tags=tags
)
else:
vm_template = VirtualMachineTemplate(
location=location,
extended_location=extended_location,
v_center_id=vcenter_id,
mo_ref_id=mo_ref_id,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -1071,6 +1084,7 @@ def create_vm(
os_profile=os_profile,
network_profile=network_profile,
storage_profile=storage_profile,
tags=tags
)
else:
vm = VirtualMachine(
Expand All @@ -1082,6 +1096,7 @@ def create_vm(
os_profile=os_profile,
network_profile=network_profile,
storage_profile=storage_profile,
tags=tags
)

return sdk_no_wait(
Expand Down Expand Up @@ -1121,14 +1136,17 @@ def update_vm(
num_cores_per_socket=num_cores_per_socket,
)

vm_update = VirtualMachineUpdate(hardware_profile=hardware_profile)
vm_update = VirtualMachineUpdate(
hardware_profile=hardware_profile,
tags=tags
)

return sdk_no_wait(
no_wait,
client.begin_update,
resource_group_name,
resource_name,
vm_update,
tags,
vm_update
)


Expand Down
Loading

0 comments on commit 3bcc340

Please sign in to comment.