]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Enable ClearLinux as a supported distribution for ceph-deploy 488/head
authorGanesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
Wed, 1 May 2019 18:20:25 +0000 (11:20 -0700)
committerGanesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
Wed, 16 Sep 2020 17:17:36 +0000 (10:17 -0700)
Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
ceph_deploy/hosts/__init__.py
ceph_deploy/hosts/clear/__init__.py [new file with mode: 0644]
ceph_deploy/hosts/clear/install.py [new file with mode: 0644]
ceph_deploy/hosts/clear/mon/__init__.py [new file with mode: 0644]
ceph_deploy/hosts/clear/uninstall.py [new file with mode: 0644]
ceph_deploy/hosts/remotes.py
ceph_deploy/util/pkg_managers.py

index 7472d4f2a09e5fa492ef8de96bff90e9e343c2fc..a2a79bec9f401ae55f9981ff00aa9681b3558477 100644 (file)
@@ -7,7 +7,7 @@ on the type of distribution/version we are dealing with.
 import logging
 from ceph_deploy import exc
 from ceph_deploy.util import versions
-from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel, arch, alt
+from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel, arch, alt, clear
 from ceph_deploy.connection import get_connection
 
 logger = logging.getLogger()
@@ -71,6 +71,7 @@ def get(hostname,
                                                'fedora', 'scientific', 'suse', 'oracle', 'virtuozzo', 'alt']
     module.is_deb = module.normalized_name in ['debian', 'ubuntu']
     module.is_pkgtarxz = module.normalized_name in ['arch']
+    module.is_swupd = module.normalized_name in ['clear']
     module.release = release
     module.codename = codename
     module.conn = conn
@@ -101,7 +102,8 @@ def _get_distro(distro, fallback=None, use_rhceph=False):
         'suse': suse,
         'virtuozzo': centos,
         'arch': arch,
-        'alt': alt
+        'alt': alt,
+        'clear': clear
         }
 
     if distro == 'redhat' and use_rhceph:
@@ -130,6 +132,8 @@ def _normalized_distro_name(distro):
         return 'arch'
     elif distro.startswith(('alt', 'altlinux', 'basealt', 'alt linux')):
         return 'alt'
+    elif distro.startswith('clear'):
+        return 'clear'
     return distro
 
 
diff --git a/ceph_deploy/hosts/clear/__init__.py b/ceph_deploy/hosts/clear/__init__.py
new file mode 100644 (file)
index 0000000..e1b3322
--- /dev/null
@@ -0,0 +1,25 @@
+from . import mon # noqa
+from .install import install # noqa
+from .uninstall import uninstall # noqa
+from ceph_deploy.util import pkg_managers
+
+# Allow to set some information about this distro
+#
+
+distro = None
+release = None
+codename = None
+
+
+def choose_init(module):
+    """
+    Select a init system
+
+    Returns the name of a init system (upstart, sysvinit ...).
+    """
+    # Currently clearlinux only has systemd.
+    return 'systemd'
+
+
+def get_packager(module):
+    return pkg_managers.Swupd(module)
diff --git a/ceph_deploy/hosts/clear/install.py b/ceph_deploy/hosts/clear/install.py
new file mode 100644 (file)
index 0000000..3741c3d
--- /dev/null
@@ -0,0 +1,14 @@
+
+def install(distro, version_kind, version, adjust_repos, **kw):
+    """
+    Install bundle that contains ceph on the clear host.
+
+    Since clear does not have alternate channels, we will just run the command
+    """
+    logger = distro.conn.logger
+    packages = ['storage-cluster']
+
+    logger.info("Installing storage-cluster bundle")
+    distro.packager.install(
+        packages
+        )
diff --git a/ceph_deploy/hosts/clear/mon/__init__.py b/ceph_deploy/hosts/clear/mon/__init__.py
new file mode 100644 (file)
index 0000000..f266fb0
--- /dev/null
@@ -0,0 +1,2 @@
+from ceph_deploy.hosts.common import mon_add as add  # noqa
+from ceph_deploy.hosts.common import mon_create as create  # noqa
diff --git a/ceph_deploy/hosts/clear/uninstall.py b/ceph_deploy/hosts/clear/uninstall.py
new file mode 100644 (file)
index 0000000..18423ee
--- /dev/null
@@ -0,0 +1,42 @@
+import logging
+
+from ceph_deploy.util.system import disable_service, stop_service
+
+SYSTEMD_UNITS = [
+    'ceph-mds.target',
+    'ceph-mon.target',
+    'ceph-osd.target',
+    'ceph-radosgw.target',
+    'ceph-fuse.target',
+    'ceph-mgr.target',
+    'ceph-rbd-mirror.target',
+    'ceph.target',
+    'ceph-mds*service',
+    'ceph-mon*service',
+    'ceph-osd*service',
+    'ceph-radosgw*service',
+    'ceph-fuse*service',
+    'ceph-mgr*service',
+    'ceph-rbd-mirror*service',
+    'ceph*service',
+]
+
+
+def uninstall(distro, purge=False):
+
+    hostname = distro.conn.hostname
+    LOG = logging.getLogger(hostname)
+
+    # I need to stop and disable services prior package removal
+    LOG.info('stopping and disabling services on {}'.format(hostname))
+    for unit in SYSTEMD_UNITS:
+        stop_service(distro.conn, unit)
+        disable_service(distro.conn, unit)
+
+    packages = [
+        'storage-cluster',
+        'ceph'
+        ]
+
+    distro.packager.remove(packages)
+    distro.packager.clean()
index 47dd0bf787d46678fc9224a160e78a7dffca67a0..049ebff0afd2cf7e7698ab1e548d012cd53f7fed 100644 (file)
@@ -161,6 +161,10 @@ def write_conf(cluster, conf, overwrite):
     tmp_file = tempfile.NamedTemporaryFile('w', dir='/etc/ceph', delete=False)
     err_msg = 'config file %s exists with different content; use --overwrite-conf to overwrite' % path
 
