From 165284e52da496799b9029312fb927a2c3dbfc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 13 Mar 2015 18:18:55 +0000 Subject: Use the modern way of the GPL copyright header: URL instead real address Change-Id: I992dc0c1d40f563ade56a833162d409b02be90a0 --- add-config-files.configure | 5 ++--- fstab.configure | 5 ++--- initramfs.write | 5 ++--- install-files.configure | 5 ++--- kvm.check | 3 +-- kvm.write | 5 ++--- nfsboot.check | 5 ++--- nfsboot.configure | 5 ++--- nfsboot.write | 5 ++--- openstack.check | 5 ++--- openstack.write | 5 ++--- rawdisk.check | 5 ++--- rawdisk.write | 5 ++--- set-hostname.configure | 5 ++--- simple-network.configure | 5 ++--- ssh-rsync.check | 5 ++--- ssh-rsync.write | 5 ++--- sysroot.check | 3 +-- sysroot.write | 3 +-- tar.check | 5 ++--- tar.write | 5 ++--- vdaboot.configure | 5 ++--- virtualbox-ssh.check | 5 ++--- virtualbox-ssh.write | 3 +-- 24 files changed, 44 insertions(+), 68 deletions(-) diff --git a/add-config-files.configure b/add-config-files.configure index 0094cf6b..2cf96fd1 100755 --- a/add-config-files.configure +++ b/add-config-files.configure @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013,2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # Copy all files located in $SRC_CONFIG_DIR to the image /etc. diff --git a/fstab.configure b/fstab.configure index a1287ea4..3bbc9102 100755 --- a/fstab.configure +++ b/fstab.configure @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013,2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # # =*= License: GPL-2 =*= diff --git a/initramfs.write b/initramfs.write index f8af6d84..1059defa 100755 --- a/initramfs.write +++ b/initramfs.write @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # # =*= License: GPL-2 =*= diff --git a/install-files.configure b/install-files.configure index 04dc5f18..58cf373a 100755 --- a/install-files.configure +++ b/install-files.configure @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2013-2014 Codethink Limited +# Copyright (C) 2013-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . ''' A Morph configuration extension for adding arbitrary files to a system diff --git a/kvm.check b/kvm.check index b8877a89..62d76453 100755 --- a/kvm.check +++ b/kvm.check @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''Preparatory checks for Morph 'kvm' write extension''' diff --git a/kvm.write b/kvm.write index 30b43d6c..0d0c095b 100755 --- a/kvm.write +++ b/kvm.write @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2012-2014 Codethink Limited +# Copyright (C) 2012-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''A Morph deployment write extension for deploying to KVM+libvirt. diff --git a/nfsboot.check b/nfsboot.check index 806e560a..e273f61c 100755 --- a/nfsboot.check +++ b/nfsboot.check @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''Preparatory checks for Morph 'nfsboot' write extension''' diff --git a/nfsboot.configure b/nfsboot.configure index 660d9c39..6a68dc48 100755 --- a/nfsboot.configure +++ b/nfsboot.configure @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2013-2014 Codethink Limited +# Copyright (C) 2013-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # Remove all networking interfaces. On nfsboot systems, eth0 is set up diff --git a/nfsboot.write b/nfsboot.write index 49d71174..d928775e 100755 --- a/nfsboot.write +++ b/nfsboot.write @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2013-2014 Codethink Limited +# Copyright (C) 2013-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''A Morph deployment write extension for deploying to an nfsboot server diff --git a/openstack.check b/openstack.check index 3850d481..4c21b604 100755 --- a/openstack.check +++ b/openstack.check @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''Preparatory checks for Morph 'openstack' write extension''' diff --git a/openstack.write b/openstack.write index d29d2661..67e07c18 100755 --- a/openstack.write +++ b/openstack.write @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2013 - 2014 Codethink Limited +# Copyright (C) 2013-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''A Morph deployment write extension for deploying to OpenStack.''' diff --git a/rawdisk.check b/rawdisk.check index 094adb72..9be0ce91 100755 --- a/rawdisk.check +++ b/rawdisk.check @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''Preparatory checks for Morph 'rawdisk' write extension''' diff --git a/rawdisk.write b/rawdisk.write index d91a4d5f..6f2d45ba 100755 --- a/rawdisk.write +++ b/rawdisk.write @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2012-2014 Codethink Limited +# Copyright (C) 2012-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''A Morph deployment write extension for raw disk images.''' diff --git a/set-hostname.configure b/set-hostname.configure index e44c5d56..4b2424d8 100755 --- a/set-hostname.configure +++ b/set-hostname.configure @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013,2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # Set hostname on system from HOSTNAME. diff --git a/simple-network.configure b/simple-network.configure index b98b202c..13884e9d 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013,2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''A Morph deployment configuration extension to handle /etc/network/interfaces diff --git a/ssh-rsync.check b/ssh-rsync.check index 11446c28..c3bdfd29 100755 --- a/ssh-rsync.check +++ b/ssh-rsync.check @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''Preparatory checks for Morph 'ssh-rsync' write extension''' diff --git a/ssh-rsync.write b/ssh-rsync.write index c4577026..6d596500 100755 --- a/ssh-rsync.write +++ b/ssh-rsync.write @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2013-2014 Codethink Limited +# Copyright (C) 2013-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''A Morph deployment write extension for upgrading systems over ssh.''' diff --git a/sysroot.check b/sysroot.check index bfacd3fc..8ed965bd 100755 --- a/sysroot.check +++ b/sysroot.check @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # Preparatory checks for Morph 'sysroot' write extension diff --git a/sysroot.write b/sysroot.write index be315365..0ad8d630 100755 --- a/sysroot.write +++ b/sysroot.write @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # A Morph write extension to deploy to another directory diff --git a/tar.check b/tar.check index cbeaf163..f2304d46 100755 --- a/tar.check +++ b/tar.check @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # Preparatory checks for Morph 'tar' write extension diff --git a/tar.write b/tar.write index 333626b5..01b545b4 100755 --- a/tar.write +++ b/tar.write @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013,2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # A Morph write extension to deploy to a .tar file diff --git a/vdaboot.configure b/vdaboot.configure index b88eb3a8..60de925b 100755 --- a/vdaboot.configure +++ b/vdaboot.configure @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013,2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . # Change the "/" mount point to /dev/vda to use virtio disks. diff --git a/virtualbox-ssh.check b/virtualbox-ssh.check index 57d54db1..a97f3294 100755 --- a/virtualbox-ssh.check +++ b/virtualbox-ssh.check @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''Preparatory checks for Morph 'virtualbox-ssh' write extension''' diff --git a/virtualbox-ssh.write b/virtualbox-ssh.write index 7eafcff3..774f2b4f 100755 --- a/virtualbox-ssh.write +++ b/virtualbox-ssh.write @@ -11,8 +11,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . '''A Morph deployment write extension for deploying to VirtualBox via ssh. -- cgit v1.2.1 From 5258835b5440bf1217186dc76299a55149ce3562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 6 Mar 2015 12:21:05 +0000 Subject: simple-network.configure: Move the generation of /etc/network/interfaces to a function --- simple-network.configure | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/simple-network.configure b/simple-network.configure index 13884e9d..c533ff22 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -48,8 +48,13 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): self.status(msg="Processing NETWORK_CONFIG=%(nc)s", nc=network_config) stanzas = self.parse_network_stanzas(network_config) - iface_file = self.generate_iface_file(stanzas) + self.generate_interfaces_file(args, stanzas) + + def generate_interfaces_file(self, args, stanzas): + """Generate /etc/network/interfaces file""" + + iface_file = self.generate_iface_file(stanzas) with open(os.path.join(args[0], "etc/network/interfaces"), "w") as f: f.write(iface_file) -- cgit v1.2.1 From 6d2d47d6c69878de51edbf3c0dbe50811a27941c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 6 Mar 2015 12:39:58 +0000 Subject: simple-network.configure: Generate networkd .network files as well --- simple-network.configure | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/simple-network.configure b/simple-network.configure index c533ff22..5b02142c 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -50,6 +50,7 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): stanzas = self.parse_network_stanzas(network_config) self.generate_interfaces_file(args, stanzas) + self.generate_networkd_files(args, stanzas) def generate_interfaces_file(self, args, stanzas): """Generate /etc/network/interfaces file""" @@ -87,6 +88,38 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): lines += [""] return "\n".join(lines) + def generate_networkd_files(self, args, stanzas): + """Generate .network files""" + + for i, stanza in enumerate(stanzas, 50): + iface_file = self.generate_networkd_file(stanza) + + if iface_file is None: + continue + + path = os.path.join(args[0], "etc", "systemd", "network", + "%s-%s.network" % (i, stanza['name'])) + + with open(path, "w") as f: + f.write(iface_file) + + def generate_networkd_file(self, stanza): + """Generate an .network file from the provided data.""" + + name = stanza['name'] + itype = stanza['type'] + pairs = stanza['args'].items() + + if itype == "loopback": + return + + lines = ["[Match]"] + lines += ["Name=%s\n" % name] + lines += ["[Network]"] + if itype == "dhcp": + lines += ["DHCP=yes"] + + return "\n".join(lines) def parse_network_stanzas(self, config): """Parse a network config environment variable into stanzas. -- cgit v1.2.1 From ac5125c8a60dd71eba2a22f8790aae3887d1b543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 6 Mar 2015 12:56:19 +0000 Subject: simple-network.configure: Add function to convert mask to cidr suffix 255.255.255.0 -> 24 --- simple-network.configure | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/simple-network.configure b/simple-network.configure index 5b02142c..0e514e0b 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -121,6 +121,13 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): return "\n".join(lines) + def convert_net_mask_to_cidr_suffix(self, mask): + """Convert dotted decimal form of a subnet mask to CIDR suffix notation + + For example: 255.255.255.0 -> 24 + """ + return sum(bin(int(x)).count('1') for x in mask.split('.')) + def parse_network_stanzas(self, config): """Parse a network config environment variable into stanzas. -- cgit v1.2.1 From 0c3d3c645f40fd5f70b0268309912f8c533ed182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 6 Mar 2015 12:55:01 +0000 Subject: simple-network.configure: process pairs of parameters in a function --- simple-network.configure | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/simple-network.configure b/simple-network.configure index 0e514e0b..a058cba7 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -118,9 +118,38 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): lines += ["[Network]"] if itype == "dhcp": lines += ["DHCP=yes"] + else: + lines += self.generate_networkd_entries(pairs) return "\n".join(lines) + def generate_networkd_entries(self, pairs): + """Generate networkd configuration entries with the other parameters""" + + address = None + netmask = None + gateway = None + lines = [] + for pair in pairs: + if pair[0] == 'address': + address = pair[1] + elif pair[0] == 'netmask': + netmask = pair[1] + elif pair[0] == 'gateway': + gateway = pair[1] + + if address and netmask: + network_suffix = self.convert_net_mask_to_cidr_suffix (netmask); + address_line = address + '/' + str(network_suffix) + lines += ["Address=%s" % address_line] + elif address or netmask: + raise Exception('address and netmask must be specified together') + + if gateway is not None: + lines += ["Gateway=%s" % gateway] + + return lines + def convert_net_mask_to_cidr_suffix(self, mask): """Convert dotted decimal form of a subnet mask to CIDR suffix notation -- cgit v1.2.1 From 41082a8956c6581c1c735388c73fd73fef6b1f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 6 Mar 2015 13:18:08 +0000 Subject: simple-network.configure: Generate default network config files in a function Use DHCP by defaul in the default interfaces: - for /etc/networ/interfaces: "lo:loopback;eth0:dhcp,hostname=$(hostname)" - for networkd: "e*:dhcp" --- simple-network.configure | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/simple-network.configure b/simple-network.configure index a058cba7..fbbe6c4e 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -42,15 +42,29 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): ''' def process_args(self, args): - network_config = os.environ.get( - "NETWORK_CONFIG", "lo:loopback;eth0:dhcp,hostname=$(hostname)") + network_config = os.environ.get("NETWORK_CONFIG") - self.status(msg="Processing NETWORK_CONFIG=%(nc)s", nc=network_config) + if network_config is None: + self.generate_default_network_config(args) + else: + self.status(msg="Processing NETWORK_CONFIG=%(nc)s", nc=network_config) + + stanzas = self.parse_network_stanzas(network_config) + + self.generate_interfaces_file(args, stanzas) + self.generate_networkd_files(args, stanzas) + + def generate_default_network_config(self, args): + """Generate default network configuration: DHCP in all the interfaces""" + + default_network_config_interfaces = "lo:loopback;eth0:dhcp,hostname=$(hostname)" + default_network_config_networkd = "e*:dhcp" - stanzas = self.parse_network_stanzas(network_config) + stanzas_interfaces = self.parse_network_stanzas(default_network_config_interfaces) + stanzas_networkd = self.parse_network_stanzas(default_network_config_networkd) - self.generate_interfaces_file(args, stanzas) - self.generate_networkd_files(args, stanzas) + self.generate_interfaces_file(args, stanzas_interfaces) + self.generate_networkd_files(args, stanzas_networkd) def generate_interfaces_file(self, args, stanzas): """Generate /etc/network/interfaces file""" -- cgit v1.2.1 From 1692a0460dd14b1e3af19d65b4e8b802f88a9ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Wed, 11 Mar 2015 19:48:02 +0000 Subject: simple-network.configure: Update documentation --- simple-network.configure | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/simple-network.configure b/simple-network.configure index fbbe6c4e..7c078c93 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -13,13 +13,15 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see . -'''A Morph deployment configuration extension to handle /etc/network/interfaces +'''A Morph deployment configuration extension to handle network configutation -This extension prepares /etc/network/interfaces with the interfaces specified -during deployment. +This extension prepares /etc/network/interfaces and networkd .network files +in /etc/systemd/network/ with the interfaces specified during deployment. If no network configuration is provided, eth0 will be configured for DHCP -with the hostname of the system. +with the hostname of the system in the case of /etc/network/interfaces. +In the case of networkd, any interface starting by e* will be configured +for DHCP ''' @@ -36,9 +38,10 @@ class SimpleNetworkError(morphlib.Error): class SimpleNetworkConfigurationExtension(cliapp.Application): - '''Configure /etc/network/interfaces + '''Configure /etc/network/interfaces and generate networkd .network files - Reading NETWORK_CONFIG, this extension sets up /etc/network/interfaces. + Reading NETWORK_CONFIG, this extension sets up /etc/network/interfaces + and .network files in /etc/systemd/network/. ''' def process_args(self, args): -- cgit v1.2.1 From 7720a88463e4bfaee9bb86e3874137052160a558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Wed, 11 Mar 2015 19:48:17 +0000 Subject: simple-network.configure: Rename networkd file generated by systemd chunk Rename instead removal in case the user is already using a 10-dhcp.network file --- simple-network.configure | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/simple-network.configure b/simple-network.configure index 7c078c93..a347ebf9 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -47,6 +47,8 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): def process_args(self, args): network_config = os.environ.get("NETWORK_CONFIG") + self.rename_networkd_chunk_file(args) + if network_config is None: self.generate_default_network_config(args) else: @@ -57,6 +59,33 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): self.generate_interfaces_file(args, stanzas) self.generate_networkd_files(args, stanzas) + def rename_networkd_chunk_file(self, args): + """Rename the 10-dchp.network file generated in the systemd chunk + + The systemd chunk will place something in 10-dhcp.network, which will + have higher precedence than anything added in this extension (we + start at 50-*). + + We should check for that file and rename it instead remove it in + case the file is being used by the user. + + Until both the following happen, we should continue to rename that + default config file: + + 1. simple-network.configure is always run when systemd is included + 2. We've been building systems without systemd including that default + networkd config for long enough that nobody should be including + that config file. + """ + file_path = os.path.join(args[0], "etc", "systemd", "network", + "10-dhcp.network") + try: + os.rename(file_path, file_path + ".morph") + self.status(msg="Renaming networkd file from systemd chunk: %(f)s \ + to %(f)s.morph", f=file_path) + except OSError: + pass + def generate_default_network_config(self, args): """Generate default network configuration: DHCP in all the interfaces""" -- cgit v1.2.1