Blame SOURCES/sos-bz1717882-openstack-placement.patch

5baea9
From b5d72bd91c8685e3551d6e796ca8559304b45785 Mon Sep 17 00:00:00 2001
5baea9
From: Lee Yarwood <lyarwood@redhat.com>
5baea9
Date: Mon, 24 Dec 2018 10:03:59 +0000
5baea9
Subject: [PATCH] [openstack] Extract Placement plugin from Nova
5baea9
5baea9
The OpenStack Placement service is being extracted from Nova [1]
5baea9
duringthe Stein development cycle [2]. This change extracts the
5baea9
required plugin logic from the original Nova plugin into a new
5baea9
Placement plugin ahead of this extraction.
5baea9
5baea9
[1] https://docs.openstack.org/placement/latest/
5baea9
[2] https://releases.openstack.org/stein/schedule.html
5baea9
5baea9
Co-Authored-by: Piotr Kopec <pkopec@redhat.com>
5baea9
5baea9
Resolves: #1676
5baea9
5baea9
Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
5baea9
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
5baea9
---
5baea9
 sos/plugins/openstack_placement.py | 112 +++++++++++++++++++++++++++++
5baea9
 1 file changed, 112 insertions(+)
5baea9
 create mode 100644 sos/plugins/openstack_placement.py
5baea9
5baea9
diff --git a/sos/plugins/openstack_placement.py b/sos/plugins/openstack_placement.py
5baea9
new file mode 100644
5baea9
index 00000000..26b1a520
5baea9
--- /dev/null
5baea9
+++ b/sos/plugins/openstack_placement.py
5baea9
@@ -0,0 +1,112 @@
5baea9
+# Copyright (C) 2019 Red Hat, Inc., Lee Yarwood <lyarwood@redhat.com>
5baea9
+
5baea9
+# This file is part of the sos project: https://github.com/sosreport/sos
5baea9
+#
5baea9
+# This copyrighted material is made available to anyone wishing to use,
5baea9
+# modify, copy, or redistribute it subject to the terms and conditions of
5baea9
+# version 2 of the GNU General Public License.
5baea9
+#
5baea9
+# See the LICENSE file in the source distribution for further information.
5baea9
+
5baea9
+from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
5baea9
+
5baea9
+
5baea9
+class OpenStackPlacement(Plugin):
5baea9
+    """OpenStack Placement
5baea9
+    """
5baea9
+    plugin_name = "openstack_placement"
5baea9
+    profiles = ('openstack', 'openstack_controller')
5baea9
+
5baea9
+    var_puppet_gen = "/var/lib/config-data/puppet-generated/placement"
5baea9
+
5baea9
+    def setup(self):
5baea9
+
5baea9
+        # collect commands output only if the openstack-placement-api service
5baea9
+        # is running
5baea9
+
5baea9
+        in_container = self.running_in_container()
5baea9
+
5baea9
+        if self.service_is_running('openstack-placement-api') or in_container:
5baea9
+            placement_config = ""
5baea9
+            # if containerized we need to pass the config to the cont.
5baea9
+            if in_container:
5baea9
+                placement_config = "--config-dir " + self.var_puppet_gen + \
5baea9
+                                "/etc/placement/"
5baea9
+            self.add_cmd_output(
5baea9
+                "placement-manage " + placement_config + " db version",
5baea9
+                suggest_filename="placement-manage_db_version"
5baea9
+            )
5baea9
+
5baea9
+        if self.get_option("all_logs"):
5baea9
+            self.add_copy_spec([
5baea9
+                "/var/log/placement/",
5baea9
+                "/var/log/containers/placement/",
5baea9
+                "/var/log/containers/httpd/placement-api/"
5baea9
+            ])
5baea9
+        else:
5baea9
+            self.add_copy_spec([
5baea9
+                "/var/log/placement/*.log",
5baea9
+                "/var/log/containers/placement/*.log",
5baea9
+                "/var/log/containers/httpd/placement-api/*log",
5baea9
+            ])
5baea9
+
5baea9
+        self.add_copy_spec([
5baea9
+            "/etc/placement/",
5baea9
+            self.var_puppet_gen + "/etc/placement/",
5baea9
+            self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf",
5baea9
+            self.var_puppet_gen + "/etc/httpd/conf/",
5baea9
+            self.var_puppet_gen + "/etc/httpd/conf.d/",
5baea9
+            self.var_puppet_gen + "/etc/httpd/conf.modules.d/*.conf",
5baea9
+        ])
5baea9
+
5baea9
+    def running_in_container(self):
5baea9
+        for runtime in ["docker", "podman"]:
5baea9
+            container_status = self.get_command_output(runtime + " ps")
5baea9
+            if container_status['status'] == 0:
5baea9
+                for line in container_status['output'].splitlines():
5baea9
+                    if line.endswith("placement_api"):
5baea9
+                        return True
5baea9
+        return False
5baea9
+
5baea9
+    def apply_regex_sub(self, regexp, subst):
5baea9
+        self.do_path_regex_sub("/etc/placement/*", regexp, subst)
5baea9
+        self.do_path_regex_sub(
5baea9
+            self.var_puppet_gen + "/etc/placement/*",
5baea9
+            regexp, subst
5baea9
+        )
5baea9
+
5baea9
+    def postproc(self):
5baea9
+        protect_keys = ["password"]
5baea9
+        connection_keys = ["database_connection", "slave_connection"]
5baea9
+
5baea9
+        self.apply_regex_sub(
5baea9
+            r"((?m)^\s*(%s)\s*=\s*)(.*)" % "|".join(protect_keys),
5baea9
+            r"\1*********"
5baea9
+        )
5baea9
+        self.apply_regex_sub(
5baea9
+            r"((?m)^\s*(%s)\s*=\s*(.*)://(\w*):)(.*)(@(.*))" %
5baea9
+            "|".join(connection_keys),
5baea9
+            r"\1*********\6"
5baea9
+        )
5baea9
+
5baea9
+
5baea9
+class DebianPlacement(OpenStackPlacement, DebianPlugin, UbuntuPlugin):
5baea9
+
5baea9
+    packages = ('placement')
5baea9
+
5baea9
+    def setup(self):
5baea9
+        super(DebianPlacement, self).setup()
5baea9
+
5baea9
+
5baea9
+class RedHatPlacement(OpenStackPlacement, RedHatPlugin):
5baea9
+
5baea9
+    packages = ('openstack-selinux')
5baea9
+
5baea9
+    def setup(self):
5baea9
+        super(RedHatPlacement, self).setup()
5baea9
+        if self.get_option("all_logs"):
5baea9
+            self.add_copy_spec("/var/log/httpd/placement*")
5baea9
+        else:
5baea9
+            self.add_copy_spec("/var/log/httpd/placement*.log")
5baea9
+
5baea9
+# vim: set et ts=4 sw=4 :
5baea9
-- 
5baea9
2.21.0
5baea9