]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume api.lvm fallback to 1 part if none are define when creating lvs 22508/head
authorAlfredo Deza <adeza@redhat.com>
Mon, 4 Jun 2018 18:08:44 +0000 (14:08 -0400)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 11 Jun 2018 14:47:18 +0000 (09:47 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 552d987233545f6f33b9220ea4ea98753f96962f)

src/ceph-volume/ceph_volume/api/lvm.py

index be1bb67d3a64d2141079f81fedb4034dc1fd54a2..0c4df928363f104fac95ff91f0db17be44e0343c 100644 (file)
@@ -423,7 +423,7 @@ def create_lv(name, group, size=None, tags=None):
     return lv
 
 
-def create_lvs(group, parts=None, size=None, name_prefix='ceph-lv'):
+def create_lvs(volume_group, parts=None, size=None, name_prefix='ceph-lv'):
     """
     Create multiple Logical Volumes from a Volume Group by calculating the
     proper extents from ``parts`` or ``size``. A custom prefix can be used
@@ -431,25 +431,22 @@ def create_lvs(group, parts=None, size=None, name_prefix='ceph-lv'):
 
     LV creation in ceph-volume will require tags, this is expected to be
     pre-computed by callers who know Ceph metadata like OSD IDs and FSIDs. It
-    will probably not be the case when mass-creating LVs, so common/default tags will be
-    set to ``"null"``.
+    will probably not be the case when mass-creating LVs, so common/default
+    tags will be set to ``"null"``.
 
-        ceph.empty dict is
+    .. note:: LVs that are not in use can be detected by querying LVM for tags that are
+              set to ``"null"``.
 
-    LVs that are not in use can be detected by querying LVM for tags that are
-    set to ``"null"``
-
-    :param group: The volume group (vg) to use for LV creation
+    :param volume_group: The volume group (vg) to use for LV creation
     :type group: ``VolumeGroup()`` object
     :param parts: Number of LVs to create *instead of* ``size``.
     :type parts: int
     :param size: Size (in gigabytes) of LVs to create, e.g. "as many 10gb LVs as possible"
     :type size: int
-
-    .. warning:: Only one of ``parts`` or ``size`` is allowed.
     """
     if parts is None and size is None:
-        raise RuntimeError("Unable to create lvs without 'parts' or 'size' being defined")
+        # fallback to just one part (using 100% of the vg)
+        parts = 1
     lvs = []
     tags = {
         "ceph.osd_id": "null",
@@ -457,12 +454,12 @@ def create_lvs(group, parts=None, size=None, name_prefix='ceph-lv'):
         "ceph.cluster_fsid": "null",
         "ceph.osd_fsid": "null",
     }
-    sizing = group.sizing(parts=parts, size=size)
+    sizing = volume_group.sizing(parts=parts, size=size)
     for part in range(0, sizing['parts']):
         size = sizing['sizes']
         lv_name = '%s-%s' % (name_prefix, uuid.uuid4())
         lvs.append(
-            create_lv(lv_name, group.name, size="%sg" % size, tags=tags)
+            create_lv(lv_name, volume_group.name, size="%sg" % size, tags=tags)
         )
     return lvs