diff options
author | Kim Hagen <kim.sidney@gmail.com> | 2020-01-02 20:33:25 +0100 |
---|---|---|
committer | Kim Hagen <kim.sidney@gmail.com> | 2020-01-02 20:34:06 +0100 |
commit | 993e50c82ed0857a23d2c8d0856bbb3320b9d730 (patch) | |
tree | 9bdfedc2c2980e62c42c1ea4c0dfa7f6a38909a3 | |
parent | e71ea889ff0b3904c1d39f2f7c9ce608f63e047a (diff) | |
download | vyos-cloud-init-993e50c82ed0857a23d2c8d0856bbb3320b9d730.tar.gz vyos-cloud-init-993e50c82ed0857a23d2c8d0856bbb3320b9d730.zip |
T1934: Change default hostname when deploy from OVA without params.
-rw-r--r-- | cloudinit/config/cc_vyos.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cloudinit/config/cc_vyos.py b/cloudinit/config/cc_vyos.py index a1445e09..bd595397 100644 --- a/cloudinit/config/cc_vyos.py +++ b/cloudinit/config/cc_vyos.py @@ -104,7 +104,7 @@ def set_config_ovf(config, hostname, metadata): APIPORT = metadata['APIPORT'] APIDEBUG = metadata['APIDEBUG'] - if ip_0 != '' and mask_0 != '' and gateway != '': + if ip_0 and ip_0 != 'null' and mask_0 and mask_0 != 'null' and gateway and gateway != 'null': cidr = str(IPv4Network('0.0.0.0/' + mask_0).prefixlen) ipcidr = ip_0 + '/' + cidr @@ -117,33 +117,35 @@ def set_config_ovf(config, hostname, metadata): config.set(['interfaces', 'ethernet', 'eth0', 'address'], value='dhcp', replace=True) config.set_tag(['interfaces', 'ethernet']) - DNS = [ server for server in DNS if server != '' ] + DNS = [server for server in DNS if server and server != 'null'] if DNS: for server in DNS: config.set(['system', 'name-server'], value=server, replace=False) - NTP = [ server for server in NTP if server != '' ] + NTP = [server for server in NTP if server and server != 'null'] if NTP: for server in NTP: config.set(['system', 'ntp', 'server'], value=server, replace=False) config.set_tag(['system', 'ntp', 'server']) - if APIKEY != '': + if APIKEY and APIKEY != 'null': config.set(['service', 'https', 'api', 'keys', 'id', 'cloud-init', 'key'], value=APIKEY, replace=True) config.set_tag(['service', 'https', 'api', 'keys', 'id']) - if APIDEBUG != 'False' and APIKEY != '': + if APIDEBUG != 'False' and APIKEY and APIKEY != 'null': config.set(['service', 'https', 'api', 'debug'], replace=True) - if APIPORT != '' and APIKEY != '': + if APIPORT and APIPORT != 'null' and APIKEY and APIKEY != 'null': config.set(['service', 'https', 'listen-address', '0.0.0.0', 'listen-port'], value=APIPORT, replace=True) config.set_tag(['service', 'https', 'listen-address']) config.set(['service', 'ssh'], replace=True) config.set(['service', 'ssh', 'port'], value='22', replace=True) - if hostname != '': + if hostname and hostname != 'null': config.set(['system', 'host-name'], value=hostname, replace=True) + else: + config.set(['system', 'host-name'], value='vyos', replace=True) def set_config_interfaces(config, interface): |