diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-10-24 12:27:32 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-10-24 12:27:32 -0600 |
commit | 65d02af9035034b504c4e3588d30fcda68182e36 (patch) | |
tree | 077c1449edb2f1b1934a5877a4604a700d7263b7 /snaps/openstack/create_volume.py | |
parent | 2f3d18fd64ce0aea7d229493130404e2bf86dab2 (diff) |
Implemented the ability to attach volumes to VM instances.
JIRA: SNAPS-198
Change-Id: I30bb92dabab64e6a8918fa5ab0de1bed359a147e
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/create_volume.py')
-rw-r--r-- | snaps/openstack/create_volume.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/snaps/openstack/create_volume.py b/snaps/openstack/create_volume.py index 9baad7e..7688da5 100644 --- a/snaps/openstack/create_volume.py +++ b/snaps/openstack/create_volume.py @@ -29,7 +29,8 @@ VOLUME_ACTIVE_TIMEOUT = 300 VOLUME_DELETE_TIMEOUT = 60 POLL_INTERVAL = 3 STATUS_ACTIVE = 'available' -STATUS_FAILED = 'failed' +STATUS_IN_USE = 'in-use' +STATUS_FAILED = 'error' STATUS_DELETED = 'deleted' @@ -97,7 +98,7 @@ class OpenStackVolume(OpenStackVolumeObject): """ if self.__volume: try: - if self.volume_active(block=True): + if self.volume_active(): cinder_utils.delete_volume(self._cinder, self.__volume) else: logger.warn('Timeout waiting to delete volume %s', @@ -144,6 +145,14 @@ class OpenStackVolume(OpenStackVolumeObject): return self._volume_status_check(STATUS_ACTIVE, block, timeout, poll_interval) + def volume_in_use(self): + """ + Returns true when the volume status returns the value of + expected_status_code + :return: T/F + """ + return self._volume_status_check(STATUS_IN_USE, False, 0, 0) + def volume_deleted(self, block=False, poll_interval=POLL_INTERVAL): """ Returns true when the VM status returns the value of @@ -179,7 +188,7 @@ class OpenStackVolume(OpenStackVolumeObject): if block: start = time.time() else: - start = time.time() - timeout + 10 + start = time.time() - timeout + 1 while timeout > time.time() - start: status = self._status(expected_status_code) |