Esempio n. 1
0
    def _delete_volume(self, volume):
        try:
            self.cinderclient.volumes.delete(volume)
        except cinder_exception.NotFound:
            return
        except cinder_exception.ClientException as e:
            LOG.error(
                _LE("Error happened when delete volume from Cinder."
                    " Error: %s"), e)
            raise

        start_time = time.time()
        # Wait until the volume is not there or until the operation timeout
        while (time.time() - start_time < consts.DESTROY_VOLUME_TIMEOUT):
            try:
                self.cinderclient.volumes.get(volume.id)
            except cinder_exception.NotFound:
                return
            time.sleep(consts.VOLUME_SCAN_TIME_DELAY)

        # If the volume is not deleted, raise an exception
        msg_ft = _LE("Timed out while waiting for volume. "
                     "Expected Volume: {0}, "
                     "Expected State: {1}, "
                     "Elapsed Time: {2}").format(volume, None,
                                                 time.time() - start_time)
        raise exceptions.TimeoutException(msg_ft)
Esempio n. 2
0
    def disconnect_volume(self, share, **disconnect_opts):
        mountpoint = self.get_mountpoint(share)
        mount.Mounter().unmount(mountpoint)

        self._access_deny(share)

        def _check_access_binded(s):
            sal = self.manilaclient.shares.access_list(s)
            share_proto = s.share_proto
            access_type = self.proto_access_type_map.get(share_proto)
            access_to = self._get_access_to(access_type)
            for a in sal:
                if a.access_type == access_type and a.access_to == access_to:
                    if a.state in ('error', 'error_deleting'):
                        raise exceptions.NotMatchedState(
                            "Revoke access {0} failed".format(a))
                    return True
            return False

        start_time = time.time()
        while time.time() - start_time < consts.ACCSS_DENY_TIMEOUT:
            if not _check_access_binded(share):
                LOG.info("Disconnect share %s successfully", share)
                return
            time.sleep(consts.SCAN_INTERVAL)

        raise exceptions.TimeoutException("Disconnect volume timeout")
Esempio n. 3
0
    def monitor_manila_share(self):
        while True:
            try:
                share = self.client.shares.get(self.expected_obj.id)
            except manila_exception.ClientException:
                elapsed_time = time.time() - self.start_time
                if elapsed_time > self.time_limit:
                    msg = _LE("Timed out while waiting for share. "
                              "Expected Share: {0}, "
                              "Expected State: {1}, "
                              "Elapsed Time: {2}").format(self.expected_obj,
                                                          self.desired_state,
                                                          elapsed_time)
                    raise exceptions.TimeoutException(msg)
                raise

            if self._reached_desired_state(share.status):
                return share

            time.sleep(self.time_delay)
Esempio n. 4
0
    def monitor_share_access(self, access_type, access_to):
        while True:
            try:
                al = self.client.shares.access_list(self.expected_obj.id)
            except manila_exception.ClientException:
                elapsed_time = time.time() - self.start_time
                if elapsed_time > self.time_limit:
                    msg = _LE("Timed out while waiting for share access. "
                              "Expected State: {0}, "
                              "Elapsed Time: {1}").format(self.desired_state,
                                                          elapsed_time)
                    raise exceptions.TimeoutException(msg)
                raise

            for a in al:
                if a.access_type == access_type and a.access_to == access_to:
                    if self._reached_desired_state(a.state):
                        return self.expected_obj

            time.sleep(self.time_delay)
Esempio n. 5
0
    def monitor_cinder_volume(self):
        while True:
            try:
                volume = self.client.volumes.get(self.expected_obj.id)
            except cinder_exception.ClientException:
                elapsed_time = time.time() - self.start_time
                if elapsed_time > self.time_limit:
                    msg = _LE("Timed out while waiting for volume. "
                              "Expected Volume: {0}, "
                              "Expected State: {1}, "
                              "Elapsed Time: {2}").format(self.expected_obj,
                                                          self.desired_state,
                                                          elapsed_time)
                    LOG.error(msg)
                    raise exceptions.TimeoutException(msg)
                raise

            if self._reached_desired_state(volume.status):
                return volume

            time.sleep(self.time_delay)