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',
|
'interfaces',
|
||||||
)
|
)
|
||||||
def interfaces(metadata):
|
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 {
|
return {
|
||||||
'interfaces': {
|
'interfaces': {
|
||||||
metadata.get('network/interface'): {
|
metadata.get('network/interface'): 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_reactor.provides(
|
@metadata_reactor.provides(
|
||||||
'interfaces/gateway4',
|
'network/gateway4',
|
||||||
'interfaces/gateway6',
|
'network/gateway6',
|
||||||
)
|
)
|
||||||
def guess_gateway(metadata):
|
def guess_gateway(metadata):
|
||||||
if metadata.get('network/gateway4', None):
|
if metadata.get('network/gateway4', None):
|
||||||
|
|
Loading…
Reference in a new issue