summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorKim Hagen <kim.sidney@gmail.com>2020-01-02 20:33:25 +0100
committerKim Hagen <kim.sidney@gmail.com>2020-01-02 20:33:25 +0100
commit22f4329c86fb153d52de8a33996fe46f47097107 (patch)
tree4d7ea620b5cf494136686ee750ba8934aedb8324 /cloudinit/config
parent46cdd473cdf8994765fbd7ccbb49a75afd5b148a (diff)
downloadvyos-cloud-init-22f4329c86fb153d52de8a33996fe46f47097107.tar.gz
vyos-cloud-init-22f4329c86fb153d52de8a33996fe46f47097107.zip
T1934: Change default hostname when deploy from OVA without params.
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_vyos.py16
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):