From b45418446dd7c1277bf219e45a595e966213dc2b Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 6 Jan 2017 13:01:42 -0700 Subject: [PATCH] Handle VMs missing consoles safely Signed-off-by: Zack Cerza --- teuthology/nuke/__init__.py | 6 +----- teuthology/nuke/actions.py | 2 ++ teuthology/orchestra/console.py | 2 +- teuthology/orchestra/remote.py | 5 ++++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/teuthology/nuke/__init__.py b/teuthology/nuke/__init__.py index 605072d7ae..987765c44c 100644 --- a/teuthology/nuke/__init__.py +++ b/teuthology/nuke/__init__.py @@ -294,11 +294,7 @@ def nuke_helper(ctx, should_unlock): host = target.split('@')[-1] shortname = host.split('.')[0] if should_unlock: - if 'vpm' in shortname: - return - status_info = get_status(host) - if is_vm(status=status_info) and \ - status_info['machine_type'] == 'openstack': + if is_vm(shortname): return log.debug('shortname: %s' % shortname) log.debug('{ctx}'.format(ctx=ctx)) diff --git a/teuthology/nuke/actions.py b/teuthology/nuke/actions.py index 6b37fea978..deaa1fff98 100644 --- a/teuthology/nuke/actions.py +++ b/teuthology/nuke/actions.py @@ -411,6 +411,8 @@ def check_console(hostname): remote = Remote(hostname) shortname = remote.shortname console = remote.console + if not console: + return cname = '{host}.{domain}'.format( host=shortname, domain=console.ipmidomain, diff --git a/teuthology/orchestra/console.py b/teuthology/orchestra/console.py index f12b4cacb1..c59c366531 100644 --- a/teuthology/orchestra/console.py +++ b/teuthology/orchestra/console.py @@ -322,7 +322,7 @@ class VirtualConsole(): if teuthology.lock.query.is_vm(status=status_info): phys_host = status_info['vm_host']['name'].split('.')[0] except TypeError: - return + raise RuntimeError("Cannot create a virtual console for %s", name) self.connection = libvirt.open(phys_host) for i in self.connection.listDomainsID(): d = self.connection.lookupByID(i) diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 572f4ad315..441ece30a7 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -471,6 +471,9 @@ def getRemoteConsole(name, ipmiuser=None, ipmipass=None, ipmidomain=None, Return either VirtualConsole or PhysicalConsole depending on name. """ if teuthology.lock.query.is_vm(name): - return console.VirtualConsole(name) + try: + return console.VirtualConsole(name) + except Exception: + return None return console.PhysicalConsole( name, ipmiuser, ipmipass, ipmidomain, logfile, timeout) -- 2.39.5