Skip to content

Commit

Permalink
Add a target size < current size sanity check to symmetrix "array res…
Browse files Browse the repository at this point in the history
…ize"

And a --force flag to bypass.
  • Loading branch information
cvaroqui committed Sep 28, 2017
1 parent ae194c8 commit 3b4cc0b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/rcSymmetrix.py
Expand Up @@ -29,6 +29,9 @@
"dev": Option(
"--dev", action="store", dest="dev",
help="The device id (ex: 00A04)"),
"force": Option(
"--force", action="store_true", dest="force",
help="bypass the downsize sanity check."),
"pair": Option(
"--pair", action="store", dest="pair",
help="The device id pair (ex: 00A04:00A04)"),
Expand Down Expand Up @@ -117,6 +120,7 @@
"msg": "Resize a thin device.",
"options": [
OPT.dev,
OPT.force,
OPT.size,
],
},
Expand Down Expand Up @@ -818,7 +822,7 @@ def rename_disk(self, dev=None, name=None, **kwargs):
if ret != 0:
raise ex.excError(err)

def resize_disk(self, dev=None, size=None, **kwargs):
def resize_disk(self, dev=None, size=None, force=False, **kwargs):
if dev is None:
raise ex.excError("The '--dev' parameter is mandatory")
if size is None:
Expand All @@ -827,12 +831,16 @@ def resize_disk(self, dev=None, size=None, **kwargs):
if len(dev_data) != 1:
raise ex.excError("device %s does not exist" % dev)
dev_data = dev_data[0]
current_size = int(dev_data["Capacity"]["megabytes"])
if size.startswith("+"):
incr = convert_size(size.lstrip("+"), _to="MB")
current_size = int(dev_data["Capacity"]["megabytes"])
size = str(current_size + incr)
else:
size = str(convert_size(size, _to="MB"))
if not force and int(size) < current_size:
raise ex.excError("the target size is smaller than the current "
"size. refuse to process. use --force if you "
"accept the data loss risk.")
if "RDF" in dev_data:
rdf_data = dev_data["RDF"]
else:
Expand Down

0 comments on commit 3b4cc0b

Please sign in to comment.