Merge "Add size option to "--mount" when run container"

This commit is contained in:
Zuul 2017-12-06 06:11:10 +00:00 committed by Gerrit Code Review
commit 7010aabb8b

View File

@ -200,10 +200,12 @@ def parse_command(command):
def parse_mounts(mounts):
err_msg = ("Invalid mounts argument '%s'. mounts arguments must be of "
"the form --mount source=<volume>,destination=<path>.")
"the form --mount source=<volume>,destination=<path>. Or use "
"--mount size=<size>,destination=<path> to create a new volume "
"and mount to the container")
parsed_mounts = []
for mount in mounts:
mount_info = {"source": "", "destination": ""}
mount_info = {"source": "", "destination": "", "size": ""}
for mnt in mount.split(","):
try:
k, v = mnt.split("=", 1)
@ -218,7 +220,10 @@ def parse_mounts(mounts):
else:
raise apiexec.CommandError(err_msg % mnt)
if not mount_info['source'] or not mount_info['destination']:
if not mount_info['destination']:
raise apiexec.CommandError(err_msg % mnt)
if not mount_info['source'] and not mount_info['size']:
raise apiexec.CommandError(err_msg % mnt)
parsed_mounts.append(mount_info)