From 5ce9597d3579e5f4ee6523b59c42f6b3ef2ece82 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 30 Aug 2017 14:11:52 -0400 Subject: [PATCH] ceph-volume lvm.prepare store the blkid uuid of a partition journal Signed-off-by: Alfredo Deza (cherry picked from commit 5160c5398bbf107bcc826696664c503aa52d0020) --- .../ceph_volume/devices/lvm/prepare.py | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py index 9139597b6ae6..1ca5b0d88540 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py @@ -3,8 +3,8 @@ import json import os from textwrap import dedent from ceph_volume.util import prepare as prepare_utils -from ceph_volume.util import system -from ceph_volume import conf, decorators +from ceph_volume.util import system, disk +from ceph_volume import conf, decorators, terminal from . import api from .common import prepare_parser @@ -51,23 +51,12 @@ 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_ptuuid(self, argument): + uuid = disk.get_partuuid(argument) + if not uuid: + terminal.error('blkid could not detect a PARTUUID for device: %s' % argument) + raise RuntimeError('unable to use device for a journal') + return uuid def get_journal_lv(self, argument): """ @@ -124,12 +113,15 @@ class Prepare(object): 'ceph.data_uuid': data_lv.lv_uuid, }) - # otherwise assume this is a regular disk, that will need to be - # created as a 'pv' + # allow a file + elif os.path.isfile(args.journal): + journal_uuid = '' + journal_device = args.journal + + # otherwise assume this is a regular disk partition else: - journal_pv = self.get_journal_pv(args.journal) - journal_device = journal_pv.pv_name - journal_uuid = journal_pv.pv_uuid + journal_uuid = self.get_journal_ptuuid(args.journal) + journal_device = args.journal data_lv.set_tags({ 'ceph.type': 'data', -- 2.47.3