Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[connectedvmware] Added tags support and fix know bugs. #4264

Merged
merged 8 commits into from
Jan 4, 2022
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