Ejemplo n.º 1
0
    def checkForRunningSystemVM(self, ssvm, ssvm_type=None):
        if not ssvm:
            return None

        def checkRunningState():
            if not ssvm_type:
                response = list_ssvms(
                    self.apiclient,
                    id=ssvm.id
                )
            else:
                response = list_ssvms(
                    self.apiclient,
                    zoneid=self.zone.id,
                    systemvmtype=ssvm_type
                )

            if isinstance(response, list):
                ssvm_response = response[0]
                return ssvm_response.state == 'Running', ssvm_response
            return False, None

        res, ssvm_response = wait_until(3, 300, checkRunningState)
        if not res:
            self.fail("Failed to reach systemvm state to Running")
        return ssvm_response
Ejemplo n.º 2
0
    def checkForRunningSystemVM(self, ssvm, ssvm_type=None):
        if not ssvm:
            return None

        def checkRunningState():
            if not ssvm_type:
                response = list_ssvms(
                    self.apiclient,
                    id=ssvm.id
                )
            else:
                response = list_ssvms(
                    self.apiclient,
                    zoneid=self.zone.id,
                    systemvmtype=ssvm_type
                )

            if isinstance(response, list):
                ssvm_response = response[0]
                return ssvm_response.state == 'Running', ssvm_response
            return False, None

        res, ssvm_response = wait_until(3, 300, checkRunningState)
        if not res:
            self.fail("Failed to reach systemvm state to Running")
        return ssvm_response
Ejemplo n.º 3
0
    def _wait_for_storage_cleanup_thread(self, system_vms):
        retry_interval = 60
        num_tries = 10

        wait_result, return_val = wait_until(retry_interval, num_tries, self._check_resource_state, system_vms)

        if not wait_result:
            raise Exception(return_val)
Ejemplo n.º 4
0
    def _wait_for_volume_state(self, volume_id, volume_state):
        retry_interval = 30
        num_tries = 10

        wait_result, return_val = wait_until(retry_interval, num_tries, TestUploadDownload._check_volume_state, self.apiClient, volume_id, volume_state)

        if not wait_result:
            raise Exception(return_val)
Ejemplo n.º 5
0
    def _wait_for_removal_of_extracted_volume(self, volume_id, extract_result_url):
        retry_interval = 60
        num_tries = 10

        wait_result, return_val = wait_until(retry_interval, num_tries, self._check_removal_of_extracted_volume_state, volume_id, extract_result_url)

        if not wait_result:
            raise Exception(return_val)
Ejemplo n.º 6
0
    def waitForSystemVMAgent(self, vmname):
        def checkRunningAgent():
            list_host_response = list_hosts(self.apiclient, name=vmname)
            if isinstance(list_host_response, list):
                return list_host_response[0].state == 'Up', None
            return False, None

        res, _ = wait_until(3, 300, checkRunningAgent)
        if not res:
            raise Exception("Failed to wait for SSVM agent to be Up")
Ejemplo n.º 7
0
    def _wait_for_and_get_running_system_vms(self, expected_number_of_system_vms):
        retry_interval = 60
        num_tries = 10

        wait_result, return_val = wait_until(retry_interval, num_tries, self._check_number_of_running_system_vms, expected_number_of_system_vms)

        if not wait_result:
            raise Exception(return_val)

        return return_val
    def _wait_for_volume_state(self, volume_id, volume_state):
        retry_interval = 30
        num_tries = 10

        wait_result, return_val = wait_until(
            retry_interval, num_tries, TestUploadDownload._check_volume_state,
            self.apiClient, volume_id, volume_state)

        if not wait_result:
            raise Exception(return_val)
    def _wait_for_removal_of_extracted_volume(self, volume_id,
                                              extract_result_url):
        retry_interval = 60
        num_tries = 10

        wait_result, return_val = wait_until(
            retry_interval, num_tries,
            self._check_removal_of_extracted_volume_state, volume_id,
            extract_result_url)

        if not wait_result:
            raise Exception(return_val)
Ejemplo n.º 10
0
    def waitForSystemVMAgent(self, vmname):
        def checkRunningAgent():
            list_host_response = list_hosts(
                self.apiclient,
                name=vmname
            )
            if isinstance(list_host_response, list):
                return list_host_response[0].state == 'Up', None
            return False, None

        res, _ = wait_until(3, 300, checkRunningAgent)
        if not res:
            raise Exception("Failed to wait for SSVM agent to be Up")
Ejemplo n.º 11
0
    def wait_for_attributes_and_return_root_vol(self):
        def checkVolumeResponse():
            list_volume_response = Volume.list(
                self.apiClient,
                virtualmachineid=self.virtual_machine.id,
                type='ROOT',
                listall=True
            )

            if isinstance(list_volume_response, list) and list_volume_response[0].virtualsize is not None:
                return True, list_volume_response[0]
            return False, None

        # sleep interval is 1s, retries is 360, this will sleep atmost 360 seconds, or 6 mins
        res, response = wait_until(1, 360, checkVolumeResponse)
        if not res:
            self.fail("Failed to return root volume response")
        return response
