Browse Source

Add NetworkManager distro plugin support

On Fedora 29+, the network.service scripts have been moved into a
separate deprecated package.  NetworkManager is the supported
interface for configuring networks.  We have ignored NM for a long
time, but we are now running out of options.

Luckily we can support this fairly easily with the ifcfg-rh disto
plugin that NM provides.  Using this, the existing
/etc/sysconfig/network-scripts files are used by NM.  The only slight
difference to the config files is that we need to tell NM it's ok to
use it by removing NM_CONTROLLED=no.  We also need to update the
.service file which needs to call glean with the flag to enable NM,
and doesn't need to call ifup.  We have found that local-fs.target
seems to be the best place to run this so it's nice and early.

This is plumbed through from simple-init in DIB
(I4d76e88ce25e5675fd5ef48924acd09915a62a4b) which will call
glean-install with the new --use-nm flag if
DIB_SIMPLE_INIT_NETWORKMANAGER is set.

Since all Centos and Feodora are using NetworkManager by default,
there is an argument that we should just switch to this and not bother
with a flag.  However, since NM brings in new libraries and possibly
other changes to the base system, it's very possible we will either
want to revert the change temporarily or perhaps even run parallel
with and without.  In these cases we can simply flip the variable in
DIB and rebuild rather than having to revert code and do new glean
releases.  Longer term (say, around time we bring up CentOS 8), I see
this becoming the default.

Other platforms have distro plugins for NM to read their "legacy"
configuration files too in the same way as here.  This is left as
future work.

NetworkManager enabled build and boot for Centos and Fedora is tested
in I640838c68a05f3b22683c1e90279725a77678526

Change-Id: I3d379d35e7b000f32c3f6cc197c8aaafebc683fb
changes/64/618964/17
Ian Wienand 3 years ago
parent
commit
8f9b156acc
24 changed files with 176 additions and 88 deletions
  1. +40
    -11
      README.rst
  2. +9
    -2
      glean/cmd.py
  3. +21
    -0
      glean/init/glean-nm@.service
  4. +2
    -0
      glean/init/nm-no-resolv-handling.conf
  5. +15
    -1
      glean/install.py
  6. +3
    -3
      glean/tests/fixtures/test/hp.centos.network.out
  7. +3
    -3
      glean/tests/fixtures/test/hp.fedora.network.out
  8. +3
    -3
      glean/tests/fixtures/test/hp.redhat.network.out
  9. +12
    -12
      glean/tests/fixtures/test/liberty.centos.network.out
  10. +12
    -12
      glean/tests/fixtures/test/liberty.fedora.network.out
  11. +12
    -12
      glean/tests/fixtures/test/liberty.redhat.network.out
  12. +3
    -3
      glean/tests/fixtures/test/nokey.centos.network.out
  13. +3
    -3
      glean/tests/fixtures/test/nokey.fedora.network.out
  14. +3
    -3
      glean/tests/fixtures/test/nokey.redhat.network.out
  15. +1
    -1
      glean/tests/fixtures/test/ovh.centos.network.out
  16. +1
    -1
      glean/tests/fixtures/test/ovh.fedora.network.out
  17. +1
    -1
      glean/tests/fixtures/test/ovh.redhat.network.out
  18. +2
    -2
      glean/tests/fixtures/test/rax-iad.centos.network.out
  19. +2
    -2
      glean/tests/fixtures/test/rax-iad.fedora.network.out
  20. +2
    -2
      glean/tests/fixtures/test/rax-iad.redhat.network.out
  21. +3
    -3
      glean/tests/fixtures/test/rax.centos.network.out
  22. +3
    -3
      glean/tests/fixtures/test/rax.fedora.network.out
  23. +3
    -3
      glean/tests/fixtures/test/rax.redhat.network.out
  24. +17
    -2
      glean/tests/test_glean.py

+ 40
- 11
README.rst View File