+    if not os.path.isdir('/etc/ceph'):
+        err_msg = '/etc/ceph/ does not exist - could not write config'
+        raise RuntimeError(err_msg)
+
     if os.path.exists(path):
         with open(path, 'r') as f:
             old = f.read()
@@ -169,15 +173,10 @@ def write_conf(cluster, conf, overwrite):
         tmp_file.write(conf)
         tmp_file.close()
         shutil.move(tmp_file.name, path)
-        os.chmod(path, 0o644)
-        return
-    if os.path.exists('/etc/ceph'):
+    else:
         with open(path, 'w') as f:
             f.write(conf)
-        os.chmod(path, 0o644)
-    else:
-        err_msg = '/etc/ceph/ does not exist - could not write config'
-        raise RuntimeError(err_msg)
+    os.chmod(path, 0o644)
 
 
 def write_keyring(path, key, uid=-1, gid=-1):
index feb167f39606a58725af0232372db9e0a03e757a..d05db5d8a9682b4d943a6c5653d2060a204941c0 100644 (file)
@@ -427,3 +427,53 @@ class AptRpm(PackageManager):
     def clean(self):
         cmd = self.executable + ['update']
         return self._run(cmd)
+
+
+class Swupd(PackageManager):
+    """
+    Swupd package manager from ClearLinux distribution
+    """
+
+    executable = [
+        'swupd',
+        ]
+    name = 'swupd'
+
+    def install(self, packages, **kw):
+        if isinstance(packages, str):
+            packages = [packages]
+
+        extra_flags = kw.pop('extra_install_flags', None)
+        # Prior to installing packages, make sure we create folders for ceph
+        # config and logging which do not exist in Clear
+        cmd = ['mkdir', '-p', '/etc/ceph/']
+        self._run(cmd)
+        cmd = ['mkdir', '-p', '/var/log/ceph/']
+        self._run(cmd)
+
+        cmd = self.executable + ['bundle-add']
+
+        if extra_flags:
+            if isinstance(extra_flags, str):
+                extra_flags = [extra_flags]
+            cmd.extend(extra_flags)
+        cmd.extend(packages)
+        return self._run(cmd)
+
+    def remove(self, packages, **kw):
+        if isinstance(packages, str):
+            packages = [packages]
+
+        extra_flags = kw.pop('extra_remove_flags', None)
+        cmd = self.executable + ['bundle-remove']
+
+        if extra_flags:
+            if isinstance(extra_flags, str):
+                extra_flags = [extra_flags]
+            cmd.extend(extra_flags)
+        cmd.extend(packages)
+        return self._run(cmd)
+
+    def clean(self):
+        cmd = self.executable + ['clean']
+        return self._run(cmd)