Skip to content

Commit 1c7346d

Browse files
lewistorringtonlu1a
authored andcommitted
fix: force metadata service true if user chose storage os which requires metdata
1 parent bd1cda5 commit 1c7346d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

upcloud_api/server.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from upcloud_api.firewall import FirewallRule
55
from upcloud_api.ip_address import IPAddress
66
from upcloud_api.server_group import ServerGroup
7-
from upcloud_api.storage import Storage
7+
from upcloud_api.storage import STORAGE_OSES_WHICH_REQUIRE_METADATA, Storage
88
from upcloud_api.upcloud_resource import UpCloudResource
99
from upcloud_api.utils import try_it_n_times
1010

@@ -393,6 +393,16 @@ def prepare_post_body(self):
393393
if hasattr(self, 'metadata') and isinstance(self.metadata, bool):
394394
body['server']['metadata'] = "yes" if self.metadata else "no"
395395

396+
# metadata service has to be "yes" for certain OSes
397+
for storage in self.storage_devices:
398+
if (
399+
hasattr(storage, 'os')
400+
and storage.os
401+
and storage.os in STORAGE_OSES_WHICH_REQUIRE_METADATA
402+
):
403+
body['server']['metadata'] = "yes"
404+
break
405+
396406
if hasattr(self, 'server_group') and isinstance(self.server_group, ServerGroup):
397407
body['server']['server_group'] = f"{self.server_group.uuid}"
398408

upcloud_api/storage.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
from upcloud_api.upcloud_resource import UpCloudResource
44

5+
STORAGE_OSES_WHICH_REQUIRE_METADATA = [
6+
"01000000-0000-4000-8000-000020060100", # Debian GNU/Linux 11 (Bullseye)
7+
"01000000-0000-4000-8000-000020070100", # Debian GNU/Linux 12 (Bookworm)
8+
"01000000-0000-4000-8000-000030200200", # Ubuntu Server 20.04 LTS (Focal Fossa)
9+
"01000000-0000-4000-8000-000030220200", # Ubuntu Server 22.04 LTS (Jammy Jellyfish)
10+
"01000000-0000-4000-8000-000030240200", # Ubuntu Server 24.04 LTS (Noble Numbat)
11+
"01000000-0000-4000-8000-000140010100", # AlmaLinux 8
12+
"01000000-0000-4000-8000-000140020100", # AlmaLinux 9
13+
"01000000-0000-4000-8000-000150010100", # Rocky Linux 8
14+
"01000000-0000-4000-8000-000150020100", # Rocky Linux 9
15+
]
16+
517

618
class BackupDeletionPolicy(Enum):
719
"""

0 commit comments

Comments
 (0)