]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add _console_command()
authorZack Cerza <zack@redhat.com>
Tue, 23 Aug 2016 20:57:50 +0000 (14:57 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 30 Aug 2016 16:47:33 +0000 (10:47 -0600)
This provides a way to generate a command that establishes a SOL console
session that, depending on whether conserver settings are present, will
use that or fall back to ipmitool.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/console.py
teuthology/orchestra/test/test_console.py

index 4ebce301e02e3c22e7f478939bcbdb975d7d923c..e2dcd0096daad1d05c8d3c4d02a2302b743ed496 100644 (file)
@@ -68,6 +68,16 @@ class PhysicalConsole():
         )
         return child
 
+    def _console_command(self):
+        if self.has_conserver:
+            return 'console -M {master} -p {port} {host}'.format(
+                master=self.conserver_master,
+                port=self.conserver_port,
+                host=self.shortname,
+            )
+        else:
+            return self._build_command('sol activate')
+
     def _build_command(self, subcommand):
         template = \
             'ipmitool -H {s}.{dn} -I lanplus -U {ipmiuser} -P {ipmipass} {cmd}'
index 297f347fa7d5ac719b5fc991e7ab112e1c970f39..0782d13391f44b5183c27548df6271f7a25fa5c7 100644 (file)
@@ -9,29 +9,62 @@ class TestConsole(object):
 
 class TestPhysicalConsole(TestConsole):
     klass = console.PhysicalConsole
+    ipmi_cmd_templ = 'ipmitool -H {h}.{d} -I lanplus -U {u} -P {p} {c}'
+    conserver_cmd_templ = 'console -M {m} -p {p} {h}'
 
     def setup(self):
+        self.hostname = 'host'
         teuth_config.ipmi_domain = 'ipmi_domain'
         teuth_config.ipmi_user = 'ipmi_user'
         teuth_config.ipmi_password = 'ipmi_pass'
-        self.hostname = 'host'
+        teuth_config.conserver_master = 'conserver_master'
+        teuth_config.conserver_port = 3109
+
+    def test_console_command_conserver(self):
+        cons = self.klass(
+            self.hostname,
+            teuth_config.ipmi_user,
+            teuth_config.ipmi_password,
+            teuth_config.ipmi_domain,
+        )
+        cons.has_conserver = True
+        console_cmd = cons._console_command()
+        assert console_cmd == self.conserver_cmd_templ.format(
+            m=teuth_config.conserver_master,
+            p=teuth_config.conserver_port,
+            h=self.hostname,
+        )
 
-    def test_build_command(self):
-        cmd_templ = 'ipmitool -H {h}.{d} -I lanplus -U {u} -P {p} {c}'
+    def test_console_command_ipmi(self):
+        teuth_config.conserver_master = None
         cons = self.klass(
             self.hostname,
             teuth_config.ipmi_user,
             teuth_config.ipmi_password,
             teuth_config.ipmi_domain,
         )
-        sol_cmd = cons._build_command('sol activate')
-        assert sol_cmd == cmd_templ.format(
+        sol_cmd = cons._console_command()
+        assert sol_cmd == self.ipmi_cmd_templ.format(
             h=self.hostname,
             d=teuth_config.ipmi_domain,
             u=teuth_config.ipmi_user,
             p=teuth_config.ipmi_password,
             c='sol activate',
         )
+
+    def test_build_command_ipmi(self):
+        cons = self.klass(
+            self.hostname,
+            teuth_config.ipmi_user,
+            teuth_config.ipmi_password,
+            teuth_config.ipmi_domain,
+        )
         pc_cmd = cons._build_command('power cycle')
-        assert pc_cmd == sol_cmd.replace('sol activate', 'power cycle')
+        assert pc_cmd == self.ipmi_cmd_templ.format(
+            h=self.hostname,
+            d=teuth_config.ipmi_domain,
+            u=teuth_config.ipmi_user,
+            p=teuth_config.ipmi_password,
+            c='power cycle',
+        )