@ -41,29 +41,58 @@ It will also handle `authorized_keys` and host-name info provided from
How does glean do this?
+++++++++++++++++++++++
Glean determines the network configuration environment for the running
platform and configures the interfaces appropriately.
systemd environment
===================
glean install will add a `udev` rules file (`99-glean.rules`) that
triggers on any network device being added. This will run the
`glean@.service` systemd template for the interface specified.
On platforms where systemd is detected `glean-install` will add a
`udev` rules file (`99-glean.rules`) that triggers on any network
device being added. This will run the `glean@.service` systemd
template for the interface specified.
This systemd unit firstly determines if there is already a
`/etc/sysconfig/network/` configuration for the interface; if so, the
interface is considered configured and skipped.
If not, glean is started with the interface specified. The
configuration drive is probed to see if network configuration for the
interface is available. If so, it will be added, otherwise the
interface will configured for DHCP.
If not, glean is started with the interface that triggered this event
specified as an argument. The configuration drive is probed to see if
network configuration for the interface is available. If so, it will
be added, otherwise the interface will configured for DHCP.
.. note ::
glean uses the network init scripts service ``network.service`` on
RedHat platforms (or the equivalent on other platforms). You should
ensure this service is enabled and other tools such as
NetworkManager are disabled for correct operation.
By default glean provides configuration for the network init
scripts service ``network.service`` on RedHat platforms (or the
equivalent on other platforms). You should ensure this service is
enabled and other tools such as NetworkManager are disabled for
correct operation in this mode. Note on Fedora 29 onwards, this is
in a separate package `network-scripts` and is considered
deprecated.
Alternatively, to use NetworkManager with the `ifcfg-rh` plugin
with to manage the interfaces, call `glean-install` with the
`--use-nm` flag. In this case, ensure NetworkManager is installed.
This will trigger glean to write out configuration files that are
suitable for use with NetworkManager and use a slightly different
service file that doesn't trigger legacy tools like `ifup`.
networkd
========
`networkd` support is implemented as a separate distribution type.
Currently it is only supported on Gentoo, and will be automatically
selected by `glean-install`. It will similarly install a systemd
service file or openrc config file (both are supported on Gentoo) and
udev rules to call glean.
Other platforms
===============
`upstart` and `sysv` environments are also supported. These will have
init scripts installed to run glean at boot.
How do I use glean?
-------------------


+ 9
- 2
glean/cmd.py View File

@ -104,7 +104,9 @@ def _network_config(args):
"DEVICE={name}",
"BOOTPROTO={bootproto}",
"HWADDR={hwaddr}"])
footer = "\n".join(["ONBOOT=yes", "NM_CONTROLLED=no",
footer = "\n".join(["ONBOOT=yes",
"NM_CONTROLLED=%s" %
("yes" if args.use_nm else "no"),
"TYPE=Ethernet"]) + "\n"
network_config = {
@ -182,7 +184,6 @@ def _write_rh_interface(name, interface, args):
hwaddr=interface['mac_address'],
ip_address=interface['ip_address'],
netmask=interface['netmask'],
)
results += _set_rh_vlan(name, interface, distro)
# set_rh_bonding takes results as argument so we need to assign
@ -1416,6 +1417,10 @@ def main(argv=None):
parser.add_argument(
'--skip-network', dest='skip', action='store_true',
help="Do not write network info")
parser.add_argument(
'--use-nm', dest='use_nm', action='store_true',
help=('Use NetworkManager instead of legacy'
'configuration scripts to manage interfaces'))
parser.add_argument(
'--skip-dns', dest='skip_dns', action='store_true',
help='Do not write dns info')
@ -1431,6 +1436,8 @@ def main(argv=None):
log.debug("Starting glean")
log.debug("Detected distro : %s" % args.distro)
log.debug("Configuring %s NetworkManager" %
"with" if args.use_nm else "without")
with systemlock.Lock('/tmp/glean.lock'):
if args.ssh:


+ 21
- 0
glean/init/glean-nm@.service View File

@ -0,0 +1,21 @@
[Unit]
Description=Glean for interface %I with NetworkManager
Wants=local-fs.target
After=local-fs.target
# Red Hat
ConditionPathExists=!/etc/sysconfig/network-scripts/ifcfg-%I
# SuSE
ConditionPathExists=!/etc/sysconfig/network/ifcfg-%I
[Service]
Type=oneshot
User=root
Environment="ARGS=--interface %I"
ExecStart=%%GLEANSH_PATH%%/glean.sh --use-nm --debug $ARGS
RemainAfterExit=true
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target

+ 2
- 0
glean/init/nm-no-resolv-handling.conf View File

@ -0,0 +1,2 @@
[main]
dns=none

+ 15
- 1
glean/install.py View File

@ -81,6 +81,8 @@ def main():
parser = argparse.ArgumentParser(
description='Install glean init components')
parser.add_argument("-n", "--use-nm", help="Use NetworkManager",
action="store_true")
parser.add_argument("-q", "--quiet", help="Be very quiet",
action="store_true")
@ -118,8 +120,14 @@ def main():
replacements={'GLEANSH_PATH': p})
subprocess.call(['systemctl', 'enable', 'glean.service'])
else:
log.info("Installing %s NetworkManager support" %
"with" if args.use_nm else "without")
if args.use_nm:
service_file = 'glean-nm@.service'
else:
service_file = 'glean@.service'
install(
'glean@.service',
service_file,
'/usr/lib/systemd/system/glean@.service',
mode='0644',
replacements={'GLEANSH_PATH': p})
@ -127,6 +135,12 @@ def main():
'glean-udev.rules',
'/etc/udev/rules.d/99-glean.rules',
mode='0644')
if args.use_nm:
# glean handles resolv.conf, so this turns off nm touching
# it
install('nm-no-resolv-handling.conf',
'/etc/NetworkManager/conf.d/nm-no-resolv-handling.conf',
mode='0644')
elif os.path.exists('/etc/init'):
log.info("Installing upstart services")
install('glean.conf', '/etc/init/glean.conf')


