mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 09:32:21 +00:00
Add netmask to net config data
Some clients may want to consume netmask without going to the trouble of converting, so provide the extra data a different way.
This commit is contained in:
parent
830c9e171f
commit
9fe156601b
@ -287,6 +287,11 @@ def get_flat_net_config(configmanager, node):
|
||||
ret.append(nc)
|
||||
return ret
|
||||
|
||||
def add_netmask(ncfg):
|
||||
if '/' in ncfg['ipv4_address']:
|
||||
plen = ncfg['ipv4_address'].split('/', 1)[1]
|
||||
ncfg['ipv4_netmask'] = cidr_to_mask(int(plen))
|
||||
|
||||
def get_full_net_config(configmanager, node, serverip=None):
|
||||
cfd = configmanager.get_node_attributes(node, ['net.*'])
|
||||
cfd = cfd.get(node, {})
|
||||
@ -319,8 +324,11 @@ def get_full_net_config(configmanager, node, serverip=None):
|
||||
retattrs = {}
|
||||
if None in nm.myattribs:
|
||||
retattrs['default'] = nm.myattribs[None]
|
||||
add_netmask(retattrs['default'])
|
||||
del nm.myattribs[None]
|
||||
retattrs['extranets'] = nm.myattribs
|
||||
for attri in retattrs['extranets']:
|
||||
add_netmask(retattrs['extranets'][attri])
|
||||
return retattrs
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user