diff --git a/kloudbuster/base_compute.py b/kloudbuster/base_compute.py index 88ad35a..a0a0a35 100644 --- a/kloudbuster/base_compute.py +++ b/kloudbuster/base_compute.py @@ -19,13 +19,16 @@ import log as logging LOG = logging.getLogger(__name__) +class KBVolAttachException(Exception): + pass + + class BaseCompute(object): """ The Base class for nova compute resources 1. Creates virtual machines with specific configs """ - def __init__(self, vm_name, network): self.novaclient = network.router.user.nova_client self.network = network @@ -92,6 +95,8 @@ class BaseCompute(object): time.sleep(2) def attach_vol(self): + if self.vol.status != 'available': + raise KBVolAttachException('Volume must be in available status before attaching.') for _ in range(10): try: self.novaclient.volumes.create_server_volume(self.instance.id, self.vol.id) diff --git a/kloudbuster/base_storage.py b/kloudbuster/base_storage.py index 8bd66a7..89897ea 100644 --- a/kloudbuster/base_storage.py +++ b/kloudbuster/base_storage.py @@ -18,6 +18,9 @@ import log as logging LOG = logging.getLogger(__name__) +class KBVolCreationException(Exception): + pass + class BaseStorage(object): """ The Base class for cinder storage resources @@ -27,7 +30,17 @@ class BaseStorage(object): self.cinderclient = cinderclient def create_vol(self, size, name=None): - return self.cinderclient.volumes.create(size, name=name) + vol = self.cinderclient.volumes.create(size, name=name) + for _ in range(10): + if vol.status == 'creating': + time.sleep(1) + elif vol.status == 'available': + break + elif vol.status == 'error': + raise KBVolCreationException('Not enough disk space in the host?') + vol = self.cinderclient.volumes.get(vol.id) + + return vol def delete_vol(self, volume): """ diff --git a/kloudbuster/force_cleanup.py b/kloudbuster/force_cleanup.py index 59759b8..1dd62b2 100755 --- a/kloudbuster/force_cleanup.py +++ b/kloudbuster/force_cleanup.py @@ -89,7 +89,7 @@ def fetch_resources(fetcher, options=None): except AttributeError: resid = res['id'] resname = res['name'] - if resource_name_re.match(resname): + if resname and resource_name_re.match(resname): resources[resid] = resname return resources diff --git a/requirements-dev.txt b/requirements-dev.txt index 3cfad39..3ae7215 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,6 +3,7 @@ flake8>=2.3.0 git-review>=1.24 pylint>=1.3 pep8>=1.5.7 -sphinx>=1.2.3 +sphinx>=1.4.0 +sphinx_rtd_theme>=0.1.9 tox>=1.9.0 twine>=1.6.5 diff --git a/test-requirements.txt b/test-requirements.txt index d92ef94..cfa963c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,7 +7,8 @@ hacking<0.11,>=0.10.0 coverage>=3.6 discover python-subunit>=0.0.18 -sphinx>=1.3.1 +sphinx>=1.4.0 +sphinx_rtd_theme>=0.1.9 oslosphinx>=2.5.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0 testrepository>=0.0.18