+ 3
- 3
glean/tests/fixtures/test/hp.centos.network.out View File

@ -4,7 +4,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:01:62:86
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
# Automatically generated, do not edit
@ -12,7 +12,7 @@ DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:06
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
@ -20,5 +20,5 @@ DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 3
- 3
glean/tests/fixtures/test/hp.fedora.network.out View File

@ -4,7 +4,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:01:62:86
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
# Automatically generated, do not edit
@ -12,7 +12,7 @@ DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:06
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
@ -20,5 +20,5 @@ DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 3
- 3
glean/tests/fixtures/test/hp.redhat.network.out View File

@ -4,7 +4,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:01:62:86
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
# Automatically generated, do not edit
@ -12,7 +12,7 @@ DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:06
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
@ -20,5 +20,5 @@ DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 12
- 12
glean/tests/fixtures/test/liberty.centos.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:01:62:86
IPADDR=23.253.229.154
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=23.253.229.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,14 +20,14 @@ HWADDR=bc:76:4e:05:7b:06
IPADDR=10.208.169.118
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth4.25
# Automatically generated, do not edit
@ -35,7 +35,7 @@ DEVICE=eth4.25
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bc
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes
### Write /etc/sysconfig/network-scripts/ifcfg-eth4.26
@ -44,7 +44,7 @@ DEVICE=eth4.26
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bd
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes
### Write /etc/sysconfig/network-scripts/route-eth1
@ -60,7 +60,7 @@ DEVICE=eth5
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:13
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond0
@ -70,7 +70,7 @@ DEVICE=eth6
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:14
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond0
@ -80,7 +80,7 @@ DEVICE=bond0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:13
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth7
# Automatically generated, do not edit
@ -88,7 +88,7 @@ DEVICE=eth7
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:15
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond1
@ -98,7 +98,7 @@ DEVICE=eth8
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:16
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond1
@ -108,7 +108,7 @@ DEVICE=bond1
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:15
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-bond1.27
# Automatically generated, do not edit
@ -116,6 +116,6 @@ DEVICE=bond1.27
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:be
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes

