From 321ee8735db2ce14c6450f24ee68a1168d8a512f Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 8 Nov 2017 13:06:15 -0700 Subject: [PATCH] Add a Console base class Signed-off-by: Zack Cerza --- teuthology/orchestra/console/base.py | 28 ++++++++++++++++++++++++ teuthology/orchestra/console/physical.py | 9 +++----- teuthology/orchestra/console/virtual.py | 6 +++-- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 teuthology/orchestra/console/base.py diff --git a/teuthology/orchestra/console/base.py b/teuthology/orchestra/console/base.py new file mode 100644 index 0000000000..e144418d9d --- /dev/null +++ b/teuthology/orchestra/console/base.py @@ -0,0 +1,28 @@ +import teuthology.orchestra.remote + + +class Console(object): + def __init__(self, name): + self.name = name + self.shortname = teuthology.orchestra.remote.getShortName(name) + + def check_power(self, state, timeout=None): + pass + + def check_status(self, timeout=None): + pass + + def hard_reset(self): + pass + + def power_cycle(self): + pass + + def power_on(self): + pass + + def power_off(self): + pass + + def power_off_for_interval(self, interval=30): + pass diff --git a/teuthology/orchestra/console/physical.py b/teuthology/orchestra/console/physical.py index d6546ec6b7..b9f71d7cdb 100644 --- a/teuthology/orchestra/console/physical.py +++ b/teuthology/orchestra/console/physical.py @@ -6,23 +6,20 @@ import subprocess import sys import time -import teuthology.orchestra.remote - from teuthology.config import config - from teuthology.exceptions import ConsoleError +from teuthology.orchestra.console.base import Console log = logging.getLogger(__name__) -class PhysicalConsole(): +class PhysicalConsole(Console): """ Physical Console (set from getRemoteConsole) """ def __init__(self, name, ipmiuser=None, ipmipass=None, ipmidomain=None, logfile=None, timeout=20): - self.name = name - self.shortname = teuthology.orchestra.remote.getShortName(name) + super(PhysicalConsole, self).__init__(name) self.timeout = timeout self.logfile = None self.ipmiuser = ipmiuser or config.ipmi_user diff --git a/teuthology/orchestra/console/virtual.py b/teuthology/orchestra/console/virtual.py index a89f51a18f..8905501e34 100644 --- a/teuthology/orchestra/console/virtual.py +++ b/teuthology/orchestra/console/virtual.py @@ -5,21 +5,23 @@ try: except ImportError: libvirt = None +from teuthology.orchestra.console.base import Console + import teuthology.lock.query import teuthology.lock.util log = logging.getLogger(__name__) -class VirtualConsole(): +class VirtualConsole(Console): """ Virtual Console (set from getRemoteConsole) """ def __init__(self, name): + super(VirtualConsole, self).__init__(name) if libvirt is None: raise RuntimeError("libvirt not found") - self.shortname = remote.getShortName(name) status_info = teuthology.lock.query.get_status(self.shortname) try: if teuthology.lock.query.is_vm(status=status_info): -- 2.39.5