Merge lp:~larryprice/libertine/update-configure-bind-mount into lp:libertine

Proposed by Larry Price
Status: Merged
Approved by: Christopher Townsend
Approved revision: 327
Merged at revision: 357
Proposed branch: lp:~larryprice/libertine/update-configure-bind-mount
Merge into: lp:libertine
Diff against target: 105 lines (+29/-13)
5 files modified
python/libertine/ChrootContainer.py (+6/-2)
python/libertine/LxdContainer.py (+8/-1)
python/libertine/utils.py (+2/-2)
tools/libertine-container-manager (+1/-2)
tools/libertine-lxc-manager (+12/-6)
To merge this branch: bzr merge lp:~larryprice/libertine/update-configure-bind-mount
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+313645@code.launchpad.net

Commit message

Update configure bind-mount logic given new lxd backend.

Description of the change

Update configure bind-mount logic given new lxd backend.

This allows directories mounted to /media/$USER to be accessed from /media/$USER instead of living in $HOME.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:325
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/282/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/585
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/473
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/473
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/473
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/473
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/595
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/577
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/577/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/577
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/577/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/577
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/577/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/577
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/577/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/282/rebuild

review: Approve (continuous-integration)
326. By Larry Price

merge

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
327. By Larry Price

exe l-c-m

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:327
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/296/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/602
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/488
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/488
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/488
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/488
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/612
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/594
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/594/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/594
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/594/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/594
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/594/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/594
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/594/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/296/rebuild

review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, this works. I had to manually mount a USB device in U8 since it doesn't support automatic mounting, but once I did that with the correct permissions, then the configured bind-mount showed up in /media/townsend/blah in the lxd container when using Terminator.

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'python/libertine/ChrootContainer.py'
2--- python/libertine/ChrootContainer.py 2017-01-03 17:51:30 +0000
3+++ python/libertine/ChrootContainer.py 2017-01-04 20:37:19 +0000
4@@ -194,8 +194,12 @@
5 mounts = self._sanitize_bind_mounts(utils.get_common_xdg_user_directories() + \
6 ContainersConfig().get_container_bind_mounts(self.container_id))
7 for user_dir in utils.generate_binding_directories(mounts, home_path):
8- user_dir_path = os.path.join(home_path, user_dir[1])
9- bind_mounts += " -b \"%s:%s\"" % (user_dir[0], user_dir_path)
10+ if os.path.isabs(user_dir[1]):
11+ path = user_dir[1]
12+ else:
13+ path = os.path.join(home_path, user_dir[1])
14+
15+ bind_mounts += " -b \"%s:%s\"" % (user_dir[0], path)
16
17 proot_cmd += bind_mounts
18
19
20=== modified file 'python/libertine/LxdContainer.py'
21--- python/libertine/LxdContainer.py 2017-01-04 19:36:35 +0000
22+++ python/libertine/LxdContainer.py 2017-01-04 20:37:19 +0000
23@@ -289,9 +289,16 @@
24 utils.get_logger().warning('Bind-mount path \'{}\' does not exist.'.format(user_dir[0]))
25 continue
26
27+ if os.path.isabs(user_dir[1]):
28+ path = user_dir[1]
29+ else:
30+ path = os.path.join(home_path, user_dir[1])
31+
32+ utils.get_logger().debug("Mounting {}:{} in container {}".format(user_dir[0], path, self._id))
33 self._container.devices[user_dir[1]] = {
34 'source': _readlink(user_dir[0]),
35- 'path': os.path.join(home_path, user_dir[1]),
36+ 'path': path,
37+ 'optional': 'true',
38 'type': 'disk'
39 }
40
41
42=== modified file 'python/libertine/utils.py'
43--- python/libertine/utils.py 2016-12-07 21:24:16 +0000
44+++ python/libertine/utils.py 2017-01-04 20:37:19 +0000
45@@ -127,8 +127,8 @@
46
47 name = dir
48 if name.startswith(prefix):
49- name = name.replace(prefix, '', 1)
50- name = name.lstrip('/')
51+ name = name.replace(prefix, '', 1).lstrip('/')
52+
53 if name in names:
54 binding_dirs.append((dir, "%s (%i)" % (name, names.count(name))))
55 else:
56
57=== modified file 'tools/libertine-container-manager'
58--- tools/libertine-container-manager 2017-01-03 18:22:35 +0000
59+++ tools/libertine-container-manager 2017-01-04 20:37:19 +0000
60@@ -290,7 +290,7 @@
61
62 # validate bind-mount
63 if not mount_path.startswith(os.environ['HOME']) and not mount_path.startswith('/media/%s' % os.environ['USER']):
64- libertine.utils.get_logger().error("Cannot mount '%s', mount path must be in $HOME or /media/$USER." % mount_path)
65+ libertine.utils.get_logger().error("Cannot mount {}, mount path must be in {} or /media/{}.".format(mount_path, os.environ['HOME'], os.environ['USER']))
66 sys.exit(1)
67 if mount_path.startswith('/media/%s' % os.environ['USER']) and \
68 self.containers_config.get_container_type(container_id) == 'lxc':
69@@ -313,7 +313,6 @@
70 sys.exit(1)
71 self.containers_config.delete_bind_mount(container_id, mount_path)
72
73-
74 else:
75 libertine.utils.get_logger().error("Configure called with no subcommand. See configure --help for usage.")
76 sys.exit(1)
77
78=== modified file 'tools/libertine-lxc-manager'
79--- tools/libertine-lxc-manager 2016-12-07 20:34:42 +0000
80+++ tools/libertine-lxc-manager 2017-01-04 20:37:19 +0000
81@@ -147,13 +147,19 @@
82
83 data_dir = libertine.utils.get_libertine_container_userdata_dir_path(container_id)
84 for user_dir in libertine.utils.generate_binding_directories(mounts, home_path):
85- user_dir_fullpath = os.path.join(data_dir, user_dir[1])
86- if not os.path.exists(user_dir_fullpath):
87- os.makedirs(user_dir_fullpath, exist_ok=True)
88-
89+ if os.path.isabs(user_dir[1]):
90+ path = user_dir[1].strip('/')
91+ fullpath = os.path.join(libertine.utils.get_libertine_container_rootfs_path(container_id), path)
92+ else:
93+ path = "{}/{}".format(home_path.strip('/'), user_dir[1])
94+ fullpath = os.path.join(data_dir, user_dir[1])
95+
96+ os.makedirs(fullpath, exist_ok=True)
97+
98+ libertine.utils.get_logger().debug("Mounting {}:{} in container {}".format(user_dir[0], path, container_id))
99 xdg_user_dir_entry = (
100- "%s %s/%s none bind,create=dir,optional"
101- % (user_dir[0], home_path.strip('/'), user_dir[1])
102+ "%s %s none bind,create=dir,optional"
103+ % (user_dir[0], path)
104 )
105 container.append_config_item("lxc.mount.entry", xdg_user_dir_entry)
106

Subscribers

People subscribed via source and target branches