2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-23 10:02:04 +00:00
confluent/confluent_osdeploy/esxi7/profiles/hypervisor/scripts/makeksnet

37 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-06-08 21:24:48 +00:00
#!/usr/bin/python
nodename = None
for inf in open('/etc/confluent/confluent.info', 'r').read().split('\n'):
if inf.startswith('NODENAME: '):
nodename = inf.replace('NODENAME: ', '')
break
deploycfg = open('/etc/confluent/confluent.deploycfg', 'r').read().split('\n')
cfg = {}
nslist = False
nameservers = []
for line in deploycfg:
kv = line.split(': ')
if not kv[0]:
continue
if len(kv) == 2:
cfg[kv[0]] = kv[1]
if kv[0] == 'nameservers:':
nslist = True
continue
if nslist and kv[0].startswith('- '):
nameservers.append(kv[0].split(' ', 1)[1])
else:
nslist=False
cfg['nameservers'] = ','.join(nameservers)
netline = 'network --hostname={0} --bootproto={1}'.format(nodename, cfg['ipv4_method'])
if cfg['ipv4_method'] == 'static':
netline += ' --ip={0} --netmask={1}'.format(cfg['ipv4_address'], cfg['ipv4_netmask'])
if cfg.get('ipv4_gateway', 'null') not in (None, '', 'null'):
netline += ' --gateway={0}'.format(cfg['ipv4_gateway'])
if cfg['nameservers']:
netline += ' --nameserver={0}'.format(cfg['nameservers'])
print(netline)