]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume util.arg_validators optionally skip gpt header check
authorAlfredo Deza <adeza@redhat.com>
Wed, 28 Nov 2018 12:56:34 +0000 (07:56 -0500)
committerAlfredo Deza <adeza@redhat.com>
Fri, 30 Nov 2018 19:06:34 +0000 (14:06 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 58be4d0e18c4b2f3560361345f91c5a1c7b6c5c4)

src/ceph-volume/ceph_volume/util/arg_validators.py

index 534c9aa64673693c617f461ab14c897fc3f553ab..a04c19924bbd0d2b7745bc33f881768d01800a7b 100644 (file)
@@ -8,15 +8,22 @@ from ceph_volume.util.device import Device
 
 class ValidDevice(object):
 
-    def __init__(self, as_string=False):
+    def __init__(self, as_string=False, gpt_ok=False):
         self.as_string = as_string
+        self.gpt_ok = gpt_ok
 
     def __call__(self, string):
         device = Device(string)
         error = None
         if not device.exists:
             error = "Unable to proceed with non-existing device: %s" % string
-        elif device.has_gpt_headers:
+        # FIXME this is not a nice API, this validator was meant to catch any
+        # non-existing devices upfront, not check for gpt headers. Now this
+        # needs to optionally skip checking gpt headers which is beyond
+        # verifying if the device exists. The better solution would be to
+        # configure this with a list of checks that can be excluded/included on
+        # __init__
+        elif device.has_gpt_headers and not self.gpt_ok:
             error = "GPT headers found, they must be removed on: %s" % string
 
         if error: