Skip to content

Commit

Permalink
ceph-volume api.lvm allow uuid suffixes in vg/lv creation
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 0283164)
  • Loading branch information
Alfredo Deza authored and andrewschoen committed Aug 29, 2018
1 parent d2ad39c commit 40998a6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/ceph-volume/ceph_volume/api/lvm.py
Expand Up @@ -401,7 +401,7 @@ def create_pv(device):
])


def create_vg(devices, name=None):
def create_vg(devices, name=None, name_prefix=None):
"""
Create a Volume Group. Command looks like::
Expand All @@ -412,10 +412,16 @@ def create_vg(devices, name=None):
:param devices: A list of devices to create a VG. Optionally, a single
device (as a string) can be used.
:param name: Optionally set the name of the VG, defaults to 'ceph-{uuid}'
:param name_prefix: Optionally prefix the name of the VG, which will get combined
with a UUID string
"""
if isinstance(devices, set):
devices = list(devices)
if not isinstance(devices, list):
devices = [devices]
if name is None:
if name_prefix:
name = "%s-%s" % (name_prefix, str(uuid.uuid4()))
elif name is None:
name = "ceph-%s" % str(uuid.uuid4())
process.run([
'vgcreate',
Expand Down Expand Up @@ -482,7 +488,7 @@ def remove_lv(path):
return True


def create_lv(name, group, extents=None, size=None, tags=None):
def create_lv(name, group, extents=None, size=None, tags=None, uuid_name=False):
"""
Create a Logical Volume in a Volume Group. Command looks like::
Expand All @@ -493,7 +499,11 @@ def create_lv(name, group, extents=None, size=None, tags=None):
conform to the convention of prefixing them with "ceph." like::
{"ceph.block_device": "/dev/ceph/osd-1"}
:param uuid_name: Optionally combine the ``name`` with UUID to ensure uniqueness
"""
if uuid_name:
name = '%s-%s' % (name, uuid.uuid4())
if tags is None:
tags = {
"ceph.osd_id": "null",
Expand Down

0 comments on commit 40998a6

Please sign in to comment.