+ 12
- 12
glean/tests/fixtures/test/liberty.fedora.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:01:62:86
IPADDR=23.253.229.154
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=23.253.229.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,14 +20,14 @@ HWADDR=bc:76:4e:05:7b:06
IPADDR=10.208.169.118
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth4.25
# Automatically generated, do not edit
@ -35,7 +35,7 @@ DEVICE=eth4.25
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bc
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes
### Write /etc/sysconfig/network-scripts/ifcfg-eth4.26
@ -44,7 +44,7 @@ DEVICE=eth4.26
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bd
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes
### Write /etc/sysconfig/network-scripts/ifcfg-eth5
@ -53,7 +53,7 @@ DEVICE=eth5
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:13
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond0
@ -63,7 +63,7 @@ DEVICE=eth6
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:14
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond0
@ -73,7 +73,7 @@ DEVICE=bond0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:13
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth7
# Automatically generated, do not edit
@ -81,7 +81,7 @@ DEVICE=eth7
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:15
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond1
@ -91,7 +91,7 @@ DEVICE=eth8
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:16
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond1
@ -101,7 +101,7 @@ DEVICE=bond1
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:15
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-bond1.27
# Automatically generated, do not edit
@ -109,7 +109,7 @@ DEVICE=bond1.27
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:be
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes
### Write /etc/sysconfig/network-scripts/route-eth1


+ 12
- 12
glean/tests/fixtures/test/liberty.redhat.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:01:62:86
IPADDR=23.253.229.154
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=23.253.229.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,14 +20,14 @@ HWADDR=bc:76:4e:05:7b:06
IPADDR=10.208.169.118
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth4.25
# Automatically generated, do not edit
@ -35,7 +35,7 @@ DEVICE=eth4.25
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bc
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes
### Write /etc/sysconfig/network-scripts/ifcfg-eth4.26
@ -44,7 +44,7 @@ DEVICE=eth4.26
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bd
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes
### Write /etc/sysconfig/network-scripts/route-eth1
@ -60,7 +60,7 @@ DEVICE=eth5
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:13
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond0
@ -70,7 +70,7 @@ DEVICE=eth6
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:14
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond0
@ -80,7 +80,7 @@ DEVICE=bond0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:13
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth7
# Automatically generated, do not edit
@ -88,7 +88,7 @@ DEVICE=eth7
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:15
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond1
@ -98,7 +98,7 @@ DEVICE=eth8
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:16
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
SLAVE=yes
MASTER=bond1
@ -108,7 +108,7 @@ DEVICE=bond1
BOOTPROTO=none
HWADDR=bc:76:4e:05:7b:15
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-bond1.27
# Automatically generated, do not edit
@ -116,6 +116,6 @@ DEVICE=bond1.27
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:be
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
VLAN=yes

+ 3
- 3
glean/tests/fixtures/test/nokey.centos.network.out View File

@ -4,7 +4,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:01:62:86
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
# Automatically generated, do not edit
@ -12,7 +12,7 @@ DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:06
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
@ -20,5 +20,5 @@ DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 3
- 3
glean/tests/fixtures/test/nokey.fedora.network.out View File

@ -4,7 +4,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:01:62:86
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
# Automatically generated, do not edit
@ -12,7 +12,7 @@ DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:06
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
@ -20,5 +20,5 @@ DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 3
- 3
glean/tests/fixtures/test/nokey.redhat.network.out View File

@ -4,7 +4,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=bc:76:4e:01:62:86
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
# Automatically generated, do not edit
@ -12,7 +12,7 @@ DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=bc:76:4e:05:7b:06
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
@ -20,5 +20,5 @@ DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 1
- 1
glean/tests/fixtures/test/ovh.centos.network.out View File

@ -4,5 +4,5 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=fa:16:3e:c8:65:a0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 1
- 1
glean/tests/fixtures/test/ovh.fedora.network.out View File

@ -4,5 +4,5 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=fa:16:3e:c8:65:a0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 1
- 1
glean/tests/fixtures/test/ovh.redhat.network.out View File

@ -4,5 +4,5 @@ DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=fa:16:3e:c8:65:a0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet

+ 2
- 2
glean/tests/fixtures/test/rax-iad.centos.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:20:d7:2f
IPADDR=146.20.110.113
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=146.20.110.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,7 +20,7 @@ HWADDR=bc:76:4e:20:d7:33
IPADDR=10.210.32.174
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/route-eth1
ADDRESS0=10.176.0.0
NETMASK0=255.240.0.0


