Skip to content

Commit

Permalink
fix: force metadata service true if user chose storage os which requi…
Browse files Browse the repository at this point in the history
…res metdata
  • Loading branch information
lewistorrington committed Jul 12, 2024
1 parent 9f5891e commit a621283
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion upcloud_api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}"

Expand Down
12 changes: 12 additions & 0 deletions upcloud_api/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit a621283

Please sign in to comment.