Fix archived machine bu (#43017)
This commit is contained in:
parent
06f5e49dfb
commit
267c7667f6
1 changed files with 31 additions and 5 deletions
|
@ -102,15 +102,24 @@ def extract_public_ipv4(server_info):
|
|||
|
||||
|
||||
def extract_private_ipv4(server_info):
|
||||
return server_info["private_ip"]
|
||||
try:
|
||||
return server_info["private_ip"]
|
||||
except (KeyError, TypeError):
|
||||
return None
|
||||
|
||||
|
||||
def extract_hostname(server_info):
|
||||
return server_info["hostname"]
|
||||
try:
|
||||
return server_info["hostname"]
|
||||
except (KeyError, TypeError):
|
||||
return None
|
||||
|
||||
|
||||
def extract_server_id(server_info):
|
||||
return server_info["id"]
|
||||
try:
|
||||
return server_info["id"]
|
||||
except (KeyError, TypeError):
|
||||
return None
|
||||
|
||||
|
||||
def extract_public_ipv6(server_info):
|
||||
|
@ -120,6 +129,19 @@ def extract_public_ipv6(server_info):
|
|||
return None
|
||||
|
||||
|
||||
def extract_tags(server_info):
|
||||
try:
|
||||
return server_info["tags"]
|
||||
except (KeyError, TypeError):
|
||||
return None
|
||||
|
||||
|
||||
def extract_zone(server_info):
|
||||
try:
|
||||
return server_info["location"]["zone_id"]
|
||||
except (KeyError, TypeError):
|
||||
return None
|
||||
|
||||
extractors = {
|
||||
"public_ipv4": extract_public_ipv4,
|
||||
"private_ipv4": extract_private_ipv4,
|
||||
|
@ -161,8 +183,12 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
return set(SCALEWAY_LOCATION.keys()).intersection(config_zones)
|
||||
|
||||
def match_groups(self, server_info, tags):
|
||||
server_zone = server_info["location"]["zone_id"]
|
||||
server_tags = server_info["tags"]
|
||||
server_zone = extract_zone(server_info=server_info)
|
||||
server_tags = extract_tags(server_info=server_info)
|
||||
|
||||
# If a server does not have a zone, it means it is archived
|
||||
if server_zone is None:
|
||||
return set()
|
||||
|
||||
# If no filtering is defined, all tags are valid groups
|
||||
if tags is None:
|
||||
|
|
Loading…
Reference in a new issue