From: Zack Cerza Date: Tue, 26 Jan 2016 17:31:02 +0000 (-0700) Subject: ProvisionOpenStack: raise QuotaExceededError X-Git-Tag: 1.1.0~684^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b047ed678504d6a1571013fdf75fde6e58fdf86d;p=teuthology.git ProvisionOpenStack: raise QuotaExceededError ... if instance creation fails due to a maxed-out quota Signed-off-by: Zack Cerza --- diff --git a/teuthology/provision.py b/teuthology/provision.py index ab10a300a5..2fb3acd1d8 100644 --- a/teuthology/provision.py +++ b/teuthology/provision.py @@ -9,9 +9,12 @@ import time import tempfile import yaml +from subprocess import CalledProcessError + from .openstack import OpenStack, OpenStackInstance from .config import config from .contextutil import safe_while +from .exceptions import QuotaExceededError from .misc import decanonicalize_hostname, get_distro, get_distro_version from .lockstatus import get_status @@ -307,22 +310,28 @@ class ProvisionOpenStack(OpenStack): net = '' flavor = self.flavor(resources_hint['machine'], config['openstack'].get('flavor-select-regexp')) - misc.sh("flock --close --timeout 28800 /tmp/teuthology-server-create.lock" + - " openstack server create" + - " " + config['openstack'].get('server-create', '') + - " -f json " + - " --image '" + str(image) + "'" + - " --flavor '" + str(flavor) + "'" + - " --key-name teuthology " + - " --user-data " + str(self.user_data) + - " " + net + - " --min " + str(num) + - " --max " + str(num) + - " --security-group teuthology" + - " --property teuthology=" + self.property + - " --property ownedby=" + config.openstack['ip'] + - " --wait " + - " " + self.basename) + cmd = ("flock --close --timeout 28800 /tmp/teuthology-server-create.lock" + + " openstack server create" + + " " + config['openstack'].get('server-create', '') + + " -f json " + + " --image '" + str(image) + "'" + + " --flavor '" + str(flavor) + "'" + + " --key-name teuthology " + + " --user-data " + str(self.user_data) + + " " + net + + " --min " + str(num) + + " --max " + str(num) + + " --security-group teuthology" + + " --property teuthology=" + self.property + + " --property ownedby=" + config.openstack['ip'] + + " --wait " + + " " + self.basename) + try: + misc.sh(cmd) + except CalledProcessError as exc: + if "quota exceeded" in exc.output.lower(): + raise QuotaExceededError(message=exc.output) + raise instances = filter( lambda instance: self.property in instance['Properties'], self.list_instances())