From 6a4c5c4f078833027c3849d2f3aa43653c03acad Mon Sep 17 00:00:00 2001 From: jjmccann-cisco Date: Fri, 29 Jan 2021 10:05:57 -0500 Subject: [PATCH] cloudpulse support for podman Change-Id: I3023dbd5a0070bff67562a717638202f2a3fd07a --- .../plugins/operator_tests/operator.py | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/cloudpulse/scenario/plugins/operator_tests/operator.py b/cloudpulse/scenario/plugins/operator_tests/operator.py index 102060b..8aad1bd 100644 --- a/cloudpulse/scenario/plugins/operator_tests/operator.py +++ b/cloudpulse/scenario/plugins/operator_tests/operator.py @@ -34,6 +34,10 @@ TESTS_OPTS = [ cfg.BoolOpt('containerized', default=True, help='enable if the processes are running as containers'), + cfg.StrOpt('container_type', + default='docker', + choices=['docker', 'podman'], + help='container type'), cfg.StrOpt('rabbit_container', default='rabbitmq', help='name of the rabitmq container'), @@ -102,8 +106,8 @@ def execute(command): return {'status': p.returncode, 'output': stdout.decode('utf-8')} -def get_container_name(name): - cmd = "ansible -o all -i 127.0.0.1, -a 'docker ps' -u root" +def get_container_name(name, container_command='docker'): + cmd = "ansible -o all -i 127.0.0.1, -a '%s ps' -u root" % container_command op = execute(cmd) if op['status']: return None @@ -141,6 +145,7 @@ class operator_scenario(base.Scenario): def load(self): self.os_node_info_obj = openstack_node_info_reader( cfg.CONF.operator_test.operator_setup_file) + self.container_command = cfg.CONF.operator_test.container_type @base.scenario(admin_only=False, operator=True) def rabbitmq_check(self): @@ -150,8 +155,8 @@ class operator_scenario(base.Scenario): is_containerized = cfg.CONF.operator_test.containerized if is_containerized: - rabbit_container = get_container_name('rabbitmq') - cmd = ("'docker exec %s %s'" % (rabbit_container, cmd)) + rabbit_container = get_container_name('rabbitmq', self.container_command) + cmd = ("'%s exec %s %s'" % (self.container_command, rabbit_container, cmd)) cmd = anscmd + cmd + " -u root " @@ -200,9 +205,9 @@ class operator_scenario(base.Scenario): is_containerized = cfg.CONF.operator_test.containerized if is_containerized: - galera_container = get_container_name('mariadb') + galera_container = get_container_name('mariadb', self.container_command) - cmd = ("'docker exec %s %s'" % (galera_container, cmd)) + cmd = ("'%s exec %s %s'" % (self.container_command, galera_container, cmd)) cmd = anscmd + cmd + ' -u root' res = execute(cmd) @@ -229,8 +234,8 @@ class operator_scenario(base.Scenario): nodeip_list = [node.ip for node in node_list] anscmd = "ansible -o all -i %s -a " % ','.join(nodeip_list) - cmd = "'docker ps -a --format \{\{.Names\}\} --filter %s '" \ - % "status=exited" + cmd = ("'%s ps -a --format \{\{.Names\}\} --filter %s '" \ + % (self.container_command, "status=exited")) cmd = anscmd + cmd + ' -u root' res = execute(cmd) @@ -305,8 +310,8 @@ class operator_scenario(base.Scenario): cmd = (r"ceph -f json status") is_containerized = cfg.CONF.operator_test.containerized if is_containerized: - ceph_container = get_container_name("cephmon") - cmd = ("'docker exec %s %s'" % (ceph_container, cmd)) + ceph_container = get_container_name("cephmon", self.container_command) + cmd = ("'%s exec %s %s'" % (self.container_command, ceph_container, cmd)) anscmd = "ansible -o all -i 127.0.0.1, -a " cmd = anscmd + cmd + ' -u root'