1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

fix: also check server type deprecation after server creation (#696)

##### SUMMARY

Because the location of a server is not mandatory for creating a server,
we must also check server type deprecation after server creation.

##### ISSUE TYPE

- Bugfix Pull Request


##### COMPONENT NAME
server
This commit is contained in:
Jonas L. 2025-09-29 14:34:54 +02:00 committed by GitHub
parent 2864379079
commit c4dc19c675
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 7 deletions

View file

@ -18,7 +18,7 @@ def deprecated_server_type_warning(
module: AnsibleModule,
server_type: BoundServerType,
location: BoundLocation | None = None,
) -> None:
) -> bool:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
if server_type.deprecation is not None:
@ -40,7 +40,7 @@ def deprecated_server_type_warning(
)
+ DEPRECATED_EXISTING_SERVERS,
)
return
return True
deprecated_locations: list[ServerTypeLocation] = []
unavailable_locations: list[ServerTypeLocation] = []
@ -52,13 +52,13 @@ def deprecated_server_type_warning(
unavailable_locations.append(o)
if not deprecated_locations:
return
return False
# Warn when the server type is deprecated in the given location
if location:
found = [o for o in deprecated_locations if location.name == o.location.name]
if not found:
return
return False
deprecated_location = found[0]
@ -83,11 +83,11 @@ def deprecated_server_type_warning(
+ DEPRECATED_EXISTING_SERVERS,
)
return
return True
# No location given, only warn when all locations are deprecated
if len(server_type.locations) != len(deprecated_locations):
return
return False
if unavailable_locations:
@ -122,3 +122,5 @@ def deprecated_server_type_warning(
)
+ DEPRECATED_EXISTING_SERVERS,
)
return True