diff --git a/upcloud_api/server.py b/upcloud_api/server.py index 691eb6c..69a43ee 100644 --- a/upcloud_api/server.py +++ b/upcloud_api/server.py @@ -4,7 +4,7 @@ from upcloud_api.firewall import FirewallRule from upcloud_api.ip_address import IPAddress from upcloud_api.server_group import ServerGroup -from upcloud_api.storage import Storage +from upcloud_api.storage import STORAGE_OSES_WHICH_REQUIRE_METADATA, Storage from upcloud_api.upcloud_resource import UpCloudResource from upcloud_api.utils import try_it_n_times @@ -393,6 +393,12 @@ def prepare_post_body(self): if hasattr(self, 'metadata') and isinstance(self.metadata, bool): body['server']['metadata'] = "yes" if self.metadata else "no" + # metadata service has to be "yes" for certain OSes + for storage in self.storage_devices: + if hasattr(storage, 'os') and storage.os and storage.os in STORAGE_OSES_WHICH_REQUIRE_METADATA: + body['server']['metadata'] = "yes" + break + if hasattr(self, 'server_group') and isinstance(self.server_group, ServerGroup): body['server']['server_group'] = f"{self.server_group.uuid}" diff --git a/upcloud_api/storage.py b/upcloud_api/storage.py index 51e9ebb..1ffbd3b 100644 --- a/upcloud_api/storage.py +++ b/upcloud_api/storage.py @@ -2,6 +2,18 @@ from upcloud_api.upcloud_resource import UpCloudResource +STORAGE_OSES_WHICH_REQUIRE_METADATA = [ + "01000000-0000-4000-8000-000020060100", # Debian GNU/Linux 11 (Bullseye) + "01000000-0000-4000-8000-000020070100", # Debian GNU/Linux 12 (Bookworm) + "01000000-0000-4000-8000-000030200200", # Ubuntu Server 20.04 LTS (Focal Fossa) + "01000000-0000-4000-8000-000030220200", # Ubuntu Server 22.04 LTS (Jammy Jellyfish) + "01000000-0000-4000-8000-000030240200", # Ubuntu Server 24.04 LTS (Noble Numbat) + "01000000-0000-4000-8000-000140010100", # AlmaLinux 8 + "01000000-0000-4000-8000-000140020100", # AlmaLinux 9 + "01000000-0000-4000-8000-000150010100", # Rocky Linux 8 + "01000000-0000-4000-8000-000150020100" # Rocky Linux 9 +] + class BackupDeletionPolicy(Enum): """