]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/ceph-disk/ceph_disk/main.py
update sources to v12.1.0
[ceph.git] / ceph / src / ceph-disk / ceph_disk / main.py
index a98350f99a0ce1836c91500cb897972504dc9272..414a63301d3b2ba96ea7b1cc9ad41d75d028537c 100755 (executable)
@@ -546,53 +546,6 @@ def command_check_call(arguments, exit=False):
         raise
 
 
-def platform_distro():
-    """
-    Returns a normalized, lower case string without any leading nor trailing
-    whitespace that represents the distribution name of the current machine.
-    """
-    distro = platform_information()[0] or ''
-    return distro.strip().lower()
-
-
-def platform_information():
-    if FREEBSD:
-        distro = platform.system()
-        release = platform.version().split()[1]
-        codename = platform.version().split()[3]
-        version = platform.version().split('-')[0][:-1]
-        major_version = version.split('.')[0]
-        major, minor = release.split('.')
-    else:
-        distro, release, codename = platform.linux_distribution()
-        # this could be an empty string in Debian
-        if not codename and 'debian' in distro.lower():
-            debian_codenames = {
-                '8': 'jessie',
-                '7': 'wheezy',
-                '6': 'squeeze',
-            }
-            major_version = release.split('.')[0]
-            codename = debian_codenames.get(major_version, '')
-
-            # In order to support newer jessie/sid,  wheezy/sid strings we test
-            # this if sid is buried in the minor, we should use sid anyway.
-            if not codename and '/' in release:
-                major, minor = release.split('/')
-                if minor == 'sid':
-                    codename = minor
-                else:
-                    codename = major
-        # this could be an empty string in Virtuozzo linux
-        if not codename and 'virtuozzo linux' in distro.lower():
-            codename = 'virtuozzo'
-
-    return (
-        str(distro).strip(),
-        str(release).strip(),
-        str(codename).strip()
-    )
-
 #
 # An alternative block_path implementation would be
 #