Ejemplo n.º 12
0
    def wait_for_attributes_and_return_root_vol(self):
        def checkVolumeResponse():
            list_volume_response = Volume.list(
                self.apiClient,
                virtualmachineid=self.virtual_machine.id,
                type='ROOT',
                listall=True
            )

            if isinstance(list_volume_response, list) and list_volume_response[0].virtualsize is not None:
                return True, list_volume_response[0]
            return False, None

        # sleep interval is 1s, retries is 360, this will sleep atmost 360 seconds, or 6 mins
        res, response = wait_until(1, 360, checkVolumeResponse)
        if not res:
            self.fail("Failed to return root volume response")
        return response
Ejemplo n.º 13
0
    def test_11_ss_nfs_version_on_ssvm(self):
        """Test NFS Version on Secondary Storage mounted properly on SSVM
        """

        # 1) List SSVM in zone
        # 2) Get id and url from mounted nfs store
        # 3) Update NFS version for previous image store
        # 4) Stop SSVM
        # 5) Check NFS version of mounted nfs store after SSVM starts

        nfs_version = self.config.nfsVersion
        if nfs_version == None:
            self.skipTest('No NFS version provided in test data')

        #List SSVM for zone id
        list_ssvm_response = list_ssvms(self.apiclient,
                                        systemvmtype='secondarystoragevm',
                                        state='Running',
                                        zoneid=self.zone.id)
        self.assertNotEqual(list_ssvm_response, None)
        self.assertEqual(isinstance(list_ssvm_response, list), True,
                         "Check list response returns a valid list")
        self.assertEqual(len(list_ssvm_response), 1,
                         "Check list System VMs response")

        ssvm = list_ssvm_response[0]
        image_stores_response = ImageStore.list(self.apiclient,
                                                zoneid=self.zone.id)

        if self.hypervisor.lower() in ('vmware', 'hyperv'):
            # SSH into SSVMs is done via management server for Vmware and Hyper-V
            result = get_process_status(self.apiclient.connection.mgtSvr,
                                        22,
                                        self.apiclient.connection.user,
                                        self.apiclient.connection.passwd,
                                        ssvm.privateip,
                                        "mount | grep 'type nfs'",
                                        hypervisor=self.hypervisor)

        for res in result:
            split_res = res.split("on")
            mounted_img_store_url = split_res[0].strip()
            for img_store in image_stores_response:
                img_store_url = str(img_store.url)
                if img_store_url.startswith("nfs://"):
                    img_store_url = img_store_url[6:]
                    #Add colon after ip address to match output from mount command
                    first_slash = img_store_url.find('/')
                    img_store_url = img_store_url[
                        0:first_slash] + ':' + img_store_url[first_slash:]
                    if img_store_url == mounted_img_store_url:
                        img_store_id = img_store.id
                        break

        self.assertNotEqual(img_store_id, None,
                            "Check image store id mounted on SSVM")

        #Update NFS version for image store mounted on SSVM
        updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
        updateConfigurationCmd.name = "secstorage.nfs.version"
        updateConfigurationCmd.value = nfs_version
        updateConfigurationCmd.imagestoreuuid = img_store_id

        updateConfigurationResponse = self.apiclient.updateConfiguration(
            updateConfigurationCmd)
        self.logger.debug("updated the parameter %s with value %s" %
                          (updateConfigurationResponse.name,
                           updateConfigurationResponse.value))

        #Stop SSVM
        self.debug("Stopping SSVM: %s" % ssvm.id)
        cmd = stopSystemVm.stopSystemVmCmd()
        cmd.id = ssvm.id
        self.apiclient.stopSystemVm(cmd)

        def checkForRunningSSVM():
            new_list_ssvm_response = list_ssvms(self.apiclient, id=ssvm.id)
            if isinstance(new_list_ssvm_response, list):
                return new_list_ssvm_response[0].state == 'Running', None

        res, _ = wait_until(self.services["sleep"], self.services["timeout"],
                            checkForRunningSSVM)
        if not res:
            self.fail("List SSVM call failed!")

        new_list_ssvm_response = list_ssvms(self.apiclient, id=ssvm.id)

        self.assertNotEqual(new_list_ssvm_response, None)
        self.assertEqual(isinstance(new_list_ssvm_response, list), True,
                         "Check list response returns a valid list")
        ssvm = new_list_ssvm_response[0]
        self.debug("SSVM state after debug: %s" % ssvm.state)
        self.assertEqual(ssvm.state, 'Running',
                         "Check whether SSVM is running or not")
        # Wait for the agent to be up
        self.waitForSystemVMAgent(ssvm.name)

        #Check NFS version on mounted image store
        result = get_process_status(self.apiclient.connection.mgtSvr,
                                    22,
                                    self.apiclient.connection.user,
                                    self.apiclient.connection.passwd,
                                    ssvm.privateip,
                                    "mount | grep '%s'" %
                                    mounted_img_store_url,
                                    hypervisor=self.hypervisor)

        self.assertNotEqual(result, None)
        self.assertEqual(len(result), 1, "Check result length")

        res = result[0]
        mounted_nfs_version = res.split("vers=")[1][0:1]
        self.assertEqual(
            int(mounted_nfs_version), int(nfs_version),
            "Check mounted NFS version to be the same as provided")

        return
