def tearDownClass(cls):
     try:
         # Cleanup resources used
         cleanup_resources(cls.api_client, cls._cleanup)
         for host in cls.hosts:
             Host.cancelMaintenance(cls.api_client, id=host.id)
             hosts_states = Host.list(cls.api_client,
                                      id=host.id,
                                      listall=True)
             if hosts_states[0].resourcestate != 'Enabled':
                 raise Exception("Failed to cancel maintenance mode on %s" %
                                 (host.name))
     except Exception as e:
         raise Exception("Warning: Exception during cleanup : %s" % e)
     return
Ejemplo n.º 2
0
    def test_02_cancel_maintenance(self):
        """ Test cancel Maintenance Mode on the above Hosts + Migrate VMs Back
        """

        # Steps
        # 1. Cancel Maintenance Mode on the host.
        # 2. Migrate the VMs back onto the host on which Maintenance mode is
        #    cancelled.
        # Validate the following
        # 1. Successfully cancel the Maintenance mode on the host.
        # 2. Migrate the VMs back successfully onto the host.
        # 3. Check that the network connectivity exists with the migrated VMs.

        self.debug("Cancel host maintenence on which the VPCVR is running")
        try:
            Host.cancelMaintenance(self.apiclient, id=self.vpcvr.hostid)
        except Exception as e:
            self.fail("Failed to enable maintenance mode on host: %s" % e)

        self.debug(
            "Migrating the instances back to the host: %s" %
                                                        self.vpcvr.hostid)
        try:
            cmd = migrateSystemVm.migrateSystemVmCmd()
            cmd.hostid = self.vpcvr.hostid
            cmd.virtualmachineid = self.vpcvr.id
            self.apiclient.migrateSystemVm(cmd)
        except Exception as e:
            self.fail("Failed to migrate VPCVR back: %s" % e)

        self.debug("Check the status of router after migration")
        routers = Router.list(
                              self.apiclient,
                              id=self.vpcvr.id,
                              listall=True
                              )
        self.assertEqual(
                         isinstance(routers, list),
                         True,
                         "List routers shall return the valid response"
                         )
        self.assertEqual(
                         routers[0].state,
                         "Running",
                         "Router state should be running"
                         )
        #  TODO: Check for the network connectivity
        return
