Skip to content

Commit a0b1447

Browse files
committed
Merge pull request #113 from QualiSystems/feature/alex_59_app_orchestration
fixed bug in appTemplates xml
2 parents 5b4b45f + 2753ef1 commit a0b1447

5 files changed

Lines changed: 27 additions & 24 deletions

File tree

vCenterShell/bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def __init__(self):
7070
# Virtual Switch Revoke
7171
virtual_switch_disconnect_command = \
7272
VirtualSwitchToMachineDisconnectCommand(py_vmomi_service,
73-
cloudshell_data_retriever_service,
74-
synchronous_task_waiter,
73+
resource_connection_details_retriever,
74+
virtual_machine_port_group_configurer,
7575
vc_data_model.default_network)
7676

7777
destroy_virtual_machine_command = DestroyVirtualMachineCommand(py_vmomi_service,

vCenterShell/command_executer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def disconnect(self):
8181
def destroy(self):
8282
# get command parameters from the environment
8383
uuid = self.qualipy_helpers.get_user_param('VM_UUID')
84-
resource = self.qualipy_helpers.get_resource_context_details()
84+
resource_fullname = self.qualipy_helpers.get_user_param('RESOURCE_FULLNAME')
8585

8686
# prepare for execute command
8787
connection_details = self.connection_retriever.connection_details()
@@ -91,7 +91,7 @@ def destroy(self):
9191
connection_details,
9292
self.destroyVirtualMachineCommand.destroy,
9393
uuid,
94-
resource.fullname)
94+
resource_fullname)
9595

9696
def deploy_from_template(self):
9797
# get command parameters from the environment

vCenterShell/commands/destroy_vm.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ def __init__(self, pv_service, resource_remover, disconnector):
1616
self.resource_remover = resource_remover
1717
self.disconnector = disconnector
1818

19-
def destroy(self, si, uuid, resource_full_name):
19+
def destroy(self, si, vm_uuid, resource_full_name):
2020
# find vm
21-
vm = self.pv_service.find_by_uuid(si, uuid)
21+
vm = self.pv_service.find_by_uuid(si, vm_uuid)
2222

2323
# todo: change it with the function form SergaiiT Branch
24-
#disconnect all vnics
25-
self.disconnector.disconnect_all(vm)
24+
# todo: alexa: check if I can refactor the disconnector so it will not request the vCenter resource name
25+
# disconnect all vnics before destroy
26+
self.disconnector.disconnect_all("", vm_uuid, vm)
2627

2728
# destroy vm
28-
result = self.pv_service.destory_mv(si, vm)
29+
result = self.pv_service.destroy_vm(vm)
2930

3031
# delete resources
3132
self.resource_remover.remove_resource(resource_full_name)

vCenterShell/commands/disconnect_dvswitch.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,16 @@ def __init__(self,
3131
self.port_group_configurer = port_group_configurer
3232
self.default_network = default_network
3333

34-
def get_service_instance(self, vcenter_name):
34+
def _get_service_instance(self, vcenter_name):
3535
"""
3636
Get vCenter connection
37-
:param vcenter_name:
3837
:return: VmWare SI (Service Instance)
3938
"""
40-
connection_details = self.connection_retriever.connection_details(vcenter_name)
39+
connection_details = self.connection_retriever.connection_details()
4140
si = self.pyvmomi_service.connect(connection_details.host,
42-
connection_details.username,
43-
connection_details.password,
44-
connection_details.port)
41+
connection_details.username,
42+
connection_details.password,
43+
connection_details.port)
4544
return si
4645

4746
def remove_vnic(self, vcenter_name, vm_uuid, network_name=None):
@@ -53,27 +52,30 @@ def remove_vnic(self, vcenter_name, vm_uuid, network_name=None):
5352
:return:
5453
"""
5554
_logger.debug(u"Revoking ALL Interfaces from VM '{}'...".format(vm_uuid))
56-
si = self.get_service_instance(vcenter_name)
55+
si = self._get_service_instance(vcenter_name)
5756
vm = self.pyvmomi_service.find_by_uuid(si, vm_uuid)
5857

59-
condition = lambda device: VNicService.device_is_attached_to_network(device, network_name) if network_name else lambda \
60-
x: True
58+
condition = lambda device: VNicService.device_is_attached_to_network(device,
59+
network_name) if network_name else lambda \
60+
x: True
6161
return self.remove_interfaces_from_vm_task(vm, condition)
6262

63-
def disconnect_all(self, vcenter_name, vm_uuid):
63+
def disconnect_all(self, vcenter_name, vm_uuid, vm=None):
6464
return self.disconnect(vcenter_name, vm_uuid, None)
6565

66-
def disconnect(self, vcenter_name, vm_uuid, network_name=None):
66+
def disconnect(self, vcenter_name, vm_uuid, network_name=None, vm=None):
6767
"""
6868
disconnect network adapter of the vm. If 'network_name' = None - disconnect ALL interfaces
6969
:param <str> vcenter_name: the name of the vCenter to connect to
7070
:param <str> vm_uuid: the uuid of the vm
7171
:param <str | None> network_name: the name of the specific network to disconnect
72+
:param <pyvmomi vm object> vm: If the vm obj is None will use vm_uuid to fetch the object
7273
:return: Started Task
7374
"""
7475
_logger.debug(u"Disconnect Interface VM: '{}' Network: '{}' ...".format(vm_uuid, network_name or "ALL"))
75-
si = self.get_service_instance(vcenter_name)
76-
vm = self.pyvmomi_service.find_by_uuid(si, vm_uuid)
76+
si = self._get_service_instance(vcenter_name)
77+
if vm is None:
78+
vm = self.pyvmomi_service.find_by_uuid(si, vm_uuid)
7779

7880
if network_name:
7981
network = self.pyvmomi_service.vm_get_network_by_name(vm, network_name)

vCenterShellPackage/App Templates/VM Deployment.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<AppResources>
55
<AppResource ModelName="Generic Deployed App" Driver="">
66
<Attributes>
7-
<Attribute Name="UUID" Value="" />
8-
<Attribute Name="vCenter Inventory Path" Value="" />
7+
<Attribute Name="VM_UUID" Value="" />
8+
<Attribute Name="Cloud Provider" Value="" />
99
</Attributes>
1010
</AppResource>
1111
</AppResources>

0 commit comments

Comments
 (0)