aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Postiglione <andrea.postiglione@gmail.com>2022-04-03 16:05:05 +0200
committerAndrea Postiglione <andrea.postiglione@gmail.com>2022-04-03 16:05:05 +0200
commite7063905e35ee1725909a63cc0227f877d02c1a9 (patch)
treef06f7f0357d327275f737ef1bb6dbb6e4d519ead
parentmail-client/mailspring-bin: version bump to 1.10.2 (diff)
downloadguru-e7063905.tar.gz
guru-e7063905.tar.bz2
guru-e7063905.zip
sys-cluster/pcs 0.11.2 first release
Signed-off-by: Andrea Postiglione <andrea.postiglione@gmail.com>
-rw-r--r--sys-cluster/pcs/Manifest1
-rw-r--r--sys-cluster/pcs/files/pcs-0.11-gentoo-support.patch516
-rw-r--r--sys-cluster/pcs/files/pcs-0.11.initd35
-rw-r--r--sys-cluster/pcs/files/pcsd-0.11.initd27
-rw-r--r--sys-cluster/pcs/pcs-0.11.2.ebuild110
5 files changed, 689 insertions, 0 deletions
diff --git a/sys-cluster/pcs/Manifest b/sys-cluster/pcs/Manifest
index 95eae5e99..3b8504e14 100644
--- a/sys-cluster/pcs/Manifest
+++ b/sys-cluster/pcs/Manifest
@@ -1 +1,2 @@
DIST pcs-0.10.8.tar.gz 1852902 BLAKE2B ef023ca27c2dbd1d765e1d68f67a55c79f57b1dbc7d571b8f21e1c30f8a8510b1148459a0e683c682fb969c7635ef726c8e227b995d1a35dfd27894f40bdaa26 SHA512 8b9ba62279431e481d062e804d24480d2a274d2f4897a82149df6116ff3df2394d97a3ee77a6dee4c563d915bab0142124a8942524fcc4e894912086e865353c
+DIST pcs-0.11.2.tar.gz 1412048 BLAKE2B f94459516f3ad29061a80b3fbeb228eef687c7cbb181bd0af219e410d53b7618eb029a52d4cab8599511455183ecbc01e64ef3d5735350834bccf51b51aa291c SHA512 ee610a7626de8c6abeffc23943fd95250c8550bbff946cffed8f18748bb862694f7cbc384127e0f062f121f3c31b8197b4b5d4eb150c3efcb8045809e54c0bf5
diff --git a/sys-cluster/pcs/files/pcs-0.11-gentoo-support.patch b/sys-cluster/pcs/files/pcs-0.11-gentoo-support.patch
new file mode 100644
index 000000000..d2e6fb804
--- /dev/null
+++ b/sys-cluster/pcs/files/pcs-0.11-gentoo-support.patch
@@ -0,0 +1,516 @@
+diff -uPNr pcs-0.11.2/configure.ac pcs-0.11.2-openrc/configure.ac
+--- pcs-0.11.2/configure.ac 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/configure.ac 2022-04-02 16:47:45.968552397 +0200
+@@ -89,17 +89,17 @@
+ ])
+
+ # check for systemd
+-PKG_CHECK_MODULES([systemd], [systemd])
+-PCS_PKG_CHECK_VAR([SYSTEMD_UNIT_DIR_TMP], [systemd], [systemdsystemunitdir], [/usr/lib/systemd/system])
+-if test "${prefix}" != "/usr"; then
+- SYSTEMD_UNIT_DIR="${prefix}/$SYSTEMD_UNIT_DIR_TMP"
+-else
+- SYSTEMD_UNIT_DIR="$SYSTEMD_UNIT_DIR_TMP"
+-fi
+-AC_SUBST([SYSTEMD_UNIT_DIR])
+-PCS_PKG_CHECK_VAR([SYSTEMD_UNIT_PATH], [systemd], [systemdsystemunitpath],
+- [/etc/systemd/system:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:/usr/lib/systemd/system:/usr/lib/systemd/system:/lib/systemd/system])
+-AC_SUBST([SYSTEMD_UNIT_PATH])
++#PKG_CHECK_MODULES([systemd], [systemd])
++#PCS_PKG_CHECK_VAR([SYSTEMD_UNIT_DIR_TMP], [systemd], [systemdsystemunitdir], [/usr/lib/systemd/system])
++#if test "${prefix}" != "/usr"; then
++# SYSTEMD_UNIT_DIR="${prefix}/$SYSTEMD_UNIT_DIR_TMP"
++#else
++# SYSTEMD_UNIT_DIR="$SYSTEMD_UNIT_DIR_TMP"
++#fi
++#AC_SUBST([SYSTEMD_UNIT_DIR])
++#PCS_PKG_CHECK_VAR([SYSTEMD_UNIT_PATH], [systemd], [systemdsystemunitpath],
++# [/etc/systemd/system:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:/usr/lib/systemd/system:/usr/lib/systemd/system:/lib/systemd/system])
++#AC_SUBST([SYSTEMD_UNIT_PATH])
+
+ # check for ruby
+ AC_PATH_PROG([RUBY], [ruby])
+@@ -217,6 +217,15 @@
+ DISTROEXT=fedora
+ break
+ ;;
++ gentoo)
++ FOUND_DISTRO=1
++ CONFIGDIR="$sysconfdir/default"
++ PCSLIBDIR="$prefix/share"
++ PCMKDAEMONDIR="$prefix/libexec/pacemaker"
++ COROSYNCLOGDIR="$localstatedir/log/corosync"
++ DISTROEXT=gentoo
++ break
++ ;;
+ esac
+ done
+
+@@ -396,9 +405,9 @@
+ fi
+ AC_PATH_PROG([SYSTEMCTL], [systemctl])
+ if test "x$SYSTEMCTL" = "x"; then
+- AC_PATH_PROG([SERVICE], [service])
++ AC_PATH_PROG([SERVICE], [rc-service])
+ if test "x$SERVICE" = "x"; then
+- AC_MSG_ERROR([Unable to find systemctl or service in $PATH])
++ AC_MSG_ERROR([Unable to find systemctl or rc-service in $PATH])
+ fi
+ fi
+
+diff -uPNr pcs-0.11.2/pcs/common/services/drivers/__init__.py pcs-0.11.2-openrc/pcs/common/services/drivers/__init__.py
+--- pcs-0.11.2/pcs/common/services/drivers/__init__.py 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcs/common/services/drivers/__init__.py 2022-04-01 20:20:31.536218481 +0200
+@@ -1,2 +1,3 @@
+ from .systemd import SystemdDriver
+ from .sysvinit_rhel import SysVInitRhelDriver
++from .openrc_gentoo import OpenRCGentooDriver
+diff -uPNr pcs-0.11.2/pcs/common/services/drivers/openrc_gentoo.py pcs-0.11.2-openrc/pcs/common/services/drivers/openrc_gentoo.py
+--- pcs-0.11.2/pcs/common/services/drivers/openrc_gentoo.py 1970-01-01 01:00:00.000000000 +0100
++++ pcs-0.11.2-openrc/pcs/common/services/drivers/openrc_gentoo.py 2022-04-01 19:52:57.765788816 +0200
+@@ -0,0 +1,87 @@
++import os.path
++from typing import (
++ List,
++ Optional,
++)
++
++from .. import errors
++from ..interfaces import (
++ ExecutorInterface,
++ ServiceManagerInterface,
++)
++
++
++class OpenRCGentooDriver(ServiceManagerInterface):
++ def __init__(
++ self, executor: ExecutorInterface, rc_service_bin: str, rc_config_bin: str
++ ):
++ """
++ executor -- external commands used by this class are executed using
++ this object
++ rc_service_bin -- path to an executable used for starting and stopping
++ services and to check if a service is running
++ rc_config_bin -- path to an executable used for enabling, disabling and
++ listing available service and to check if service is enabled
++ """
++ self._executor = executor
++ self._rc_config_bin = rc_config_bin
++ self._rc_service_bin = rc_service_bin
++ self._available_services: List[str] = []
++
++ def start(self, service: str, instance: Optional[str] = None) -> None:
++ result = self._executor.run([self._rc_service_bin, service, "start"])
++ if result.retval != 0:
++ raise errors.StartServiceError(service, result.joined_output)
++
++ def stop(self, service: str, instance: Optional[str] = None) -> None:
++ result = self._executor.run([self._rc_service_bin, service, "stop"])
++ if result.retval != 0:
++ raise errors.StopServiceError(service, result.joined_output)
++
++ def enable(self, service: str, instance: Optional[str] = None) -> None:
++ result = self._executor.run([self._rc_config_bin, "add", service, "default"])
++ if result.retval != 0:
++ raise errors.EnableServiceError(service, result.joined_output)
++
++ def disable(self, service: str, instance: Optional[str] = None) -> None:
++ if not self.is_installed(service):
++ return
++ result = self._executor.run([self._rc_config_bin, "delete", service, "default"])
++ if result.retval != 0:
++ raise errors.DisableServiceError(service, result.joined_output)
++
++ def is_enabled(self, service: str, instance: Optional[str] = None) -> bool:
++ if not self._available_services:
++ self._available_services = self._get_available_services()
++ return ( service in self._available_services )
++
++ def is_running(self, service: str, instance: Optional[str] = None) -> bool:
++ result = self._executor.run([self._rc_service_bin, service, "status"]).stdout
++ return( result == " * status: started" )
++
++ def is_installed(self, service: str) -> bool:
++ return service in self.get_available_services()
++
++ def get_available_services(self) -> List[str]:
++ if not self._available_services:
++ self._available_services = self._get_available_services()
++ return self._available_services
++
++ def _get_available_services(self) -> List[str]:
++ result = self._executor.run([self._rc_config_bin])
++ if result.retval != 0:
++ return []
++
++ service_list = []
++ # skip first string that say 'Init scripts to be started by runlevel default'
++ for service in result.stdout.splitlines()[1:]:
++ service = service.strip()
++ if service:
++ service_list.append(service)
++ return service_list
++
++ def is_current_system_supported(self) -> bool:
++ return all(
++ os.path.isfile(binary)
++ for binary in (self._rc_service_bin, self._rc_config_bin)
++ )
+diff -uPNr pcs-0.11.2/pcs/lib/services.py pcs-0.11.2-openrc/pcs/lib/services.py
+--- pcs-0.11.2/pcs/lib/services.py 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcs/lib/services.py 2022-04-01 20:02:05.023001421 +0200
+@@ -84,6 +84,9 @@
+ services.drivers.SysVInitRhelDriver(
+ executor, settings.service_binary, settings.chkconfig_binary
+ ),
++ service.drivers.OpenRCGentooDriver(
++ executor, settings.rc_config_binary, settings.rc_service_binary
++ ),
+ ]
+
+ for driver in drivers:
+diff -uPNr pcs-0.11.2/pcs/Makefile.am pcs-0.11.2-openrc/pcs/Makefile.am
+--- pcs-0.11.2/pcs/Makefile.am 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcs/Makefile.am 2022-04-01 20:22:42.198605061 +0200
+@@ -131,6 +131,7 @@
+ common/services/drivers/__init__.py \
+ common/services/drivers/systemd.py \
+ common/services/drivers/sysvinit_rhel.py \
++ common/services/drivers/openrc_gentoo.py \
+ common/services_dto.py \
+ common/services/errors.py \
+ common/services/__init__.py \
+diff -uPNr pcs-0.11.2/pcs/settings.py.in pcs-0.11.2-openrc/pcs/settings.py.in
+--- pcs-0.11.2/pcs/settings.py.in 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcs/settings.py.in 2022-04-03 14:09:08.438232140 +0200
+@@ -4,6 +4,8 @@
+ systemd_unit_path = "@SYSTEMD_UNIT_PATH@".split(":")
+ chkconfig_binary = "/sbin/chkconfig"
+ service_binary = "@SERVICE@"
++rc_config_binary = "/usr/bin/rc-config"
++rc_service_binary = "/sbin/rc-service"
+ # Used only in utils.py in deprecated funcion
+ pacemaker_binaries = "@PCMKEXECPREFIX@/sbin"
+ corosync_binaries = "@COROEXECPREFIX@/sbin"
+@@ -52,8 +54,8 @@
+ cibadmin = "@PCMKEXECPREFIX@/sbin/cibadmin"
+ crm_mon_schema = "@PCMK_SCHEMA_DIR@/crm_mon.rng"
+ pacemaker_api_result_schema = "@PCMK_SCHEMA_DIR@/api/api-result.rng"
+-pcsd_var_location = "@LOCALSTATEDIR@/lib/pcsd"
+-pcsd_ruby_socket = "@LOCALSTATEDIR@/run/pcsd-ruby.socket"
++pcsd_var_location = "/var/lib/pcsd"
++pcsd_ruby_socket = "/var/run/pcsd.socket"
+ pcsd_cert_location = os.path.join(pcsd_var_location, "pcsd.crt")
+ pcsd_key_location = os.path.join(pcsd_var_location, "pcsd.key")
+ pcsd_known_hosts_location = os.path.join(pcsd_var_location, "known-hosts")
+@@ -63,7 +65,7 @@
+ )
+ pcsd_dr_config_location = os.path.join(pcsd_var_location, "disaster-recovery")
+ pcsd_exec_location = "@LIB_DIR@/pcsd"
+-pcsd_log_location = "@LOCALSTATEDIR@/log/pcsd/pcsd.log"
++pcsd_log_location = "/var/log/pcsd/pcsd.log"
+ pcsd_default_port = 2224
+ pcsd_config = "@CONF_DIR@/pcsd"
+ cib_dir = "@PCMK_CIB_DIR@"
+diff -uPNr pcs-0.11.2/pcsd/logrotate/pcsd.in pcs-0.11.2-openrc/pcsd/logrotate/pcsd.in
+--- pcs-0.11.2/pcsd/logrotate/pcsd.in 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcsd/logrotate/pcsd.in 2022-04-02 18:35:15.265764389 +0200
+@@ -1,4 +1,4 @@
+-@localstatedir@/log/pcsd/*.log {
++/var/log/pcsd/*.log {
+ rotate 5
+ weekly
+ missingok
+diff -uPNr pcs-0.11.2/pcsd/Makefile.am pcs-0.11.2-openrc/pcsd/Makefile.am
+--- pcs-0.11.2/pcsd/Makefile.am 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcsd/Makefile.am 2022-04-02 18:34:42.609049415 +0200
+@@ -80,8 +80,8 @@
+ cp -rp ../${PCSD_BUNDLED_DIR_ROOT_LOCAL}/* $(DESTDIR)${GEM_HOME}
+ rm -rf $(DESTDIR)${GEM_HOME}/cache
+ endif
+- $(MKDIR_P) -m 0700 $(DESTDIR)$(localstatedir)/log/pcsd
+- $(MKDIR_P) -m 0700 $(DESTDIR)$(localstatedir)/lib/pcsd
++ $(MKDIR_P) -m 0700 $(DESTDIR)/var/log/pcsd
++ $(MKDIR_P) -m 0700 $(DESTDIR)/var/lib/pcsd
+
+ uninstall-local:
+ rm -rf $(DESTDIR)/$(sysconfdir)/pam.d/pcsd
+@@ -89,5 +89,5 @@
+ if INSTALL_EMBEDDED_GEMS
+ rm -rf $(DESTDIR)/${GEM_HOME}
+ endif
+- rmdir $(DESTDIR)/$(localstatedir)/log/pcsd 2>/dev/null || :
+- rmdir $(DESTDIR)/$(localstatedir)/lib/pcsd 2>/dev/null || :
++ rmdir $(DESTDIR)/var/log/pcsd 2>/dev/null || :
++ rmdir $(DESTDIR)/var/lib/pcsd 2>/dev/null || :
+diff -uPNr pcs-0.11.2/pcsd/pam/pcsd.gentoo pcs-0.11.2-openrc/pcsd/pam/pcsd.gentoo
+--- pcs-0.11.2/pcsd/pam/pcsd.gentoo 1970-01-01 01:00:00.000000000 +0100
++++ pcs-0.11.2-openrc/pcsd/pam/pcsd.gentoo 2022-04-02 12:58:06.249036062 +0200
+@@ -0,0 +1,5 @@
++#%PAM-1.0
++auth include system-auth
++account include system-auth
++password include system-auth
++session include system-auth
+diff -uPNr pcs-0.11.2/pcsd/settings.rb.in pcs-0.11.2-openrc/pcsd/settings.rb.in
+--- pcs-0.11.2/pcsd/settings.rb.in 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcsd/settings.rb.in 2022-04-03 14:08:03.767014211 +0200
+@@ -2,9 +2,9 @@
+ PCS_EXEC = '@SBINDIR@/pcs'
+ PCS_INTERNAL_EXEC = '@LIB_DIR@/pcs/pcs_internal'
+ PCSD_EXEC_LOCATION = '@LIB_DIR@/pcsd'
+-PCSD_VAR_LOCATION = '@LOCALSTATEDIR@/lib/pcsd'
++PCSD_VAR_LOCATION = '/var/lib/pcsd'
+ PCSD_DEFAULT_PORT = 2224
+-PCSD_RUBY_SOCKET = '@LOCALSTATEDIR@/run/pcsd-ruby.socket'
++PCSD_RUBY_SOCKET = '/var/run/pcsd.socket'
+
+ CRT_FILE = File.join(PCSD_VAR_LOCATION, 'pcsd.crt')
+ KEY_FILE = File.join(PCSD_VAR_LOCATION, 'pcsd.key')
+diff -uPNr pcs-0.11.2/pcs_test/Makefile.am pcs-0.11.2-openrc/pcs_test/Makefile.am
+--- pcs-0.11.2/pcs_test/Makefile.am 2022-02-03 13:37:44.000000000 +0100
++++ pcs-0.11.2-openrc/pcs_test/Makefile.am 2022-04-01 20:23:35.837945885 +0200
+@@ -101,6 +101,7 @@
+ tier0/common/services/drivers/__init__.py \
+ tier0/common/services/drivers/test_systemd.py \
+ tier0/common/services/drivers/test_sysvinit_rhel.py \
++ tier0/common/services/drivers/test_openrc_gentoo.py \
+ tier0/common/services/__init__.py \
+ tier0/common/test_file.py \
+ tier0/common/test_host.py \
+diff -uPNr pcs-0.11.2/pcs_test/tier0/common/services/drivers/test_openrc_gentoo.py pcs-0.11.2-openrc/pcs_test/tier0/common/services/drivers/test_openrc_gentoo.py
+--- pcs-0.11.2/pcs_test/tier0/common/services/drivers/test_openrc_gentoo.py 1970-01-01 01:00:00.000000000 +0100
++++ pcs-0.11.2-openrc/pcs_test/tier0/common/services/drivers/test_openrc_gentoo.py 2022-04-01 20:29:57.272257820 +0200
+@@ -0,0 +1,232 @@
++from unittest import mock, TestCase
++
++
++from pcs.common.services import errors
++from pcs.common.services.drivers import OpenRCGentooDriver
++from pcs.common.services.interfaces import ExecutorInterface
++from pcs.common.services.types import ExecutorResult
++
++
++class Base(TestCase):
++ def setUp(self):
++ self.mock_executor = mock.MagicMock(spec_set=ExecutorInterface)
++ self.service = "service_name"
++ self.instance = "instance_name"
++ self.rc_service_bin = "rc_service_bin"
++ self.rc_config_bin = "rc_config_bin"
++ self.driver = OpenRCGentooDriver(
++ self.mock_executor, self.rc_service_bin, self.rc_config_bin
++ )
++
++
++class BaseTestMixin:
++ subcmd = None
++ exception = None
++ executable = None
++ driver_callback = staticmethod(lambda: None)
++
++ def test_success(self):
++ self.mock_executor.run.return_value = ExecutorResult(0, "", "")
++ self.driver_callback(self.service)
++ self.mock_executor.run.assert_called_once_with(
++ [self.executable, self.service, self.subcmd]
++ )
++
++ def test_instance_success(self):
++ self.mock_executor.run.return_value = ExecutorResult(0, "", "")
++ self.driver_callback(self.service, self.instance)
++ self.mock_executor.run.assert_called_once_with(
++ [self.executable, self.service, self.subcmd]
++ )
++
++ def test_failure(self):
++ result = ExecutorResult(1, "stdout", "stderr")
++ self.mock_executor.run.return_value = result
++ with self.assertRaises(self.exception) as cm:
++ self.driver_callback(self.service)
++
++ self.assertEqual(cm.exception.service, self.service)
++ self.assertEqual(cm.exception.message, result.joined_output)
++ self.assertIsNone(cm.exception.instance)
++ self.mock_executor.run.assert_called_once_with(
++ [self.executable, self.service, self.subcmd]
++ )
++
++ def test_instace_failure(self):
++ result = ExecutorResult(1, "stdout", "stderr")
++ self.mock_executor.run.return_value = result
++ with self.assertRaises(self.exception) as cm:
++ self.driver_callback(self.service, self.instance)
++
++ self.assertEqual(cm.exception.service, self.service)
++ self.assertEqual(cm.exception.message, result.joined_output)
++ self.assertIsNone(cm.exception.instance)
++ self.mock_executor.run.assert_called_once_with(
++ [self.executable, self.service, self.subcmd]
++ )
++
++
++class StartTest(Base, BaseTestMixin):
++ subcmd = "start"
++ exception = errors.StartServiceError
++
++ def setUp(self):
++ super().setUp()
++ self.driver_callback = self.driver.start
++ self.executable = self.rc_service_bin
++
++
++class StopTest(Base, BaseTestMixin):
++ subcmd = "stop"
++ exception = errors.StopServiceError
++
++ def setUp(self):
++ super().setUp()
++ self.driver_callback = self.driver.stop
++ self.executable = self.service_bin
++
++
++class EnableTest(Base, BaseTestMixin):
++ subcmd = "on"
++ exception = errors.EnableServiceError
++
++ def setUp(self):
++ super().setUp()
++ self.driver_callback = self.driver.enable
++ self.executable = self.rc_config_bin
++
++
++class DisableTest(Base, BaseTestMixin):
++ subcmd = "off"
++ exception = errors.DisableServiceError
++
++ def setUp(self):
++ super().setUp()
++ # pylint: disable=protected-access
++ self.driver._available_services = [self.service]
++ self.driver_callback = self.driver.disable
++ self.executable = self.rc_config_bin
++
++ def test_not_intalled(self):
++ # pylint: disable=protected-access
++ self.driver._available_services = [f"not_{self.service}"]
++ self.driver_callback(self.service)
++ self.mock_executor.run.assert_not_called()
++
++
++class IsEnabledTest(Base):
++ def test_enabled(self):
++ self.mock_executor.run.return_value = ExecutorResult(0, "", "")
++ self.assertTrue(self.driver.is_enabled(self.service))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_config_bin, self.service]
++ )
++
++ def test_instance_enabled(self):
++ self.mock_executor.run.return_value = ExecutorResult(0, "", "")
++ self.assertTrue(self.driver.is_enabled(self.service, self.instance))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_config_bin, self.service]
++ )
++
++ def test_disabled(self):
++ self.mock_executor.run.return_value = ExecutorResult(3, "", "")
++ self.assertFalse(self.driver.is_enabled(self.service))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_config_bin, self.service]
++ )
++
++ def test_failure(self):
++ self.mock_executor.run.return_value = ExecutorResult(1, "", "")
++ self.assertFalse(self.driver.is_enabled(self.service))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_config_bin, self.service]
++ )
++
++
++class IsRunningTest(Base):
++ def test_running(self):
++ self.mock_executor.run.return_value = ExecutorResult(
++ 0, " * status: started", ""
++ )
++ self.assertTrue(self.driver.is_running(self.service))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_service_bin, self.service, "status"]
++ )
++
++ def test_instance_running(self):
++ self.mock_executor.run.return_value = ExecutorResult(
++ 0, " * status: started", ""
++ )
++ self.assertTrue(self.driver.is_running(self.service, self.instance))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_service_bin, self.service, "status"]
++ )
++
++ def test_not_running(self):
++ self.mock_executor.run.return_value = ExecutorResult(
++ 0, " * status: stopped", ""
++ )
++ self.assertFalse(self.driver.is_running(self.service))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_service_bin, self.service, "status"]
++ )
++
++ def test_failure(self):
++ self.mock_executor.run.return_value = ExecutorResult(1, "", "error")
++ self.assertFalse(self.driver.is_running(self.service))
++ self.mock_executor.run.assert_called_once_with(
++ [self.rc_service_bin, self.service, "status"]
++ )
++
++
++class IsInstalledTest(Base):
++ def test_installed(self):
++ output = (
++ "Init scripts to be started by runlevel default\n"
++ " service1\n"
++ " abc\n"
++ " xyz\n"
++ f" {self.service}\n"
++ )
++ self.mock_executor.run.return_value = ExecutorResult(0, output, "")
++ self.assertTrue(self.driver.is_installed(self.service))
++ # Intentionally called twice to make sure that unit files listing is
++ # done only once
++ self.assertTrue(self.driver.is_installed(self.service))
++ self.mock_executor.run.assert_called_once_with([self.rc_config_bin])
++
++ def test_not_installed(self):
++ output = (
++ "Init scripts to be started by runlevel default\n"
++ " service1\n"
++ " abc\n"
++ " xyz\n"
++ )
++ self.mock_executor.run.return_value = ExecutorResult(0, output, "")
++ self.assertFalse(self.driver.is_installed(self.service))
++ # Intentionally called twice to make sure that unit files listing is
++ # done only once
++ self.assertFalse(self.driver.is_installed(self.service))
++ self.mock_executor.run.assert_called_once_with([self.rc_config_bin])
++
++
++class GetAvailableServicesTest(Base):
++ def test_success(self):
++ output = (
++ "Init scripts to be started by runlevel default\n"
++ " service1\n"
++ " abc\n"
++ " xyz\n"
++ )
++ self.mock_executor.run.return_value = ExecutorResult(0, output, "")
++ self.assertEqual(
++ self.driver.get_available_services(),
++ ["service1", "abc", "xyz"],
++ )
++ self.mock_executor.run.assert_called_once_with([self.rc_config_bin])
++
++ def test_failure(self):
++ self.mock_executor.run.return_value = ExecutorResult(1, "", "error")
++ self.assertEqual(self.driver.get_available_services(), [])
++ self.mock_executor.run.assert_called_once_with([self.rc_config_bin])
diff --git a/sys-cluster/pcs/files/pcs-0.11.initd b/sys-cluster/pcs/files/pcs-0.11.initd
new file mode 100644
index 000000000..62ed7cccd
--- /dev/null
+++ b/sys-cluster/pcs/files/pcs-0.11.initd
@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+# Copyright 2019-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+name="pcs"
+description="Pacemaker & Corosync configuration daemon"
+command=/usr/sbin/pcs
+command_args="${pcsd_args}"
+
+PIDFILE=/var/run/$name.pid
+
+# load defaults
+if [ -f /etc/default/pcsd ]; then source /etc/default/pcsd; fi
+
+depend() {
+ need net pcsd-daemon
+ use syslog
+}
+
+start() {
+ nc=0
+ ebegin "Starting $description"
+
+ mkdir -p /var/run
+
+ start-stop-daemon --start -q --exec $command $command_args \
+ --pidfile "${PIDFILE}" --make-pidfile --background
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping $description"
+ start-stop-daemon --stop -q --pidfile "${PIDFILE}"
+ eend $?
+}
diff --git a/sys-cluster/pcs/files/pcsd-0.11.initd b/sys-cluster/pcs/files/pcsd-0.11.initd
new file mode 100644
index 000000000..da144d8e0
--- /dev/null
+++ b/sys-cluster/pcs/files/pcsd-0.11.initd
@@ -0,0 +1,27 @@
+#!/sbin/openrc-run
+# Copyright 2019-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+name="pcsd"
+description="PCS GUI and remote configuration interface (Ruby)"
+command=/usr/sbin/pcsd
+command_args="${pcsd_args}"
+
+PIDFILE=/var/run/$name.pid
+
+start() {
+ nc=0
+ ebegin "Starting $description"
+
+ mkdir -p /var/run
+
+ start-stop-daemon --start -q --exec $command $command_args \
+ --pidfile "${PIDFILE}" --make-pidfile --background
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping $description"
+ start-stop-daemon --stop -q --pidfile "${PIDFILE}"
+ eend $?
+}
diff --git a/sys-cluster/pcs/pcs-0.11.2.ebuild b/sys-cluster/pcs/pcs-0.11.2.ebuild
new file mode 100644
index 000000000..7cdce0605
--- /dev/null
+++ b/sys-cluster/pcs/pcs-0.11.2.ebuild
@@ -0,0 +1,110 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_SETUPTOOLS=rdepend
+PYTHON_COMPAT=( python3_{9..10} )
+USE_RUBY="ruby27 ruby30 ruby31"
+
+inherit autotools systemd python-single-r1 ruby-ng
+
+DESCRIPTION="Pacemaker/Corosync Configuration System"
+HOMEPAGE="https://github.com/ClusterLabs/pcs"
+SRC_URI="https://github.com/ClusterLabs/pcs/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
+S="${WORKDIR}/all/${P}"
+
+LICENSE="GPL-2"
+KEYWORDS="~amd64"
+IUSE="systemd"
+SLOT=0
+
+DEPEND="
+ dev-libs/libffi
+ sys-apps/coreutils
+"
+RDEPEND="
+ ${DEPEND}
+ ${PYTHON_DEPS}
+ $(python_gen_cond_dep '
+ dev-python/dacite[${PYTHON_USEDEP}]
+ dev-python/lxml[${PYTHON_USEDEP}]
+ dev-python/pycurl[${PYTHON_USEDEP}]
+ dev-python/pyparsing[${PYTHON_USEDEP}]
+ dev-python/python-dateutil[${PYTHON_USEDEP}]
+ >=www-servers/tornado-6.0[${PYTHON_USEDEP}]
+ <www-servers/tornado-7.0[${PYTHON_USEDEP}]
+ dev-python/pyagentx[${PYTHON_USEDEP}]
+ dev-python/cryptography[${PYTHON_USEDEP}]
+ dev-python/setuptools[${PYTHON_USEDEP}]
+ dev-python/setuptools_scm[${PYTHON_USEDEP}]
+ dev-python/pip[${PYTHON_USEDEP}]
+ dev-python/python-dateutil[${PYTHON_USEDEP}]
+ ')
+ >=sys-cluster/corosync-3.0
+ >=sys-cluster/pacemaker-2.1.0
+ sys-libs/pam
+ sys-process/psmisc
+"
+
+ruby_add_rdepend "
+ dev-ruby/bundler
+ dev-ruby/rubygems
+ dev-ruby/backports
+ dev-ruby/power_assert
+ dev-ruby/daemons
+ dev-ruby/ethon
+ dev-ruby/eventmachine
+ dev-ruby/mustermann
+ dev-ruby/open4
+ dev-ruby/rack
+ dev-ruby/rack-protection
+ dev-ruby/rack-test
+ dev-ruby/sinatra
+ www-servers/thin"
+
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+PATCHES="${FILESDIR}/pcs-0.11-gentoo-support.patch"
+
+src_prepare() {
+ default
+ eautoreconf
+}
+
+src_configure() {
+ econf
+}
+
+src_compile() {
+ return
+}
+
+src_install() {
+ python-single-r1_pkg_setup
+
+ local makeopts=(
+ DESTDIR="${D}"
+ )
+
+ emake install "${makeopts[@]}"
+
+ # mark log directories to be kept
+ keepdir /var/log/pcsd
+ keepdir /var/lib/pcsd
+
+ #fix statedir
+ sed -i ${D}/usr/share/pcsd/pcsd -e 's/\/var\/lib\/lib\//\/var\/lib\//g'
+
+ # custom service file for openRC
+ if ! use systemd ; then
+ newinitd "${FILESDIR}/pcs-0.11.initd" pcs
+ newinitd "${FILESDIR}/pcsd-0.11.initd" pcsd
+ fi
+
+ if use systemd ; then
+ systemd_newunit "${S}/pcsd/pcsd.service.in" "pcs.service"
+ systemd_newunit "${S}/pcsd/pcsd-ruby.service.in" "pcsd.service"
+ fi
+
+ python_optimize
+}