diff options
author | Arif Ali <arif.ali@canonical.com> | 2023-12-18 08:29:26 +0000 |
---|---|---|
committer | Arif Ali <arif-ali@users.noreply.github.com> | 2024-02-12 10:34:10 +0000 |
commit | 2d0badd086fb5c0a0e6b4db160666514b173c97d (patch) | |
tree | 742d9a466e7c1317a93a14400f7d4ac584d005ce | |
parent | db3f4cf56bb8f8782ada99df64f435decf5c99fa (diff) | |
download | sos-2d0badd086fb5c0a0e6b4db160666514b173c97d.tar.gz |
[openstack] Add collection of commands
Similar to how we do in openstack_nova, collect commands from as many
of the openstack projects.
Resolves: SET-337
Signed-off-by: Arif Ali <arif.ali@canonical.com>
-rw-r--r-- | sos/report/plugins/openstack_cinder.py | 61 | ||||
-rw-r--r-- | sos/report/plugins/openstack_glance.py | 13 | ||||
-rw-r--r-- | sos/report/plugins/openstack_heat.py | 16 | ||||
-rw-r--r-- | sos/report/plugins/openstack_neutron.py | 28 | ||||
-rw-r--r-- | sos/report/plugins/openstack_nova.py | 27 | ||||
-rw-r--r-- | sos/report/plugins/openstack_placement.py | 32 |
6 files changed, 153 insertions, 24 deletions
diff --git a/sos/report/plugins/openstack_cinder.py b/sos/report/plugins/openstack_cinder.py index 56f65cce..02627d13 100644 --- a/sos/report/plugins/openstack_cinder.py +++ b/sos/report/plugins/openstack_cinder.py @@ -13,6 +13,7 @@ # See the LICENSE file in the source distribution for further information. from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +import os class OpenStackCinder(Plugin): @@ -48,6 +49,66 @@ class OpenStackCinder(Plugin): "cinder-manage " + cinder_config + " db version", suggest_filename="cinder_db_version" ) + self.add_cmd_output( + f"cinder-manage {cinder_config} backup list" + ) + self.add_cmd_output( + f"cinder-manage {cinder_config} config list" + ) + self.add_cmd_output( + f"cinder-manage {cinder_config} host list" + ) + self.add_cmd_output( + f"cinder-status {cinder_config} upgrade check" + ) + + vars_all = [p in os.environ for p in [ + 'OS_USERNAME', 'OS_PASSWORD']] + + vars_any = [p in os.environ for p in [ + 'OS_TENANT_NAME', 'OS_PROJECT_NAME']] + + if not (all(vars_all) and any(vars_any)): + self.soslog.warning("Not all environment variables set. " + "Source the environment file for the user " + "intended to connect to the OpenStack " + "environment.") + else: + list_cmds = [ + "backend pool", + "group type", + "message", + "qos", + "service", + "type", + ] + + for cmd in list_cmds: + self.add_cmd_output(f"openstack volume {cmd} list") + + list_cmds_projects = [ + "backup", + "group", + "group snapshot", + "snapshot", + "transfer request", + "", + ] + + for cmd in list_cmds_projects: + self.add_cmd_output( + f"openstack volume {cmd} list --all-projects" + ) + + # get details for each volume + cmd = "openstack volume list -f value --all-projects" + res = self.exec_cmd(cmd) + if res['status'] == 0: + cinder_volumes = res['output'] + for volume in cinder_volumes.splitlines(): + volume = volume.split()[0] + cmd = f"openstack volume show {volume}" + self.add_cmd_output(cmd) self.add_forbidden_path('/etc/cinder/volumes') self.add_copy_spec([ diff --git a/sos/report/plugins/openstack_glance.py b/sos/report/plugins/openstack_glance.py index c8ec8fff..987f63d6 100644 --- a/sos/report/plugins/openstack_glance.py +++ b/sos/report/plugins/openstack_glance.py @@ -70,7 +70,16 @@ class OpenStackGlance(Plugin): "intended to connect to the OpenStack " "environment.") else: - self.add_cmd_output("openstack image list --long") + res = self.collect_cmd_output( + "openstack image list --long" + ) + + if res['status'] == 0: + glance_images = res['output'] + for image in glance_images.splitlines()[3:-1]: + image = image.split()[1] + cmd = f"openstack image show {image}" + self.add_cmd_output(cmd) self.add_file_tags({ "/etc/glance/glance-api.conf": "glance_api_conf", @@ -117,7 +126,7 @@ class DebianGlance(OpenStackGlance, DebianPlugin, UbuntuPlugin): 'python-glance', 'python3-glance', ) - service_name = 'glance-api.service' + service_name = 'apache2.service' class RedHatGlance(OpenStackGlance, RedHatPlugin): diff --git a/sos/report/plugins/openstack_heat.py b/sos/report/plugins/openstack_heat.py index 3d046039..83849d00 100644 --- a/sos/report/plugins/openstack_heat.py +++ b/sos/report/plugins/openstack_heat.py @@ -52,7 +52,21 @@ class OpenStackHeat(Plugin): "intended to connect to the OpenStack " "environment.") else: - self.add_cmd_output("openstack stack list") + self.add_cmd_output("openstack stack list --all-projects " + "--nested") + + res = self.collect_cmd_output( + "openstack stack list --all-projects" + ) + + if res['status'] == 0: + heat_stacks = res['output'] + for stack in heat_stacks.splitlines()[3:-1]: + stack = stack.split()[1] + cmd = f"openstack stack show {stack}" + self.add_cmd_output(cmd) + cmd = f"openstack stack resource list {stack} -n 10" + self.add_cmd_output(cmd) if self.get_option("all_logs"): self.add_copy_spec([ diff --git a/sos/report/plugins/openstack_neutron.py b/sos/report/plugins/openstack_neutron.py index feb4a924..dd8328e9 100644 --- a/sos/report/plugins/openstack_neutron.py +++ b/sos/report/plugins/openstack_neutron.py @@ -55,14 +55,26 @@ class OpenStackNeutron(Plugin): "the environment file for the user intended " "to connect to the OpenStack environment.") else: - self.add_cmd_output("openstack subnet list") - self.add_cmd_output("openstack port list") - self.add_cmd_output("openstack router list") - self.add_cmd_output("openstack network agent list") - self.add_cmd_output("openstack network list") - self.add_cmd_output("openstack extension list") - self.add_cmd_output("openstack floating ip list") - self.add_cmd_output("openstack security group list") + cmds = [ + "subnet", + "port", + "router", + "network agent", + "network", + "extension", + "floating ip", + "security group", + ] + + for cmd in cmds: + res = self.collect_cmd_output(f"openstack {cmd} list") + + if res['status'] == 0: + neutron_items = res['output'] + for item in neutron_items.splitlines()[3:-1]: + item = item.split()[1] + show_cmd = f"openstack {cmd} show {item}" + self.add_cmd_output(show_cmd) self.add_file_tags({ ".*/etc/neutron/plugins/ml2/ml2_conf.ini": "neutronml2_conf", diff --git a/sos/report/plugins/openstack_nova.py b/sos/report/plugins/openstack_nova.py index d6ad7039..eaa905b3 100644 --- a/sos/report/plugins/openstack_nova.py +++ b/sos/report/plugins/openstack_nova.py @@ -71,24 +71,25 @@ class OpenStackNova(Plugin): "intended to connect to the OpenStack " "environment.") else: - self.add_cmd_output("nova service-list") + self.add_cmd_output("openstack compute service list") self.add_cmd_output("openstack flavor list --long") - self.add_cmd_output("nova network-list") - self.add_cmd_output("nova list --all-tenants") - self.add_cmd_output("nova agent-list") + self.add_cmd_output("openstack compute agent list") self.add_cmd_output("nova version-list") - self.add_cmd_output("nova hypervisor-list") + self.add_cmd_output("openstack hypervisor list") self.add_cmd_output("openstack quota show") self.add_cmd_output("openstack hypervisor stats show") + + res = self.collect_cmd_output( + "openstack server list --all-projects" + ) + # get details for each nova instance - cmd = "openstack server list -f value" - nova_instances = self.exec_cmd(cmd)['output'] - for instance in nova_instances.splitlines(): - instance = instance.split()[0] - cmd = "openstack server show %s" % (instance) - self.add_cmd_output( - cmd, - suggest_filename="instance-" + instance + ".log") + if res['status'] == 0: + nova_instances = res['output'] + for instance in nova_instances.splitlines()[3:-1]: + instance = instance.split()[1] + cmd = f"openstack server show {instance}" + self.add_cmd_output(cmd) if self.get_option("all_logs"): self.add_copy_spec([ diff --git a/sos/report/plugins/openstack_placement.py b/sos/report/plugins/openstack_placement.py index 6d63cb35..027c71c2 100644 --- a/sos/report/plugins/openstack_placement.py +++ b/sos/report/plugins/openstack_placement.py @@ -9,6 +9,7 @@ # See the LICENSE file in the source distribution for further information. from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +import os class OpenStackPlacement(Plugin): @@ -39,6 +40,37 @@ class OpenStackPlacement(Plugin): suggest_filename="placement-manage_db_version" ) + vars_all = [p in os.environ for p in [ + 'OS_USERNAME', 'OS_PASSWORD']] + + vars_any = [p in os.environ for p in [ + 'OS_TENANT_NAME', 'OS_PROJECT_NAME']] + + if not (all(vars_all) and any(vars_any)): + self.soslog.warning("Not all environment variables set. " + "Source the environment file for the user " + "intended to connect to the OpenStack " + "environment.") + else: + res = self.collect_cmd_output( + "openstack resource provider list" + ) + + if res['status'] == 0: + resource_provider_list = res['output'] + for provider in resource_provider_list.splitlines()[3:-1]: + res_provider = provider.split()[1] + sub_cmds = [ + "inventory", + "trait", + "aggregate", + ] + self.add_cmd_output([ + f"openstack resource provider {sub_cmd} list " + f"{res_provider}" + for sub_cmd in sub_cmds + ]) + if self.get_option("all_logs"): self.add_copy_spec([ "/var/log/placement/", |