Merge lp:~pitti/cloud-init/systemd-detect-virt into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Martin Pitt on 2016-01-28
Status: Merged
Merged at revision: 1160
Proposed branch: lp:~pitti/cloud-init/systemd-detect-virt
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 23 lines (+4/-2)
1 file modified
cloudinit/util.py (+4/-2)
To merge this branch: bzr merge lp:~pitti/cloud-init/systemd-detect-virt
Reviewer Review Type Date Requested Status
cloud-init Commiters 2016-01-28 Pending
Review via email: mp+284278@code.launchpad.net

Description of the change

As explained in https://launchpad.net/bugs/1539016, running-in-container is an (over-complicated) wrapper around systemd-detect-virt -c, and an Ubuntu-ism which I'd like to get rid of.

This adds systemd-detect-virt to the list of container tests. I figure we need to keep running-in-container as a fallback test for a while, to run older releases with newer cloud-inits.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/util.py'
2--- cloudinit/util.py 2015-09-01 17:26:03 +0000
3+++ cloudinit/util.py 2016-01-28 13:11:56 +0000
4@@ -76,7 +76,9 @@
5
6
7 # Helper utils to see if running in a container
8-CONTAINER_TESTS = ('running-in-container', 'lxc-is-container')
9+CONTAINER_TESTS = (['systemd-detect-virt', '--quiet', '--container'],
10+ ['running-in-container'],
11+ ['lxc-is-container'])
12
13
14 def decode_binary(blob, encoding='utf-8'):
15@@ -1749,7 +1751,7 @@
16 try:
17 # try to run a helper program. if it returns true/zero
18 # then we're inside a container. otherwise, no
19- subp([helper])
20+ subp(helper)
21 return True
22 except (IOError, OSError):
23 pass