Commit Graph

18 Commits

Author SHA1 Message Date
Dan Prince
f10e614579 Support adding DHCP interfaces one at a time.
Refactors dhcp-all-interfaces.sh so that if an optional
INTERFACE argument (the first argument) is passed to the script
it only inspects that single interface. If no argument is
passed then the previous default behaviour is used which
causes all interfaces to be inspected.

To avoid a collision with the previous $1 we move to using
$FLOCKED for the exec flock command which runs on distributions
using ENI.

Also sets PATH so that the commands within the script
can all be found if it isn't set properly (/sbin/ip, /bin/cat, etc.)

This is a move towards using udev rules to add these types
of interfaces automatically.

Change-Id: I3ec8fd2cc2071bfc6943c744ca619e31b71146fc
2014-03-14 13:30:17 -04:00
Robert Collins
1dfd4b3e44 Revert "Add Fedora DHCP interfaces via udev rules."
This reverts commit 201c9e8527.

This depended on the revert for one-at-a-time.

Change-Id: I05f1f85b8f13a1eea3d5e4b144ff92e0e791bdac
2014-02-14 14:43:09 +13:00
Robert Collins
39e6f7a5c4 Revert "Support adding DHCP interfaces one at a time. "
This reverts commit a1b469b10b.

This broke testenv deployments - it does not yet work on Ubuntu.

Change-Id: I0f74abc6b99da4b8cabca8ed673c606bae7de0e1
2014-02-14 14:42:58 +13:00
Dan Prince
201c9e8527 Add Fedora DHCP interfaces via udev rules
Updates the dhcp-all-interfaces element so that
we add new DHCP interfaces using a udev rule
instead of a systemd service.

The previous approach (using the systemd service)
was proving to be problematic when used with
the new Fedora constistent network naming
convention rules (em1, em2, etc.). We aren't using
these device names as a default yet... but we will
need to soon and when we do udev rules seem to be the
best way to avoid racy behaviour when calling
dhcp-all-interfaces.sh from the systemd service.

Change-Id: I87e0aed1f34718e896bd414388886a1f1073b0c0
2014-02-12 12:00:50 -05:00
Dan Prince
a1b469b10b Support adding DHCP interfaces one at a time.
Refactors dhcp-all-interfaces.sh so that if an optional
INTERFACE argument (the first argument) is passed to the script
it only inspects that single interface. If no argument is
passed then the previous default behaviour use used which
causes all interfaces to be inspected.

Also sets PATH so that the commands within the script
can all be found if it isn't set properly (/sbin/ip, /bin/cat, etc.)

This is a move towards using udev rules to add these types
of interfaces automatically.

Change-Id: Ia482c1d3ddce0f0d8d77f9bc3ac76d6924640715
2014-02-12 11:57:56 -05:00
Dan Prince
01e25c378b ifquery doesn't exist on Fedora
Updates dhcp-all-interfaces so that we avoid using
ifquery on Fedora to determine if an interface exists.

Adds a new config_exists function which simply looks for
the ifcfg config file on distro's that use netscripts.

Change-Id: Ie55524b83820fe4fab28cc9d3f7e08ca2e42c182
2014-02-07 13:33:35 -05:00
Dan Prince
5da1f1324b Rename generate-interfaces-file.sh...
Rename generate-interfaces-file.sh to dhcp-all-interfaces.sh
so that it is easier to find/remember in the $PATH on a deployed
image.

Also, on some distros the script actually generates many files
so the previous name was a bit confusing.

Change-Id: I7152fa7c28e8ade251311da2cd5f75972423b66c
2014-01-23 16:38:41 -05:00
Dan Prince
f58f859303 Only configure DHCP for real interfaces
Updates the generate-interfaces-file.sh script in
the dhcp-all-interfaces element so that we only
add interfaces that have real MAC addresses.

The generate-interfaces-file.sh script is run early enough
in the boot process (before OVS is initialized) that this
isn't usually a problem unless you execute it manually by hand
after booting. Then you'll end up with network/DHCP
configs for all of your OVS bridges, etc. This
patch avoids configuring all of the virtual interfaces
which have generated MAC addresses.

Change-Id: I7a705084aa5b11305ac0ec5ca37fd2e87a2ae8b7
Closes-bug: 1239479
2014-01-23 16:37:44 -05:00
Dan Prince
ae28c99b5f Retry link check up to 10 times.
Updates the dhcp-all-interfaces element so that the link
check tries up to 10 times.

