Support the option volume_binds of docker run
Change-Id: I9e9dca7e42b48b4503fed390343f125f1cdec874 Implements: blueprint support-volume-binds
This commit is contained in:
parent
7010aabb8b
commit
c19ffb5a02
@ -200,12 +200,13 @@ 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>. Or use "
|
||||
"--mount size=<size>,destination=<path> to create a new volume "
|
||||
"the form --mount type=<local|cinder>,source=<volume>,"
|
||||
"destination=<path>. Or use --mount type=<local|cinder>,"
|
||||
"size=<size>,destination=<path> to create a new volume "
|
||||
"and mount to the container")
|
||||
parsed_mounts = []
|
||||
for mount in mounts:
|
||||
mount_info = {"source": "", "destination": "", "size": ""}
|
||||
mount_info = {"type": "", "source": "", "destination": "", "size": ""}
|
||||
for mnt in mount.split(","):
|
||||
try:
|
||||
k, v = mnt.split("=", 1)
|
||||
@ -220,11 +221,15 @@ def parse_mounts(mounts):
|
||||
else:
|
||||
raise apiexec.CommandError(err_msg % mnt)
|
||||
|
||||
if mount_info['type'] not in ["local", "cinder"]:
|
||||
raise apiexec.CommandError(err_msg % mnt)
|
||||
|
||||
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)
|
||||
if mount_info['type'] == 'cinder':
|
||||
if not mount_info['source'] and not mount_info['size']:
|
||||
raise apiexec.CommandError(err_msg % mnt)
|
||||
|
||||
parsed_mounts.append(mount_info)
|
||||
return parsed_mounts
|
||||
|
@ -166,7 +166,7 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
||||
self, mock_run, mock_show_container):
|
||||
mock_run.return_value = 'container'
|
||||
self._test_arg_success(
|
||||
'run --mount source=s,destination=d x')
|
||||
'run --mount type=local,source=s,destination=d x')
|
||||
mock_show_container.assert_called_once_with('container')
|
||||
|
||||
def test_zun_container_run_with_mount_invalid_format(self):
|
||||
|
Loading…
Reference in New Issue
Block a user