Enable network.service with systemd
glean is writing out interface scripts to /etc/sysconfig/network-scripts ; these scripts are run by the LSB/sysv init script /etc/init.d/network It is quite possible this isn't enabled in systemd and on a minimal system (no NetworkManger, cloud-config, systemd-networkd, etc), nothing may require it, so the upshot is your system boots with no network. It can be confusing because the *first* time the system boots, the glean udev rules are matched on the interface and install the interface-scripts and then bring it up. Enable the service when we install the interface config on redhat like platforms. Change-Id: Ib2b618dd975ca44e9c6b0a2c9027642ffc46b9b0
This commit is contained in:
parent
5dec9338a3
commit
7a0f9fbddb
18
glean/cmd.py
18
glean/cmd.py
|
@ -133,6 +133,18 @@ def write_redhat_interfaces(interfaces, sys_interfaces):
|
|||
return files_to_write
|
||||
|
||||
|
||||
def systemd_enable(service, args):
|
||||
log.debug("Enabling %s via systemctl" % service)
|
||||
|
||||
if args.noop:
|
||||
return
|
||||
|
||||
rc = os.system('systemctl enable %s' % service)
|
||||
if rc != 0:
|
||||
log.error("Error enabling %s" % service)
|
||||
sys.exit(rc)
|
||||
|
||||
|
||||
def _exists_debian_interface(name):
|
||||
file_to_check = '/etc/network/interfaces.d/{name}.cfg'.format(name=name)
|
||||
return os.path.exists(file_to_check)
|
||||
|
@ -273,6 +285,12 @@ def write_static_network_info(
|
|||
elif args.distro in ('redhat', 'centos', 'fedora', 'suse', 'opensuse'):
|
||||
files_to_write.update(
|
||||
write_redhat_interfaces(interfaces, sys_interfaces))
|
||||
|
||||
# glean configures interfaces via
|
||||
# /etc/sysconfig/network-scripts, so we have to ensure that
|
||||
# the LSB init script /etc/init.d/network gets started!
|
||||
systemd_enable('network.service', args)
|
||||
|
||||
else:
|
||||
return False
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ class TestGlean(base.BaseTestCase):
|
|||
self.useFixture(fixtures.MonkeyPatch('os.listdir', fake_listdir))
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'subprocess.check_output', mock.Mock()))
|
||||
self.useFixture(fixtures.MonkeyPatch('os.system',
|
||||
mock.Mock(return_value=0)))
|
||||
|
||||
real_path_exists = os.path.exists
|
||||
|
||||
|
|
Loading…
Reference in New Issue