From: Kyr Shatskyy Date: Fri, 15 Nov 2019 18:07:45 +0000 (+0100) Subject: orchestra/console: remove circular import X-Git-Tag: 1.1.0~188^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=245dbc7095da050eebef00f64fa13c4234cfed79;p=teuthology.git orchestra/console: remove circular import Signed-off-by: Kyr Shatskyy --- diff --git a/teuthology/orchestra/console.py b/teuthology/orchestra/console.py index 16a27a9df..6618710b8 100644 --- a/teuthology/orchestra/console.py +++ b/teuthology/orchestra/console.py @@ -11,8 +11,7 @@ import teuthology.lock.util from teuthology.config import config from teuthology.contextutil import safe_while from teuthology.exceptions import ConsoleError - -import remote +from teuthology.misc import host_shortname try: import libvirt @@ -22,14 +21,23 @@ except ImportError: log = logging.getLogger(__name__) -class PhysicalConsole(): +class RemoteConsole(): + def getShortName(self, name=None): + """ + Extract the name portion from remote name strings. + """ + hostname = (name or self.name).split('@')[-1] + return host_shortname(hostname) + + +class PhysicalConsole(RemoteConsole): """ Physical Console (set from getRemoteConsole) """ def __init__(self, name, ipmiuser=None, ipmipass=None, ipmidomain=None, logfile=None, timeout=20): self.name = name - self.shortname = remote.getShortName(name) + self.shortname = self.getShortName(name) self.timeout = timeout self.logfile = None self.ipmiuser = ipmiuser or config.ipmi_user @@ -306,7 +314,7 @@ class PhysicalConsole(): return proc -class VirtualConsole(): +class VirtualConsole(RemoteConsole): """ Virtual Console (set from getRemoteConsole) """ @@ -314,7 +322,7 @@ class VirtualConsole(): if libvirt is None: raise RuntimeError("libvirt not found") - self.shortname = remote.getShortName(name) + self.shortname = self.getShortName(name) status_info = teuthology.lock.query.get_status(self.shortname) try: if teuthology.lock.query.is_vm(status=status_info): diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 60436d917..2fae5a6d6 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -513,13 +513,6 @@ class Remote(object): self.ssh.close() -def getShortName(name): - """ - Extract the name portion from remote name strings. - """ - hostname = name.split('@')[-1] - return host_shortname(hostname) - def getRemoteConsole(name, ipmiuser=None, ipmipass=None, ipmidomain=None, logfile=None, timeout=20): """