@@ -1988,7 +1941,9 @@ class Prepare(object):
             formatter_class=argparse.RawDescriptionHelpFormatter,
             description=textwrap.fill(textwrap.dedent("""\
             If the --bluestore argument is given, a bluestore objectstore
-            will be used instead of the legacy filestore objectstore.
+            will be created.  If --filestore is provided, a legacy FileStore
+            objectstore will be created.  If neither is specified, we default
+            to BlueStore.
 
             When an entire device is prepared for bluestore, two
             partitions are created. The first partition is for metadata,
@@ -2086,9 +2041,16 @@ class PrepareBluestore(Prepare):
         parser = argparse.ArgumentParser(add_help=False)
         parser.add_argument(
             '--bluestore',
-            action='store_true', default=None,
+            dest='bluestore',
+            action='store_true', default=True,
             help='bluestore objectstore',
         )
+        parser.add_argument(
+            '--filestore',
+            dest='bluestore',
+            action='store_false',
+            help='filestore objectstore',
+        )
         return parser
 
     @staticmethod
@@ -2445,15 +2407,22 @@ class PrepareBluestoreBlockDB(PrepareSpace):
         super(PrepareBluestoreBlockDB, self).__init__(args)
 
     def get_space_size(self):
-        block_size = get_conf(
+        block_db_size = get_conf(
             cluster=self.args.cluster,
             variable='bluestore_block_db_size',
         )
 
-        if block_size is None:
-            return 20480  # MB, default value
+        if block_db_size is None or int(block_db_size) == 0:
+            block_size = get_conf(
+                cluster=self.args.cluster,
+                variable='bluestore_block_size',
+            )
+            if block_size is None:
+                return 1024  # MB
+            size = int(block_size) / 100 / 1048576
+            return max(size, 1024)  # MB
         else:
-            return int(block_size) / 1048576  # MB
+            return int(block_db_size) / 1048576  # MB
 
     def desired_partition_number(self):
         if getattr(self.args, 'block.db') == self.args.data:
@@ -2996,6 +2965,11 @@ class PrepareFilestoreData(PrepareData):
         self.set_data_partition()
         self.populate_data_path_device(*to_prepare_list)
 
+    def populate_data_path(self, path, *to_prepare_list):
+        super(PrepareFilestoreData, self).populate_data_path(path,
+                                                             *to_prepare_list)
+        write_one_line(path, 'type', 'filestore')
+
 
 class PrepareBluestoreData(PrepareData):
 
@@ -3081,7 +3055,7 @@ def mkfs(
                 '--setgroup', get_ceph_group(),
             ],
         )
-    else:
+    elif osd_type == 'filestore':
         ceph_osd_mkfs(
             [
                 'ceph-osd',
@@ -3098,6 +3072,8 @@ def mkfs(
                 '--setgroup', get_ceph_group(),
             ],
         )
+    else:
+        raise Error('unrecognized objectstore type %s' % osd_type)
 
 
 def auth_key(
@@ -3312,8 +3288,8 @@ def start_daemon(
         elif os.path.exists(os.path.join(path, 'bsdrc')):
             command_check_call(
                 [
-                    '/usr/local/etc/rc.d/ceph start osd.{osd_id}'
-                    .format(osd_id=osd_id),
+                    '/usr/sbin/service', 'ceph', 'start',
+                    'osd.{osd_id}'.format(osd_id=osd_id),
                 ],
             )
         else:
@@ -4877,9 +4853,14 @@ def main_trigger(args):
 def main_fix(args):
     # A hash table containing 'path': ('uid', 'gid', blocking, recursive)
     fix_table = [
-        ('/etc/ceph', 'ceph', 'ceph', True, True),
+        ('/usr/bin/ceph-mon', 'root', 'root', True, False),
+        ('/usr/bin/ceph-mds', 'root', 'root', True, False),
+        ('/usr/bin/ceph-osd', 'root', 'root', True, False),
+        ('/usr/bin/radosgw', 'root', 'root', True, False),
+        ('/etc/ceph', 'root', 'root', True, True),
         ('/var/run/ceph', 'ceph', 'ceph', True, True),
         ('/var/log/ceph', 'ceph', 'ceph', True, True),
+        ('/var/log/radosgw', 'ceph', 'ceph', True, True),
         ('/var/lib/ceph', 'ceph', 'ceph', True, False),
     ]
 
@@ -4934,6 +4915,10 @@ def main_fix(args):
     # Use find to relabel + chown ~simultaenously
     if args.all:
         for directory, uid, gid, blocking, recursive in fix_table:
+            # Skip directories/files that are not installed
+            if not os.access(directory, os.F_OK):
+                continue
+
             c = [
                 'find',
                 directory,
@@ -4973,6 +4958,10 @@ def main_fix(args):
     # Fix permissions
     if args.permissions:
         for directory, uid, gid, blocking, recursive in fix_table:
+            # Skip directories/files that are not installed
+            if not os.access(directory, os.F_OK):
+                continue
+
             if recursive:
                 c = [
                     'chown',
@@ -5008,6 +4997,10 @@ def main_fix(args):
     # Fix SELinux labels
     if args.selinux:
         for directory, uid, gid, blocking, recursive in fix_table:
+            # Skip directories/files that are not installed
+            if not os.access(directory, os.F_OK):
+                continue
+
             if recursive:
                 c = [
                     'restorecon',
@@ -5631,7 +5624,9 @@ def main(argv):
         path = os.environ.get('PATH', os.defpath)
         os.environ['PATH'] = args.prepend_to_path + ":" + path
 
-    setup_statedir(args.statedir)
+    if args.func.__name__ != 'main_trigger':
+        # trigger may run when statedir is unavailable and does not use it
+        setup_statedir(args.statedir)
     setup_sysconfdir(args.sysconfdir)
 
     global CEPH_PREF_USER