forked from pool/cloud-init
Robert Schweikert
8e9fedcf49
+ added cloud-init-net-eni.patch based on work by eblock - Using config-drive instead of metadata failed because the network translation to Ubuntu-style did not return gateway information to opensuse.py + added cloud-init-service.patch based on work by eblock - The service file cloud-init.service referenced networking.service which on SUSE is network.service + remove no_logic_change.patch included in updated upstream source + forward port suseIntegratedHandler.patch + forward port setupSUSEsysVInit.diff + forward port cloud-init-no-dmidecode-on-ppc64.patch + foward port dataSourceOpenNebula.patch + forward port fix-default-systemd-unit-dir.patch + forward port cloud-init-finalbeforelogin.patch + forward port cloud-init-python2-sigpipe.patch + SmartOS: more improvements for network configuration + add ntp config module [Ryan Harper] + ChangeLog: update changelog for previous commit. + Add distro tags on config modules that should have it. + NoCloud: fix bug providing network-interfaces via meta-data. (LP: 1577982) + ConfigDrive: recognize 'tap' as a link type. (LP: #1610784) + Upgrade to a configobj package new enough to work + MAAS: add vendor-data support (LP: #1612313) + DigitalOcean: use the v1.json endpoint [Ben Howard] + Get Azure endpoint server from DHCP client [Brent Baude] + Apt: add new apt configuration format [Christian Ehrhardt] + distros: fix get_primary_arch method use of os.uname [Andrew Jorgensen] + Fix Gentoo net config generation [Matthew Thode] + Minor cleanups to atomic_helper and add unit tests. OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=43
99 lines
3.6 KiB
Diff
99 lines
3.6 KiB
Diff
--- cloudinit/sources/DataSourceOpenNebula.py.orig
|
|
+++ cloudinit/sources/DataSourceOpenNebula.py
|
|
@@ -121,7 +121,7 @@ class BrokenContextDiskDir(Exception):
|
|
|
|
class OpenNebulaNetwork(object):
|
|
REG_DEV_MAC = re.compile(
|
|
- r'^\d+: (eth\d+):.*?link\/ether (..:..:..:..:..:..) ?',
|
|
+ r'^\d+: (eth\d+):.*?link\/\W+ (..:..:..:..:..:..) ?',
|
|
re.MULTILINE | re.DOTALL)
|
|
|
|
def __init__(self, ip, context):
|
|
@@ -130,12 +130,24 @@ class OpenNebulaNetwork(object):
|
|
self.ifaces = self.get_ifaces()
|
|
|
|
def get_ifaces(self):
|
|
- return self.REG_DEV_MAC.findall(self.ip)
|
|
+ list = self.REG_DEV_MAC.findall(self.ip)
|
|
+ ifaces = dict()
|
|
+ for l in list:
|
|
+ ifaces[l[1]] = l[0]
|
|
+ return ifaces
|
|
|
|
def mac2ip(self, mac):
|
|
components = mac.split(':')[2:]
|
|
return [str(int(c, 16)) for c in components]
|
|
|
|
+ def get_context_interfaces(self):
|
|
+
|
|
+ def device_mac(t): return re.match(r"ETH\d+_MAC", t)
|
|
+
|
|
+ mac_vars = filter(device_mac, self.context.keys())
|
|
+ context_interfaces = [v.split('_')[0] for v in mac_vars]
|
|
+ return context_interfaces
|
|
+
|
|
def get_ip(self, dev, components):
|
|
var_name = dev.upper() + '_IP'
|
|
if var_name in self.context:
|
|
@@ -188,27 +200,39 @@ class OpenNebulaNetwork(object):
|
|
conf.append('iface lo inet loopback')
|
|
conf.append('')
|
|
|
|
- for i in self.ifaces:
|
|
- dev = i[0]
|
|
- mac = i[1]
|
|
+ context_interfaces = self.get_context_interfaces()
|
|
+
|
|
+ if len(context_interfaces):
|
|
+ try:
|
|
+ (out, _err) = util.subp(["systemctl", "stop", "NetworkManager"])
|
|
+ (out, _err) = util.subp(["systemctl", "disable", "NetworkManager"])
|
|
+ except util.ProcessExecutionError:
|
|
+ util.logexc(LOG, "Disable NetworkManager command failed")
|
|
+
|
|
+ for interface in context_interfaces:
|
|
+ mac = self.context[interface+"_MAC"]
|
|
+ dev = self.ifaces.get(mac)
|
|
+ if dev is None:
|
|
+ continue
|
|
+
|
|
ip_components = self.mac2ip(mac)
|
|
|
|
conf.append('auto ' + dev)
|
|
conf.append('iface ' + dev + ' inet static')
|
|
- conf.append(' address ' + self.get_ip(dev, ip_components))
|
|
- conf.append(' network ' + self.get_network(dev, ip_components))
|
|
- conf.append(' netmask ' + self.get_mask(dev))
|
|
+ conf.append(' address ' + self.get_ip(nterface, ip_components))
|
|
+ conf.append(' network ' + self.get_network(interface, ip_components))
|
|
+ conf.append(' netmask ' + self.get_mask(interface))
|
|
|
|
- gateway = self.get_gateway(dev)
|
|
+ gateway = self.get_gateway(interface)
|
|
if gateway:
|
|
conf.append(' gateway ' + gateway)
|
|
|
|
- domain = self.get_domain(dev)
|
|
+ domain = self.get_domain(interface)
|
|
if domain:
|
|
conf.append(' dns-search ' + domain)
|
|
|
|
# add global DNS servers to all interfaces
|
|
- dns = self.get_dns(dev)
|
|
+ dns = self.get_dns(interface
|
|
if global_dns or dns:
|
|
all_dns = global_dns
|
|
if dns:
|
|
@@ -375,9 +399,8 @@ def read_context_disk_dir(source_dir, as
|
|
|
|
if ssh_key_var:
|
|
lines = context.get(ssh_key_var).splitlines()
|
|
- results['metadata']['public-keys'] = [l for l in lines
|
|
- if len(l) and not
|
|
- l.startswith("#")]
|
|
+ ssh_keys = [l for l in lines if len(l) and not l.startswith("#")]
|
|
+ results['metadata']['public-keys'] = ssh_keys
|
|
|
|
# custom hostname -- try hostname or leave cloud-init
|
|
# itself create hostname from IP address later
|