Ejemplo n.º 14
0
    def test_11_ss_nfs_version_on_ssvm(self):
        """Test NFS Version on Secondary Storage mounted properly on SSVM
        """

        # 1) List SSVM in zone
        # 2) Get id and url from mounted nfs store
        # 3) Update NFS version for previous image store
        # 4) Stop SSVM
        # 5) Check NFS version of mounted nfs store after SSVM starts 

        nfs_version = self.config.nfsVersion
        if nfs_version == None:
            self.skipTest('No NFS version provided in test data')

        #List SSVM for zone id
        list_ssvm_response = list_ssvms(
            self.apiclient,
            systemvmtype='secondarystoragevm',
            state='Running',
            zoneid=self.zone.id
        )
        self.assertNotEqual(
            list_ssvm_response,
            None
        )
        self.assertEqual(
            isinstance(list_ssvm_response, list),
            True,
            "Check list response returns a valid list"
        )
        self.assertEqual(
            len(list_ssvm_response),
            1,
            "Check list System VMs response"
        )

        ssvm = list_ssvm_response[0]
        image_stores_response = ImageStore.list(self.apiclient,zoneid=self.zone.id)

        if self.hypervisor.lower() in ('vmware', 'hyperv'):
            # SSH into SSVMs is done via management server for Vmware and Hyper-V
            result = get_process_status(
                self.apiclient.connection.mgtSvr,
                22,
                self.apiclient.connection.user,
                self.apiclient.connection.passwd,
                ssvm.privateip,
                "mount | grep 'type nfs'",
                hypervisor=self.hypervisor)

        for res in result:
            split_res = res.split("on")
            mounted_img_store_url = split_res[0].strip()
            for img_store in image_stores_response:
                img_store_url = str(img_store.url)
                if img_store_url.startswith("nfs://"):
                    img_store_url = img_store_url[6:]
                    #Add colon after ip address to match output from mount command
                    first_slash = img_store_url.find('/')
                    img_store_url = img_store_url[0:first_slash] + ':' + img_store_url[first_slash:]
                    if img_store_url == mounted_img_store_url:
                        img_store_id = img_store.id
                        break

        self.assertNotEqual(
            img_store_id,
            None,
            "Check image store id mounted on SSVM"
        )

        #Update NFS version for image store mounted on SSVM
        updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
        updateConfigurationCmd.name = "secstorage.nfs.version"
        updateConfigurationCmd.value = nfs_version
        updateConfigurationCmd.imagestoreuuid = img_store_id

        updateConfigurationResponse = self.apiclient.updateConfiguration(updateConfigurationCmd)
        self.logger.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value))

        #Stop SSVM
        self.debug("Stopping SSVM: %s" % ssvm.id)
        cmd = stopSystemVm.stopSystemVmCmd()
        cmd.id = ssvm.id
        self.apiclient.stopSystemVm(cmd)

        def checkForRunningSSVM():
            new_list_ssvm_response = list_ssvms(
                self.apiclient,
                id=ssvm.id
            )
            if isinstance(new_list_ssvm_response, list):
                return new_list_ssvm_response[0].state == 'Running', None                
            
        res, _ = wait_until(self.services["sleep"], self.services["timeout"], checkForRunningSSVM)
        if not res:
            self.fail("List SSVM call failed!")
        
        new_list_ssvm_response = list_ssvms(
                self.apiclient,
                id=ssvm.id
        )

        self.assertNotEqual(
            new_list_ssvm_response,
            None
        )
        self.assertEqual(
            isinstance(new_list_ssvm_response, list),
            True,
            "Check list response returns a valid list"
        )
        ssvm = new_list_ssvm_response[0]
        self.debug("SSVM state after debug: %s" % ssvm.state)
        self.assertEqual(
            ssvm.state,
            'Running',
            "Check whether SSVM is running or not"
        )
        # Wait for the agent to be up
        self.waitForSystemVMAgent(ssvm.name)

        #Check NFS version on mounted image store
        result = get_process_status(
                self.apiclient.connection.mgtSvr,
                22,
                self.apiclient.connection.user,
                self.apiclient.connection.passwd,
                ssvm.privateip,
                "mount | grep '%s'"%mounted_img_store_url,
                hypervisor=self.hypervisor)

        self.assertNotEqual(
            result,
            None
        )
        self.assertEqual(
            len(result),
            1,
            "Check result length"
        )

        res = result[0]
        mounted_nfs_version = res.split("vers=")[1][0:1]
        self.assertEqual(
            int(mounted_nfs_version),
            int(nfs_version),
            "Check mounted NFS version to be the same as provided"
        )

        return