Ejemplo n.º 3
0
 def tearDownClass(cls):
     try:
         for host in cls.hosts:
             Host.cancelMaintenance(cls.api_client, id=host.id)
             hosts_states = Host.list(cls.api_client,
                                      id=host.id,
                                      listall=True)
             if hosts_states[0].resourcestate != 'Enabled':
                 raise Exception("Failed to cancel maintenance mode on %s" %
                                 (host.name))
     except Exception as e:
         raise Exception(
             "Warning: Exception during resetting hosts maintenance : %s" %
             e)
     finally:
         super(TestVPCHostMaintenance, cls).tearDownClass()
     return
 def tearDownClass(cls):
     try:
         # Cleanup resources used
         cleanup_resources(cls.api_client, cls._cleanup)
         for host in cls.hosts:
             Host.cancelMaintenance(
                 cls.api_client,
                 id=host.id
             )
             hosts_states = Host.list(
                 cls.api_client,
                 id=host.id,
                 listall=True
             )
             if hosts_states[0].resourcestate != 'Enabled':
                 raise Exception(
                     "Failed to cancel maintenance mode on %s" %
                     (host.name))
     except Exception as e:
         raise Exception("Warning: Exception during cleanup : %s" % e)
     return
    def test_02_cancel_maintenance(self):
        """ Test cancel Maintenance Mode on the above Hosts + Migrate VMs Back
        """

        # Steps
        # 1. Cancel Maintenance Mode on the host.
        # 2. Migrate the VMs back onto the host on which Maintenance mode is
        #    cancelled.
        # Validate the following
        # 1. Successfully cancel the Maintenance mode on the host.
        # 2. Migrate the VMs back successfully onto the host.
        # 3. Check that the network connectivity exists with the migrated VMs.

        try:
            timeout = self.services["timeout"]
            while True:
                list_host_response = Host.list(self.apiclient, id=self.vpcvr.hostid, resourcestate="Maintenance")

                if list_host_response is not None:
                    break
                elif timeout == 0:
                    raise Exception("Failed to list the Host in Maintenance State")

                time.sleep(self.services["sleep"])
                timeout = timeout - 1

            self.debug("Verified that the Host is in Maintenance State")

        except:
            self.fail("Failed to find the Host in maintenance state")

        self.debug("Cancel host maintenence on which the VPCVR is running")
        try:
            Host.cancelMaintenance(self.apiclient, id=self.vpcvr.hostid)

            timeout = self.services["timeout"]
            while True:
                list_host_response = Host.list(self.apiclient, id=self.vpcvr.hostid, state="Up")

                if list_host_response is not None:
                    break
                elif timeout == 0:
                    raise Exception("Failed to list the Host in Up State after Canceling Maintenance Mode")

                time.sleep(self.services["sleep"])
                timeout = timeout - 1

            self.debug("Verified that the Host is in Up State after Canceling Maintenance Mode")

        except Exception as e:
            self.fail("Failed to cancel maintenance mode on host: %s" % e)

        self.debug("Migrating the instances back to the host: %s" % self.vpcvr.hostid)
        try:
            cmd = migrateSystemVm.migrateSystemVmCmd()
            cmd.hostid = self.vpcvr.hostid
            cmd.virtualmachineid = self.vpcvr.id
            self.apiclient.migrateSystemVm(cmd)
        except Exception as e:
            self.fail("Failed to migrate VPCVR back: %s" % e)

        self.debug("Check the status of router after migration")
        routers = Router.list(self.apiclient, id=self.vpcvr.id, listall=True)
        self.assertEqual(isinstance(routers, list), True, "List routers shall return the valid response")
        self.assertEqual(routers[0].state, "Running", "Router state should be running")
        #  TODO: Check for the network connectivity
        return
    def test_02_cancel_maintenance(self):
        """ Test cancel Maintenance Mode on the above Hosts + Migrate VMs Back
        """

        # Steps
        # 1. Cancel Maintenance Mode on the host.
        # 2. Migrate the VMs back onto the host on which Maintenance mode is
        #    cancelled.
        # Validate the following
        # 1. Successfully cancel the Maintenance mode on the host.
        # 2. Migrate the VMs back successfully onto the host.
        # 3. Check that the network connectivity exists with the migrated VMs.
        
        try:
            timeout = self.services["timeout"]
            while True:
                list_host_response = Host.list(
                    self.apiclient,
                    id=self.vpcvr.hostid,
                    resourcestate="Maintenance")
                
                if list_host_response is not None:
                    break
                elif timeout == 0:
                    raise Exception("Failed to list the Host in Maintenance State")

                time.sleep(self.services["sleep"])
                timeout = timeout - 1
            
            self.debug("Verified that the Host is in Maintenance State")
            
        except:
            self.fail("Failed to find the Host in maintenance state")

        self.debug("Cancel host maintenence on which the VPCVR is running")
        try:
            Host.cancelMaintenance(self.apiclient, id=self.vpcvr.hostid)

            timeout = self.services["timeout"]
            while True:
                list_host_response = Host.list(
                    self.apiclient,
                    id=self.vpcvr.hostid,
                    state="Up")
                
                if list_host_response is not None:
                    break
                elif timeout == 0:
                    raise Exception("Failed to list the Host in Up State after Canceling Maintenance Mode")

                time.sleep(self.services["sleep"])
                timeout = timeout - 1
            
            self.debug("Verified that the Host is in Up State after Canceling Maintenance Mode")
            
        except Exception as e:
            self.fail("Failed to cancel maintenance mode on host: %s" % e)

        self.debug(
            "Migrating the instances back to the host: %s" %
                                                        self.vpcvr.hostid)
        try:
            cmd = migrateSystemVm.migrateSystemVmCmd()
            cmd.hostid = self.vpcvr.hostid
            cmd.virtualmachineid = self.vpcvr.id
            self.apiclient.migrateSystemVm(cmd)
        except Exception as e:
            self.fail("Failed to migrate VPCVR back: %s" % e)

        self.debug("Check the status of router after migration")
        routers = Router.list(
                              self.apiclient,
                              id=self.vpcvr.id,
                              listall=True
                              )
        self.assertEqual(
                         isinstance(routers, list),
                         True,
                         "List routers shall return the valid response"
                         )
        self.assertEqual(
                         routers[0].state,
                         "Running",
                         "Router state should be running"
                         )
        #  TODO: Check for the network connectivity
        return