diff options
author | Kim <kim.sidney@gmail.com> | 2020-01-02 22:51:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 22:51:08 +0100 |
commit | c99785cfef9336d200b2e2cec6f233bc0c96e5a4 (patch) | |
tree | 9bdfedc2c2980e62c42c1ea4c0dfa7f6a38909a3 /cloudinit/config/cc_vyos.py | |
parent | e71ea889ff0b3904c1d39f2f7c9ce608f63e047a (diff) | |
parent | 993e50c82ed0857a23d2c8d0856bbb3320b9d730 (diff) | |
download | vyos-cloud-init-c99785cfef9336d200b2e2cec6f233bc0c96e5a4.tar.gz vyos-cloud-init-c99785cfef9336d200b2e2cec6f233bc0c96e5a4.zip |
Merge pull request #3 from UnicronNL/crux
T1934: Change default hostname when deploy from OVA without params.
Diffstat (limited to 'cloudinit/config/cc_vyos.py')
-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): |