+ 2
- 2
glean/tests/fixtures/test/rax-iad.fedora.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:20:d7:2f
IPADDR=146.20.110.113
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=146.20.110.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,7 +20,7 @@ HWADDR=bc:76:4e:20:d7:33
IPADDR=10.210.32.174
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/route-eth1
ADDRESS0=10.176.0.0
NETMASK0=255.240.0.0


+ 2
- 2
glean/tests/fixtures/test/rax-iad.redhat.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:20:d7:2f
IPADDR=146.20.110.113
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=146.20.110.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,7 +20,7 @@ HWADDR=bc:76:4e:20:d7:33
IPADDR=10.210.32.174
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/route-eth1
ADDRESS0=10.176.0.0
NETMASK0=255.240.0.0


+ 3
- 3
glean/tests/fixtures/test/rax.centos.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:01:62:86
IPADDR=23.253.229.154
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=23.253.229.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,14 +20,14 @@ HWADDR=bc:76:4e:05:7b:06
IPADDR=10.208.169.118
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/route-eth1
ADDRESS0=10.176.0.0


+ 3
- 3
glean/tests/fixtures/test/rax.fedora.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:01:62:86
IPADDR=23.253.229.154
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=23.253.229.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,14 +20,14 @@ HWADDR=bc:76:4e:05:7b:06
IPADDR=10.208.169.118
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/route-eth1
ADDRESS0=10.176.0.0


+ 3
- 3
glean/tests/fixtures/test/rax.redhat.network.out View File

@ -9,7 +9,7 @@ HWADDR=bc:76:4e:01:62:86
IPADDR=23.253.229.154
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
DEFROUTE=yes
GATEWAY=23.253.229.1
### Write /etc/sysconfig/network-scripts/ifcfg-eth1
@ -20,14 +20,14 @@ HWADDR=bc:76:4e:05:7b:06
IPADDR=10.208.169.118
NETMASK=255.255.224.0
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
### Write /etc/sysconfig/network-scripts/ifcfg-eth3
# Automatically generated, do not edit
DEVICE=eth3
BOOTPROTO=dhcp
HWADDR=bc:76:4e:12:a4:bb
ONBOOT=yes
NM_CONTROLLED=no
%NM_CONTROLLED%
TYPE=Ethernet
### Write /etc/sysconfig/network-scripts/route-eth1
ADDRESS0=10.176.0.0


+ 17
- 2
glean/tests/test_glean.py View File

@ -157,7 +157,8 @@ class TestGlean(base.BaseTestCase):
mock_os_symlink,
mock_os_unlink,
mock_call,
skip_dns=False):
skip_dns=False,
use_nm=False):
"""Main test function
:param distro: distro to return from "distro.linux_distribution()"
@ -165,6 +166,7 @@ class TestGlean(base.BaseTestCase):
out files
:param interface: --interface argument; None for no argument
:param skip_dns: --skip-dns argument; False for no argument
:param use_nm: --use-nm argument; False for no argument
"""
# These functions are watching the path and faking results
@ -189,6 +191,8 @@ class TestGlean(base.BaseTestCase):
argv.append('--interface=%s' % interface)
if skip_dns:
argv.append('--skip-dns')
if use_nm:
argv.append('--use-nm')
cmd.main(argv)
@ -197,7 +201,13 @@ class TestGlean(base.BaseTestCase):
# Generate a list of (dest, content) into write_blocks to assert
write_blocks = []
lines = open(output_path).readlines()
lines = []
with open(output_path) as f:
for line in f:
if line == '%NM_CONTROLLED%\n':
line = 'NM_CONTROLLED=%s\n' % \
("yes" if use_nm else "no")
lines.append(line)
write_dest = None
write_content = None
for line in lines:
@ -267,3 +277,8 @@ class TestGlean(base.BaseTestCase):
with mock.patch('glean.systemlock.Lock'):
self._assert_distro_provider(
self.distro, self.style, None, skip_dns=True)
def test_glean_nm(self):
with mock.patch('glean.systemlock.Lock'):
self._assert_distro_provider(
self.distro, self.style, 'eth0', use_nm=True)

Loading…
Cancel
Save