Merge lp:~josvaz/vmbuilder/jenkins_kvm+ethx-fixed into lp:~ubuntu-on-ec2/vmbuilder/jenkins_kvm

Proposed by Jose L. VG
Status: Merged
Merged at revision: 772
Proposed branch: lp:~josvaz/vmbuilder/jenkins_kvm+ethx-fixed
Merge into: lp:~ubuntu-on-ec2/vmbuilder/jenkins_kvm
Diff against target: 114 lines (+65/-27)
1 file modified
templates/img-extra-nets.tmpl (+65/-27)
To merge this branch: bzr merge lp:~josvaz/vmbuilder/jenkins_kvm+ethx-fixed
Reviewer Review Type Date Requested Status
Robert C Jennings (community) Approve
Review via email: mp+309486@code.launchpad.net

Description of the change

Fix 768-770 commits adding eth1+ udev support

Commits 768-770 added udev support for eth1+ DHCP configuration for xenial onward.

They had a bug and were reverted. This is a fixed version of those commits. The problem was the xchrooted command at line had an incorrect prefix on, a path already chrooted.

To post a comment you must log in.
Revision history for this message
Jose L. VG (josvaz) wrote :

Lines fixed

91 + # Make the script executable
92 + xchroot chmod +x /usr/local/sbin/ephemeral_eth.sh

Was:

91 + # Make the script executable
92 + xchroot chmod +x ${mp}/usr/local/sbin/ephemeral_eth.sh

Revision history for this message
Robert C Jennings (rcj) wrote :

it would be easier now and for future reviewers to have two commits. Commit #1 re-reverts r771, Commit #2 fixes the issue.

review: Needs Fixing
Revision history for this message
Jose L. VG (josvaz) wrote :

Done, please review again

Revision history for this message
Robert C Jennings (rcj) wrote :

Excellent and thank you for splitting out the fix from the revert. Merge when ready

review: Approve
771. By Jose L. VG

Re-reverts 771

772. By Jose L. VG

Fix 768-770 commits adding eth1+ udev support

Commits 768-770 added udev support for eth1+ DHCP configuration for
xenial onward.

They had a bug and were reverted. This is the fix:
The xchrooted command had a prefix on, a path already chrooted!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'templates/img-extra-nets.tmpl'
2--- templates/img-extra-nets.tmpl 2016-10-20 13:39:46 +0000
3+++ templates/img-extra-nets.tmpl 2016-10-27 15:59:51 +0000
4@@ -1,29 +1,17 @@
5 ######################
6 ## BEGIN NICS
7 ## This adds upstart jobs for the creation of hot-plug NICS
8+## For xenial onward, udev is configured instead
9 # vi: ts=4 noexpandtab syntax=sh
10
11-int_d="/etc/network/interfaces.dynamic.d"
12+int_d="/run/network/interfaces.ephemeral.d/"
13 xchroot mkdir -p ${int_d}
14
15-## Place readme to notify people what is going on
16-cat << EOF > ${mp}${int_d}/README
17-WARNING: This is mounted over during boot!
18-
19-If you are seeing this file, it means that you have disabled the tmpfs mount
20- in /etc/fstab for ${int_d}. Therefore, this directory
21- is ephemeral.
22-
23-This directory is normally populated at boot for any interface that is not
24- eth0 with a dynamic configuration.
25-
26-${CLOUD_IMG_STR}
27-EOF
28-
29-# Give an upstart job for defining a secondary interface
30-# if needed.
31-cat << EOF > ${mp}/etc/init/network-conf-ethX.conf
32-# Enable DHCP configuration for additional ethX devices
33+function config_upstart {
34+ # Give an upstart job for defining a secondary interface
35+ # if needed.
36+ cat << EOF > ${mp}/etc/init/network-conf-ethX.conf
37+# Enable DHCP configuration for eth1+ devices as they appear
38 ${CLOUD_IMG_STR}
39
40 description "Dynamically populate ${int_d}"
41@@ -50,15 +38,65 @@
42 esac
43 end script
44 EOF
45-
46-# Add an ephemeral mount for holding additional NIC interfaces
47-cat << EOF >> ${mp}/etc/fstab
48-
49+}
50+
51+function config_udev {
52+ # Give a udev script to define eth1+ interfaces, as they appear
53+ cat << EOF > ${mp}/usr/local/sbin/ephemeral_eth.sh
54+#!/bin/bash
55 ${CLOUD_IMG_STR}
56-# The following is used to dynamically configured additional
57-# NICs. Do not remove unless you know what you are doing.
58-none ${int_d} tmpfs nodev,noexec,nosuid,size=64K 0 0
59-EOF
60+# Enable DHCP configuration for ethx devices other than eth0
61+# Called by udev to define eth1+ interfaces, as they appear
62+
63+INTERFACE=\$1
64+net_int_d="${int_d}"
65+
66+function configure_nic {
67+ # Ensure \${net_int_d} exists on the ephemeral mount
68+ mkdir -p \${net_int_d}
69+
70+ # Setup the interface config file
71+ cat << EOM > \${net_int_d}/\${INTERFACE}.cfg
72+# Added by \$0
73+allow-hotplug \${INTERFACE}
74+iface \${INTERFACE} inet dhcp
75+EOM
76+
77+ # Bring the interface up
78+ /sbin/ifup \${INTERFACE}
79+}
80+
81+case \${INTERFACE} in
82+ eth0) #skip, this is static
83+ ;;
84+ eth*)
85+ if [ ! -e \${net_int_d}/\${INTERFACE}.cfg ]
86+ then
87+ configure_nic
88+ fi
89+ ;;
90+ *)
91+ ;;
92+esac
93+EOF
94+ # Make the script executable
95+ xchroot chmod +x /usr/local/sbin/ephemeral_eth.sh
96+
97+ # Place an udev rule to call the script when an net device is added
98+ cat << EOF > ${mp}/etc/udev/rules.d/10-net-device-added.rules
99+# Run /usr/local/sbin/ephemeral_eth.sh every time a network device is added
100+ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth[0-9]*", PROGRAM="/usr/local/sbin/ephemeral_eth.sh %k"
101+EOF
102+}
103+
104+case ${SUITE} in
105+ precise|trusty)
106+ config_upstart
107+ ;;
108+ *)
109+ config_udev
110+ ;;
111+esac
112
113 # Add the network ephemeral mount...
114 cat << EOF >> ${mp}/etc/network/interfaces

Subscribers

People subscribed via source and target branches