Add size validations for volume clones

Adds the same validations as a volume add or resize to volume clones, to
ensure there is enough free space for them.
This commit is contained in:
2024-02-02 10:29:34 -05:00
parent efc7434143
commit a95e72008e
5 changed files with 63 additions and 13 deletions

View File

@ -4237,13 +4237,25 @@ def cli_storage_volume_rename(pool, name, new_name):
@click.argument("pool")
@click.argument("name")
@click.argument("new_name")
def cli_storage_volume_clone(pool, name, new_name):
@click.option(
"-f",
"--force",
"force_flag",
is_flag=True,
default=False,
help="Force clone even if volume would violate 80% full safe free space.",
)
def cli_storage_volume_clone(pool, name, new_name, force_flag):
"""
Clone a Ceph RBD volume with name NAME in pool POOL to name NEW_NAME in pool POOL.
PVC will prevent the clone of a volume who's new size is greater than the available free space on the pool. This cannot be overridden.
PVC will prevent the clone of a volume who's new size is greater than the 80% full safe free space on the pool. This can be overridden with the "-f"/"--force" option but this may be dangerous!
"""
retcode, retmsg = pvc.lib.storage.ceph_volume_clone(
CLI_CONFIG, pool, name, new_name
CLI_CONFIG, pool, name, new_name, force_flag=force_flag
)
finish(retcode, retmsg)

View File

@ -1294,15 +1294,15 @@ def ceph_volume_modify(
return retstatus, response.json().get("message", "")
def ceph_volume_clone(config, pool, volume, new_volume):
def ceph_volume_clone(config, pool, volume, new_volume, force_flag=False):
"""
Clone Ceph volume
API endpoint: POST /api/v1/storage/ceph/volume/{pool}/{volume}
API arguments: new_volume={new_volume
API arguments: new_volume={new_volume, force_flag={force_flag}
API schema: {"message":"{data}"}
"""
params = {"new_volume": new_volume}
params = {"new_volume": new_volume, "force_flag": force_flag}
response = call_api(
config,
"post",