From 65d681c27e4ef94db419dad7fa5a40002126e4eb Mon Sep 17 00:00:00 2001 From: sidharthamani Date: Wed, 1 Jun 2016 17:21:31 -0700 Subject: [PATCH] allow shared/slave flags for docker volumes --- cattle/plugins/docker/compute.py | 7 +++++-- tests/docker/instance_activate_volumes | 2 +- tests/test_docker.py | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cattle/plugins/docker/compute.py b/cattle/plugins/docker/compute.py index 9c5bd6f..79f96fa 100644 --- a/cattle/plugins/docker/compute.py +++ b/cattle/plugins/docker/compute.py @@ -699,8 +699,11 @@ def _setup_volumes(self, create_config, instance, start_config, client): if len(parts) == 1: volumes_map[parts[0]] = {} else: - read_only = len(parts) == 3 and parts[2] == 'ro' - bind = {'bind': parts[1], 'ro': read_only} + if len(parts) == 3: + mode = parts[2] + else: + mode = 'rw' + bind = {'bind': parts[1], 'mode': mode} binds_map[parts[0]] = bind create_config['volumes'] = volumes_map start_config['binds'] = binds_map diff --git a/tests/docker/instance_activate_volumes b/tests/docker/instance_activate_volumes index 16ab9e5..3ea2d98 100644 --- a/tests/docker/instance_activate_volumes +++ b/tests/docker/instance_activate_volumes @@ -29,7 +29,7 @@ "imageUuid": "docker:ibuildthecloud/helloworld", "command": "sleep 5", "publishAllPorts": true, - "dataVolumes": ["/proc:/host/proc", "/sys:/host/sys:ro", "/random"], + "dataVolumes": ["/proc:/host/proc", "/sys:/host/sys:ro", "/random", "/slave_test:/slave_test:Z"], "startOnCreate": true } }, diff --git a/tests/test_docker.py b/tests/test_docker.py index 645b39e..7a04234 100644 --- a/tests/test_docker.py +++ b/tests/test_docker.py @@ -1191,7 +1191,7 @@ def post(req, resp): assert inspect['Volumes']['/volumes_from_path_by_uuid'] is not None assert inspect['Volumes']['/volumes_from_path_by_id'] is not None - assert len(inspect['Volumes']) == 5 + assert len(inspect['Volumes']) == 6 assert inspect['VolumesRW'] == { '/host/proc': True, @@ -1199,10 +1199,12 @@ def post(req, resp): '/random': True, '/volumes_from_path_by_uuid': True, '/volumes_from_path_by_id': True, - + '/slave_test': True, } - assert set(['/sys:/host/sys:ro', '/proc:/host/proc:rw']) == set( + assert set(['/sys:/host/sys:ro', + '/proc:/host/proc:rw', + '/slave_test:/slave_test:Z']) == set( inspect['HostConfig']['Binds']) instance_activate_common_validation(resp)