CLOUDSTACK-7933: test_escalations_instances.py - Fixed test_13_vm_nics for 
Vmware
Signed-off-by: SrikanteswaraRao Talluri <tall...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d0ca2d5d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d0ca2d5d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d0ca2d5d

Branch: refs/heads/useraccount-refactoring
Commit: d0ca2d5d8b1575bf8c7d1b6566cea15c8a2264bb
Parents: 2fbef67
Author: Gaurav Aradhye <gaurav.arad...@clogeny.com>
Authored: Tue Nov 18 11:49:38 2014 +0530
Committer: SrikanteswaraRao Talluri <tall...@apache.org>
Committed: Tue Nov 25 18:58:00 2014 +0530

----------------------------------------------------------------------
 .../component/test_escalations_instances.py     | 74 ++++++++++++++------
 1 file changed, 51 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ca2d5d/test/integration/component/test_escalations_instances.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations_instances.py 
b/test/integration/component/test_escalations_instances.py
index fd25bb9..cc1f78b 100644
--- a/test/integration/component/test_escalations_instances.py
+++ b/test/integration/component/test_escalations_instances.py
@@ -1781,6 +1781,12 @@ class TestListInstances(cloudstackTestCase):
             raise unittest.SkipTest(
                 "This feature is not supported on existing hypervisor.\
                         Hence, skipping the test")
+
+        hypervisorIsVmware = False
+
+        if self.hypervisor.lower() == "vmware":
+            hypervisorIsVmware = True
+
         # Listing all the VM's for a User
         list_vms_before = VirtualMachine.list(
             self.userapiclient,
@@ -1797,6 +1803,7 @@ class TestListInstances(cloudstackTestCase):
             accountid=self.account.name,
             domainid=self.account.domainid,
             serviceofferingid=self.service_offering.id,
+            mode=self.zone.networktype if hypervisorIsVmware else "default"
         )
         self.assertIsNotNone(
             vm_created,
@@ -2002,40 +2009,61 @@ class TestListInstances(cloudstackTestCase):
             default_nic.networkid,
             "Default NIC is not matching for VM"
         )
-        # Deleting non default NIC
-        vm_created.remove_nic(
-            self.userapiclient,
-            non_default_nic.id
-        )
-        # Listing the Vm details again
-        list_vms_after = VirtualMachine.list(
-            self.userapiclient,
-            id=vm_created.id
-        )
-        status = validateList(list_vms_after)
-        self.assertEquals(
+
+        # If hypervisor is Vmware, then check if
+        # the vmware tools are installed and the process is running
+        # Vmware tools are necessary for remove nic operations (vmware 5.5+)
+        isVmwareToolInstalled = False
+        if hypervisorIsVmware:
+            sshClient = vm_created.get_ssh_client()
+            result = str(
+                sshClient.execute("service vmware-tools status")).lower()
+            self.debug("and result is: %s" % result)
+            if "running" in result:
+                isVmwareToolInstalled = True
+
+        goForUnplugOperation = True
+        # If Vmware tools are not installed in case of vmware hypervisor
+        # then don't go further for unplug operation (remove nic) as it won't
+        # be supported
+        if hypervisorIsVmware and not isVmwareToolInstalled:
+            goForUnplugOperation = False
+
+        if goForUnplugOperation:
+            # Deleting non default NIC
+            vm_created.remove_nic(
+                self.userapiclient,
+                non_default_nic.id
+            )
+            # Listing the Vm details again
+            list_vms_after = VirtualMachine.list(
+                self.userapiclient,
+                id=vm_created.id
+            )
+            status = validateList(list_vms_after)
+            self.assertEquals(
             PASS,
             status[0],
             "Listing of VM failed"
-        )
-        vm = list_vms_after[0]
-        # Verifying that VM nics size is 1 now
-        vm_nics_after = vm.nic
-        self.assertIsNotNone(
+            )
+            vm = list_vms_after[0]
+            # Verifying that VM nics size is 1 now
+            vm_nics_after = vm.nic
+            self.assertIsNotNone(
             vm_nics_after,
             "Nic not found for the deployed VM"
-        )
-        self.assertEquals(
+            )
+            self.assertEquals(
             1,
             len(vm_nics_after),
             "VM NIC's count is not matching"
-        )
-        # Verifying the nic network is same as the default nic network
-        self.assertEquals(
+            )
+            # Verifying the nic network is same as the default nic network
+            self.assertEquals(
             network2.id,
             vm_nics_after[0].networkid,
             "VM NIC is not same as expected"
-        )
+            )
         return
 
 

Reply via email to