summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-09-14 15:41:39 -0400
committerScott Moser <smoser@ubuntu.com>2012-09-14 15:41:39 -0400
commit31a145068f259e1c2affbab066cfd028ae901836 (patch)
treeb99ea904fb54de4185a332d3c64cf73d8e50461c
parent75bec162045856b39b483d11a0b3a7a75886efd2 (diff)
parent18cbd9ae7872f83b4eaccdbdf2cf5023b92d7812 (diff)
downloadvyos-cloud-init-31a145068f259e1c2affbab066cfd028ae901836.tar.gz
vyos-cloud-init-31a145068f259e1c2affbab066cfd028ae901836.zip
remove 'start networking' from cloud-init-nonet
do not 'start networking' in cloud-init-nonet, but add cloud-init-container job that runs only if in container and emits net-device-added (LP: #1031065) LP: #1031065
-rw-r--r--ChangeLog3
-rw-r--r--upstart/cloud-init-container.conf51
-rw-r--r--upstart/cloud-init-nonet.conf2
3 files changed, 54 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 283d1464..aca34d6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
0.7.0:
+ - do not 'start networking' in cloud-init-nonet, but add
+ cloud-init-container job that runs only if in container and emits
+ net-device-added (LP: #1031065)
- search only top level dns for 'instance-data' in DataSourceEc2 (LP: #1040200)
- add support for config-drive-v2 (LP:#1037567)
- support creating users, including the default user.
diff --git a/upstart/cloud-init-container.conf b/upstart/cloud-init-container.conf
new file mode 100644
index 00000000..051c6e50
--- /dev/null
+++ b/upstart/cloud-init-container.conf
@@ -0,0 +1,51 @@
+# in a lxc container, events for network interfaces do not
+# get created or may be missed. This helps cloud-init-nonet along
+# by emitting those events if they have not been emitted.
+
+start on container
+stop on static-network-up
+task
+
+emits net-device-added
+
+console output
+
+script
+ # if we are inside a container, then we may have to emit the ifup
+ # events for 'auto' network devices.
+ set -f
+
+ # from /etc/network/if-up.d/upstart
+ MARK_DEV_PREFIX="/run/network/ifup."
+ MARK_STATIC_NETWORK_EMITTED="/run/network/static-network-up-emitted"
+ # if the all static network interfaces are already up, nothing to do
+ [ -f "$MARK_STATIC_NETWORK_EMITTED" ] && exit 0
+
+ # get list of all 'auto' interfaces. if there are none, nothing to do.
+ auto_list=$(ifquery --list --allow auto 2>/dev/null) || :
+ [ -z "$auto_list" ] && exit 0
+ set -- ${auto_list}
+ [ "$*" = "lo" ] && exit 0
+
+ # we only want to emit for interfaces that do not exist, so filter
+ # out anything that does not exist.
+ for iface in "$@"; do
+ [ "$iface" = "lo" ] && continue
+ # skip interfaces that are already up
+ [ -f "${MARK_DEV_PREFIX}${iface}" ] && continue
+
+ if [ -d /sys/net ]; then
+ # if /sys is mounted, and there is no /sys/net/iface, then no device
+ [ -e "/sys/net/$iface" ] && continue
+ else
+ # sys wasn't mounted, so just check via 'ifconfig'
+ ifconfig "$iface" >/dev/null 2>&1 || continue
+ fi
+ initctl emit --no-wait net-device-added "INTERFACE=$iface" &&
+ emitted="$emitted $iface" ||
+ echo "warn: ${UPSTART_JOB} failed to emit net-device-added INTERFACE=$iface"
+ done
+
+ [ -z "${emitted# }" ] ||
+ echo "${UPSTART_JOB}: emitted ifup for ${emitted# }"
+end script
diff --git a/upstart/cloud-init-nonet.conf b/upstart/cloud-init-nonet.conf
index 7b69e584..118ffc1c 100644
--- a/upstart/cloud-init-nonet.conf
+++ b/upstart/cloud-init-nonet.conf
@@ -18,8 +18,6 @@ script
[ -f /var/lib/cloud/instance/obj.pkl ] && exit 0
- start networking >/dev/null
-
short=10; long=120;
sleep ${short}
echo $UPSTART_JOB "waiting ${long} seconds for a network device."