wip
This commit is contained in:
parent
84e5176e07
commit
3a390e314e
1 changed files with 15 additions and 10 deletions
|
@ -5,23 +5,28 @@ from ipaddress import ip_interface
|
|||
'interfaces',
|
||||
)
|
||||
def interfaces(metadata):
|
||||
interface = {
|
||||
'ips': [],
|
||||
}
|
||||
|
||||
if metadata.get('network/ipv4', None):
|
||||
interface['ips'].append(metadata.get('network/ipv4'))
|
||||
interface['gateway4'] = metadata.get('network/gateway4')
|
||||
|
||||
if metadata.get('network/ipv6', None):
|
||||
interface['ips'].append(metadata.get('network/ipv6'))
|
||||
interface['gateway6'] = metadata.get('network/gateway6')
|
||||
|
||||
return {
|
||||
'interfaces': {
|
||||
metadata.get('network/interface'): {
|
||||
'ips': list(filter(None.__ne__, [
|
||||
metadata.get('network/ipv4', None),
|
||||
metadata.get('network/ipv6', None),
|
||||
])),
|
||||
'gateway4': metadata.get('network/gateway4', None),
|
||||
'gateway6': metadata.get('network/gateway6', None),
|
||||
},
|
||||
metadata.get('network/interface'): interface,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor.provides(
|
||||
'interfaces/gateway4',
|
||||
'interfaces/gateway6',
|
||||
'network/gateway4',
|
||||
'network/gateway6',
|
||||
)
|
||||
def guess_gateway(metadata):
|
||||
if metadata.get('network/gateway4', None):
|
||||
|
|
Loading…
Reference in a new issue