From 1441707222f843740fed4d7d66f46b5acf06f93d Mon Sep 17 00:00:00 2001 From: Warren Usui Date: Wed, 12 Jun 2013 14:21:14 -0700 Subject: [PATCH] Make reset of ssh key code conditional on being a virtual machine. Add and use is_vm to determine if we are running on a virtual machine. Fix #5364 Signed-off-by: Warren Usui --- teuthology/misc.py | 8 +++++--- teuthology/orchestra/remote.py | 3 ++- teuthology/task/internal.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 35e74c0223033..f5e7793e40aec 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -23,6 +23,7 @@ import datetime stamp = datetime.datetime.now().strftime("%y%m%d%H%M") global_jobid = None checked_jobid = False +is_vm = lambda x: x.startswith('vpm') or x.startswith('ubuntu@vpm') def get_testdir(ctx): if 'test_path' in ctx.teuthology_config: @@ -726,9 +727,10 @@ def reconnect(ctx, timeout, remotes=None): try: log.info('trying to connect to %s', remote.name) key = ctx.config['targets'][remote.name] - kstat = lockstatus.get_status(ctx,remote.name) - if 'sshpubkey' in kstat: - key = kstat['sshpubkey'] + if is_vm(remote.name): + kstat = lockstatus.get_status(ctx,remote.name) + if 'sshpubkey' in kstat: + key = kstat['sshpubkey'] from .orchestra import connection remote.ssh = connection.connect( user_at_host=remote.name, diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 47824d5ee3454..12fc924749a68 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -1,4 +1,5 @@ from . import run +from teuthology import misc import time class Remote(object): @@ -249,6 +250,6 @@ class VirtualConsole(): log.info('Power off for {i} seconds completed'.format(s=self.shortname, i=interval)) def getRemoteConsole(name, ipmiuser, ipmipass, ipmidomain, logfile=None, timeout=20): - if name.startswith('vpm'): + if misc.is_vm(name): return VirtualConsole(name, ipmiuser, ipmipass, ipmidomain, logfile, timeout) return PhysicalConsole(name, ipmiuser, ipmipass, ipmidomain, logfile, timeout) diff --git a/teuthology/task/internal.py b/teuthology/task/internal.py index 444341eb4e5bf..ebe9edcbefd2c 100644 --- a/teuthology/task/internal.py +++ b/teuthology/task/internal.py @@ -506,7 +506,7 @@ def vm_setup(ctx, config): editinfo = os.path.join(os.path.dirname(__file__),'edit_sudoers.sh') for remote in ctx.cluster.remotes.iterkeys(): mname = re.match(".*@([^\.]*)\..*", str(remote)).group(1) - if mname.startswith('vpm'): + if teuthology.is_vm(mname): r = remote.run(args=['test', '-e', '/ceph-qa-ready',], stdout=StringIO(), check_status=False,) -- 2.39.5