コード例 #1
0
    def _do_setup(self):
        """
        Setup test
        """
        self._refresh_instance_data()

        success, reason = _instances.instance_is_resized(self._instance_data)
        if success:
            return True, reason

        success, reason = _instances.instance_is_running(self._instance_data)
        if not success:
            return False, ("instance needs to be migrated for test, but is not in "
                           "the running state")

        nova.cold_migrate_server(self.token, self.instance_uuid)

        max_end_datetime = (self._start_datetime +
                            datetime.timedelta(seconds=self.timeout_secs))
        while True:
            self._refresh_instance_data()
            self._end_datetime = datetime.datetime.now()

            success, reason = _instances.instance_is_resized(self._instance_data)
            if success:
                break

            if self._end_datetime > max_end_datetime:
                DLOG.error("Test setup %s timeout for instance %s."
                           % (self._name, self.instance_name))
                return False, ("instance %s failed to migrate" % self.instance_name)

            time.sleep(5)

        return True, "instance setup complete"
コード例 #2
0
    def _do_setup(self):
        """
        Setup test
        """
        self._refresh_instance_data()

        success, reason = _instances.instance_is_resized(self._instance_data)
        if success:
            return True, reason

        success, reason = _instances.instance_is_running(self._instance_data)
        if not success:
            return False, ("instance needs to be resized for test, but is not in "
                           "the running state")

        flavor_id = None
        for flavor_name in self._flavor_names:
            flavor_id = self._get_flavor_id(flavor_name)
            if flavor_name != self._instance_data['flavor']['original_name']:
                break

        if flavor_id is None:
            DLOG.error("Test setup %s failure for instance %s, reason=could not "
                       "find flavor to resize with."
                       % (self._name, self.instance_name))
            return False, "no valid flavors given"

        nova.resize_server(self.token, self.instance_uuid, flavor_id)

        max_end_datetime = (self._start_datetime +
                            datetime.timedelta(seconds=self.timeout_secs))
        while True:
            self._refresh_instance_data()
            self._end_datetime = datetime.datetime.now()

            success, reason = _instances.instance_is_resized(self._instance_data)
            if success:
                break

            if self._end_datetime > max_end_datetime:
                DLOG.error("Test setup %s timeout for instance %s."
                           % (self._name, self.instance_name))
                return False, ("instance %s failed to resize" % self.instance_name)

            time.sleep(5)

        return True, "instance setup complete"