]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume lvm.prepare make a journal a pv, use uuids always
authorAlfredo Deza <adeza@redhat.com>
Mon, 28 Aug 2017 20:52:33 +0000 (16:52 -0400)
committerAlfredo Deza <adeza@redhat.com>
Thu, 31 Aug 2017 19:56:14 +0000 (15:56 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 913cef2d01b91e12c16e42d268043886b62c72fa)

src/ceph-volume/ceph_volume/devices/lvm/prepare.py

index a9630ce48d0f86e5dfd97664300564b96199b2f4..9139597b6ae61465b9efe72dcc71b62f32c7bfba 100644 (file)
@@ -51,6 +51,24 @@ class Prepare(object):
     def __init__(self, argv):
         self.argv = argv
 
+    def get_journal_pv(self, argument):
+        # it is safe to get the pv by its name
+        device = api.get_pv(pv_name=argument)
+        if device:
+            # means this has an existing uuid, so we can use it without
+            # recreating it
+            if device.pv_uuid:
+                return device
+            # otherwise, we need to create it as a 'pv', ask back again for it
+            # as a pv, and return that
+            api.create_pv(argument)
+            return api.get_pv(pv_name=argument)
+        # if we get to this point, this should be a red flag, `prepare` probably is
+        # out of options to use anything so raise an error
+        raise RuntimeError(
+            '--journal specified an invalid or non-existent device: %s' % argument
+        )
+
     def get_journal_lv(self, argument):
         """
         Perform some parsing of the value of ``--journal`` so that the process
@@ -88,36 +106,40 @@ class Prepare(object):
 
             if not args.journal:
                 raise RuntimeError('--journal is required when using --filestore')
-            journal_device = None
-            journal_lv = self.get_journal_lv(args.journal)
 
-            # check if we have an actual path to a device, which is allowed
-            if not journal_lv:
-                if os.path.exists(args.journal):
-                    journal_device = args.journal
-                else:
-                    raise RuntimeError(
-                        '--journal specified an invalid or non-existent device: %s' % args.journal
-                    )
-            # Otherwise the journal_device is the path to the lv
-            else:
+            journal_lv = self.get_journal_lv(args.journal)
+            if journal_lv:
                 journal_device = journal_lv.lv_path
+                journal_uuid = journal_lv.lv_uuid
+                # we can only set tags on an lv, the pv (if any) can't as we
+                # aren't making it part of an lvm group (vg)
                 journal_lv.set_tags({
                     'ceph.type': 'journal',
                     'ceph.osd_fsid': fsid,
                     'ceph.osd_id': osd_id,
                     'ceph.cluster_fsid': cluster_fsid,
                     'ceph.journal_device': journal_device,
+                    'ceph.journal_uuid': journal_uuid,
                     'ceph.data_device': data_lv.lv_path,
+                    'ceph.data_uuid': data_lv.lv_uuid,
                 })
 
+            # otherwise assume this is a regular disk, that will need to be
+            # created as a 'pv'
+            else:
+                journal_pv = self.get_journal_pv(args.journal)
+                journal_device = journal_pv.pv_name
+                journal_uuid = journal_pv.pv_uuid
+
             data_lv.set_tags({
                 'ceph.type': 'data',
                 'ceph.osd_fsid': fsid,
                 'ceph.osd_id': osd_id,
                 'ceph.cluster_fsid': cluster_fsid,
                 'ceph.journal_device': journal_device,
+                'ceph.journal_uuid': journal_uuid,
                 'ceph.data_device': data_lv.lv_path,
+                'ceph.data_uuid': data_lv.lv_uuid,
             })
 
             prepare_filestore(