From 994d35388d3662ea6a7f9815fddbc01d58545cdc Mon Sep 17 00:00:00 2001 From: lewistorrington Date: Fri, 12 Jul 2024 09:35:31 +0300 Subject: [PATCH 1/5] fix: initial pass on docs updates for correctness --- README.md | 1 - docs/Firewall.md | 4 ++-- docs/Server.md | 4 ++-- docs/index.md | 3 --- upcloud_api/cloud_manager/server_mixin.py | 1 + 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8decd6d..da9bc8d 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,6 @@ cluster = { ), 'web2': Server( plan='2xCPU-4GB', - memory_amount=1024, hostname='web2.example.com', zone='uk-lon1', storage_devices=[ diff --git a/docs/Firewall.md b/docs/Firewall.md index 3b1c222..03a730f 100644 --- a/docs/Firewall.md +++ b/docs/Firewall.md @@ -4,11 +4,11 @@ Firewall is configured with FirewallRule objects that are specific to each server. Please note that a servers firewall rules are ignored if firewall is turned off -(see [Server](/server) and [API documentation](https://www.upcloud.com/api/7-servers/#modify-server)). +(see [Server](/server) and [API documentation](https://developers.upcloud.com/1.3/8-servers/#modify-server)). If a server is removed, its firewall and thus its firewall rules are removed too. -Please refer to the [API documentation](https://www.upcloud.com/api/10-firewall/#create-firewall-rule) +Please refer to the [API documentation](https://developers.upcloud.com/1.3/11-firewall/#create-firewall-rule) for more info on the attributes of FirewallRule. ## List / Get diff --git a/docs/Server.md b/docs/Server.md index b036ae5..d595f01 100644 --- a/docs/Server.md +++ b/docs/Server.md @@ -57,7 +57,7 @@ manager.create_server( server ) Currently available operating system templates can be retrieved with 'manager.get_templates()'. More information on this method can be found in storage_mixin documentation. -Please refer to the [API documentation](https://www.upcloud.com/static/downloads/upcloud-apidoc-1.1.1.pdf) for the allowed Server attributes. +Please refer to the [API documentation](https://developers.upcloud.com/1.3/8-servers/#modify-server) for the allowed Server attributes. ## Update @@ -82,7 +82,7 @@ Updateable attributes: "nic_model", "title", "timezone", "video_model", "vnc", "vnc_password" ``` -Please refer to the [API documentation](https://www.upcloud.com/static/downloads/upcloud-apidoc-1.1.1.pdf) for the allowed values. +Please refer to the [API documentation](https://developers.upcloud.com/1.3/8-servers/#modify-server) for the allowed values. ### Storages diff --git a/docs/index.md b/docs/index.md index 5e66f13..1493694 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,9 +8,6 @@ This documentation includes many code examples for administrating resources on t In some cases it can help to be familiar with [UpCloud's API v1.3 documentation](https://www.upcloud.com/api/). The code itself also has commentary & examples and is structured similarly to this documentation. -If you haven't used UpCloud's API before, please see -[Getting Started With UpCloud’s API](https://www.upcloud.com/support/getting-started-with-upclouds-api/). - The documentation is divided into two parts. Usage describes the basic CRUD functionality for the object representations of different UpCloud resources (servers, storages, networks etc). The CloudManager describes the API for performing direct API calls. diff --git a/upcloud_api/cloud_manager/server_mixin.py b/upcloud_api/cloud_manager/server_mixin.py index a8f2460..f4070b2 100644 --- a/upcloud_api/cloud_manager/server_mixin.py +++ b/upcloud_api/cloud_manager/server_mixin.py @@ -111,6 +111,7 @@ def create_server(self, server: Server) -> Server: * Debian 10: 01000000-0000-4000-8000-000020050100 * Ubuntu 20.04: 01000000-0000-4000-8000-000030200200 * Windows 2019: 01000000-0000-4000-8000-000010070300 + """ if isinstance(server, Server): body = server.prepare_post_body() From 9f5891ed52d31dd40775954e28e6b682cbaf1b4f Mon Sep 17 00:00:00 2001 From: lewistorrington Date: Fri, 12 Jul 2024 12:16:24 +0300 Subject: [PATCH 2/5] fix: naively updated template ID refs --- README.md | 8 ++++---- docs/Server.md | 2 +- docs/Storage.md | 2 +- upcloud_api/cloud_manager/server_mixin.py | 11 ++++++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index da9bc8d..784f5cb 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ cluster = { # OS: template storage UUID, all available os templates can be retrieved by calling manager.get_templates() # Note: the storage os template uuid:s will change when OS is updated. So check that the UUID is correct # default tier: maxIOPS, the 100k IOPS storage backend - Storage(os='01000000-0000-4000-8000-000030200200', size=10), + Storage(os='01000000-0000-4000-8000-000030240200', size=10), # secondary storage, hdd for reduced speed & cost Storage(size=100, tier='hdd') ], @@ -81,7 +81,7 @@ cluster = { hostname='web2.example.com', zone='uk-lon1', storage_devices=[ - Storage(os='01000000-0000-4000-8000-000030200200', size=10), + Storage(os='01000000-0000-4000-8000-000030240200', size=10), Storage(size=100, tier='hdd'), ], login_user=login_user @@ -93,7 +93,7 @@ cluster = { hostname='db.example.com', zone='uk-lon1', storage_devices=[ - Storage(os='01000000-0000-4000-8000-000030200200', size=10), + Storage(os='01000000-0000-4000-8000-000030240200', size=10), Storage(size=100), ], login_user=login_user @@ -103,7 +103,7 @@ cluster = { hostname='balancer.example.com', zone='uk-lon1', storage_devices=[ - Storage(os='01000000-0000-4000-8000-000030200200', size=10) + Storage(os='01000000-0000-4000-8000-000030240200', size=10) ], login_user=login_user ) diff --git a/docs/Server.md b/docs/Server.md index d595f01..4946676 100644 --- a/docs/Server.md +++ b/docs/Server.md @@ -47,7 +47,7 @@ server = Server( hostname = "web1.example.com", zone = 'uk-lon1', storage_devices = [ - Storage(os = "01000000-0000-4000-8000-000030200200", size=10), + Storage(os = "01000000-0000-4000-8000-000030240200", size=10), Storage(size=10, tier="hdd") ]) diff --git a/docs/Storage.md b/docs/Storage.md index 3aa635e..e440094 100644 --- a/docs/Storage.md +++ b/docs/Storage.md @@ -18,7 +18,7 @@ Tiers: ### Templates -Public templates such as the 01000000-0000-4000-8000-000030200200 can be cloned by anyone to get a pre-installed +Public templates such as the 01000000-0000-4000-8000-000030240200 can be cloned by anyone to get a pre-installed server image that is immediately ready to go. A user can also create private templates for themselves out of any storage. Storages can be cloned from templates during server creation. diff --git a/upcloud_api/cloud_manager/server_mixin.py b/upcloud_api/cloud_manager/server_mixin.py index f4070b2..1fef868 100644 --- a/upcloud_api/cloud_manager/server_mixin.py +++ b/upcloud_api/cloud_manager/server_mixin.py @@ -94,7 +94,7 @@ def create_server(self, server: Server) -> Server: zone = "uk-lon1", labels = [Label('role', 'example')], storage_devices = [ - Storage(os = "01000000-0000-4000-8000-000030200200", size=10, tier=maxiops, title='Example OS disk'), + Storage(os = "01000000-0000-4000-8000-000030240200", size=10, tier=maxiops, title='Example OS disk'), Storage(size=10, labels=[Label('usage', 'data_disk')]), Storage() title = "My Example Server" @@ -107,10 +107,11 @@ def create_server(self, server: Server) -> Server: (id is a running starting from 1) - tier defaults to maxiops - valid operating systems are for example: - * CentOS 8: 01000000-0000-4000-8000-000050010400 - * Debian 10: 01000000-0000-4000-8000-000020050100 - * Ubuntu 20.04: 01000000-0000-4000-8000-000030200200 - * Windows 2019: 01000000-0000-4000-8000-000010070300 + * Debian GNU/Linux 12 (Bookworm): 01000000-0000-4000-8000-000020070100 + * Ubuntu Server 24.04 LTS (Noble Numbat): 01000000-0000-4000-8000-000030240200 + * Rocky Linux 9: 01000000-0000-4000-8000-000150020100 + * Windows Server 2022 Standard: 01000000-0000-4000-8000-000010080300 + (for a more up-to-date listing, use UpCloud's CLI: `upctl storage list --public --template`.) """ if isinstance(server, Server): From ccb7ba956824232715c6772931d621b17cc94df5 Mon Sep 17 00:00:00 2001 From: lewistorrington Date: Fri, 12 Jul 2024 13:50:26 +0300 Subject: [PATCH 3/5] fix: force metadata service true if user chose storage os which requires metdata --- upcloud_api/server.py | 12 +++++++++++- upcloud_api/storage.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/upcloud_api/server.py b/upcloud_api/server.py index 691eb6c..4cf80af 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,16 @@ 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..7eaf0d6 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): """ From f1c4f1a3ae8aa08496b912b841d699702471655b Mon Sep 17 00:00:00 2001 From: lewistorrington Date: Fri, 12 Jul 2024 14:05:00 +0300 Subject: [PATCH 4/5] fix: removing debian 11 from hardcoded metadata-needing OSes since it doesn't actually use cloud-init --- upcloud_api/storage.py | 1 - 1 file changed, 1 deletion(-) diff --git a/upcloud_api/storage.py b/upcloud_api/storage.py index 7eaf0d6..42ceee7 100644 --- a/upcloud_api/storage.py +++ b/upcloud_api/storage.py @@ -3,7 +3,6 @@ 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) From fff2d72b8ed9192a94f9c151d60c3e97aea01c71 Mon Sep 17 00:00:00 2001 From: lewistorrington Date: Fri, 12 Jul 2024 14:07:18 +0300 Subject: [PATCH 5/5] fix: removed other OSes that don't actually require cloud-init --- upcloud_api/storage.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/upcloud_api/storage.py b/upcloud_api/storage.py index 42ceee7..dff5b16 100644 --- a/upcloud_api/storage.py +++ b/upcloud_api/storage.py @@ -4,12 +4,9 @@ STORAGE_OSES_WHICH_REQUIRE_METADATA = [ "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 ]