On some of my machines 3 times (seconds) doesn't appear to
be quite long enough...

Change-Id: Ibf7015162fc890d4de8a417b868b0301146944c0
2014-01-13 13:58:42 -05:00
Dan Prince
7511faa2b1 Implement dhcp-all-interfaces for systemd.
Includes:

 * Enhancements to the generate-interfaces-file.sh script
 so that it generates ifcfg network-scripts for
 distros like Fedora/RHEL.

 * Includes a new dhcp-all-interfaces.service systemd
 script which ensures network interfaces get generated
 before the network service starts on Fedora.

 * Add a new disable_interface function to
 generate-interfaces-file.sh which (on Fedora)
 will delete the ifcfg config for an interface which
 isn't plugged in.
 This is important because ifcfg-eth0 exists by default
 and we want to remove it if the NIC isn't connected.
 Previous behaviour on Ubuntu is unchanged and the
 generate-interfaces-file.sh just logs it as skipped.

 * General doc updates...

I tested this on a multi-nic machine w/ Fedora where the first NIC
exists but was not connected.

Change-Id: Ia99e312539da43caefd72aa60398d43dac5dcc8f
Closes-Bug: 1239880
2014-01-10 10:14:07 -05:00
Victor Lowther
43b70ce224 /bin/bash all the things.
Since we are using bash syntax in some of the element fragments,
we should make sure we use bash for all of them, so that things don't
break on systems where /bin/sh != /bin/bash.

Change-Id: If2f043c57aa4e1492b7f9839213ef6123f683612
2013-11-17 16:59:31 -06:00
Derek Higgins
d23ba2a8a8 Conditionally add dhcp-all-interfaces
If the /etc/init drectory gets created on Fedora, it causes
os-svc-daemon to add upstart init scripts instead of systemd.
As a result none of the openstack services can start.

Partial-Bug: #1239880

Change-Id: Iec317baa3eb9ff651fa66c582d2f614993cde45e
2013-10-15 13:43:50 +13:00
Clint Byrum
f96f705559 Remove \r chars from dhcp-all-interfaces
For some reason we are adding CR's to/etc/network/interfaces, but it
does not require them. They are a bit annoying to see in an editor and
serve no known purpose there.

Change-Id: I9aeeff5533f418f09fcf33edd42e5d85cd486d23
2013-10-11 11:06:16 -07:00
Clint Byrum
28190d5954 Make dhcp-all-interfaces block all interfaces
Previously dhcp-all-interfaces was only blocking the first network
interface to come up. We add an instance stanza to make it run one
instance of generate-interfaces-file per interface. We then use flock to
serialize runs of generate-interfaces-file.

Fixes bug #1233577

Change-Id: Ib16bed6b37ce0789e315ef57e05ac561470a6f2a
2013-10-11 11:06:16 -07:00
Clint Byrum
2129d78124 Fix ifquery call in dhcp-all-interfaces
Ifquery does not print anything for interfaces which only have a single
iface line. It does, however, return non-zero if the interface is not
configured at all, so we can use that to indicate whether or not there
is a configuration.

Fixes bug #1233579

Change-Id: Ia2fdafbea57e806eba99ae8ddaf395ebdcc306e1
2013-10-11 11:06:16 -07:00
Clint Byrum
4a751ba162 Generate interfaces file before cloud-init runs
Cloud-init needs to query the metadata server after the network
interfaces are configured. The upstart job "cloud-init-nonet" is
specifically in place to provide a hook to block cloud-init from
running while we rearrange network interface configurations.

Fixes bug #1233577

Change-Id: Ib5cf75d858fdb670b2abcc082e912c4644d6b169
2013-10-03 16:00:19 -07:00
Robert Collins
2684cddd3d Fix typo in dhcp-all-interfaces.
It is meant to write to /etc/network/interfaces, not
/etc/network/interfaces].

Change-Id: I15ea677edf7129ffd222c39627f7f76356f68e11
2013-10-01 20:32:40 +13:00
Chris Jones
a6b794fffc Add element to run DHCP on all network interfaces.
Ensures that all network interfaces are present in
/etc/network/interfaces. Any interface not already defined there
will be added and configured for DHCP.

Change-Id: I27e0902e62804e8d719acd7288109bd0e294fd16
2013-04-02 10:28:18 +01:00