Expose full interface address list and link state in cloud node API

Each host interface surfaced by the cloud node now reports:
- ip_addresses: every IPv4 and IPv6 address (previously only a single
  IPv4 was collected internally and then dropped before the response)
- status / speed / mtu / flags: operational state and link attributes
  sourced from psutil.net_if_stats(), with flags normalized to a list

The legacy ip_address / netmask / mac_address fields are preserved so
existing callers (compute link detection, GNS3 VM, VMware, has_netmask)
keep working. The new fields travel through the existing interfaces
payload that the controller forwards verbatim, so no controller-side
change is required and the PUT / ports_mapping flow is unaffected.
This commit is contained in:
YueGuobin committed 2026-07-10 13:56:07 +08:00
1 parent a66740e154
commit 9721660cc3
6 files changed
+196 -11

No files matched your search

+6 -6
View File
@@ -72,9 +72,9 @@ async def test_json_with_ports(on_gns3vm, compute_project, manager):
}
],
"interfaces": [
{'name': 'eth0', 'special': False, 'type': 'ethernet'},
{'name': 'eth1', 'special': False, 'type': 'ethernet'},
{'name': 'virbr0', 'special': True, 'type': 'ethernet'}
{'name': 'eth0', 'special': False, 'type': 'ethernet', 'ip_addresses': [], 'status': 'up', 'speed': 1000, 'mtu': 1500, 'flags': ['up', 'broadcast', 'running', 'multicast']},
{'name': 'eth1', 'special': False, 'type': 'ethernet', 'ip_addresses': [], 'status': 'down', 'speed': 0, 'mtu': 1500, 'flags': ['broadcast']},
{'name': 'virbr0', 'special': True, 'type': 'ethernet', 'ip_addresses': [], 'status': 'up', 'speed': 10000, 'mtu': 1500, 'flags': ['up', 'broadcast', 'running', 'multicast']}
]
}
@@ -111,9 +111,9 @@ async def test_json_without_ports(on_gns3vm, compute_project, manager):
}
],
"interfaces": [
{'name': 'eth0', 'special': False, 'type': 'ethernet'},
{'name': 'eth1', 'special': False, 'type': 'ethernet'},
{'name': 'virbr0', 'special': True, 'type': 'ethernet'}
{'name': 'eth0', 'special': False, 'type': 'ethernet', 'ip_addresses': [], 'status': 'up', 'speed': 1000, 'mtu': 1500, 'flags': ['up', 'broadcast', 'running', 'multicast']},
{'name': 'eth1', 'special': False, 'type': 'ethernet', 'ip_addresses': [], 'status': 'down', 'speed': 0, 'mtu': 1500, 'flags': ['broadcast']},
{'name': 'virbr0', 'special': True, 'type': 'ethernet', 'ip_addresses': [], 'status': 'up', 'speed': 10000, 'mtu': 1500, 'flags': ['up', 'broadcast', 'running', 'multicast']}
]
}