[thread-cert] support to get link-local address of the infra interface (#10603)

This commit targets to support getting infra link-local address of a
OtbrNode in docker test, which is usefully for future test cases.

The test_multi_ail.py is also updated to test the new method added.
This commit is contained in:
Jason Zhang
2024-08-15 07:35:18 -07:00
committed by GitHub
parent 54571af6a7
commit 93e838102c
3 changed files with 30 additions and 6 deletions
+11
View File
@@ -3804,6 +3804,8 @@ class LinuxHost():
"""
if address_type == config.ADDRESS_TYPE.BACKBONE_GUA:
return self._getBackboneGua()
elif address_type == config.ADDRESS_TYPE.BACKBONE_LINK_LOCAL:
return self._getInfraLinkLocalAddress()
elif address_type == config.ADDRESS_TYPE.ONLINK_ULA:
return self._getInfraUla()
elif address_type == config.ADDRESS_TYPE.ONLINK_GUA:
@@ -3835,6 +3837,15 @@ class LinuxHost():
gua_prefix = config.ONLINK_GUA_PREFIX.split('::/')[0]
return [addr for addr in self.get_ether_addrs() if addr.startswith(gua_prefix)]
def _getInfraLinkLocalAddress(self) -> Optional[str]:
""" Returns the link-local address autoconfigured on the infra link, which is started with "fe80".
"""
for addr in self.get_ether_addrs():
if re.match(config.LINK_LOCAL_REGEX_PATTERN, addr, re.I):
return addr
return None
def ping(self, *args, **kwargs):
backbone = kwargs.pop('backbone', False)
if backbone: