Skip to content

Commit 61d33aa

Browse files
author
Elias Nygren
committed
allow setting and updating server's plan
1 parent 39b00b3 commit 61d33aa

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

test/json_data/server.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"server" : [
44
{
55
"zone" : "fi-hel1",
6+
"plan": "custom",
67
"core_number" : "0",
78
"title" : "Helsinki server",
89
"hostname" : "fi.example.com",
@@ -17,6 +18,7 @@
1718
},
1819
{
1920
"zone" : "uk-lon1",
21+
"plan": "custom",
2022
"core_number" : "0",
2123
"title" : "London server",
2224
"hostname" : "uk.example.com",

test/json_data/server_00798b85-efdc-41ca-8021-f6ef457b8531.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"vnc_host" : "fi-he1l.vnc.upcloud.com",
4646
"vnc_password" : "aabbccdd",
4747
"vnc_port" : "00000",
48-
"zone" : "fi-hel1"
48+
"zone" : "fi-hel1",
49+
"plan": "custom"
4950
}
5051
}

test/json_data/server_009d64ef-31d1-4684-a26b-c86c955cbf46.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"vnc_host" : "fi-he1l.vnc.upcloud.com",
4545
"vnc_password" : "aabbccdd",
4646
"vnc_port" : "00000",
47-
"zone" : "uk-lon1"
47+
"zone" : "uk-lon1",
48+
"plan": "custom"
4849
}
4950
}

test/json_data/server_create.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"video_model" : "cirrus",
4545
"vnc" : "off",
4646
"vnc_password" : "aabbccdd",
47-
"zone" : "us-chi1"
47+
"zone" : "us-chi1",
48+
"plan": "custom"
4849
}
49-
}
50+
}

upcloud_api/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class Server(BaseAPI):
2626
#
2727

2828
updateable_fields = [ "boot_order", "core_number", "firewall", "hostname", "memory_amount",
29-
"nic_model", "title", "timezone", "video_model", "vnc", "vnc_password" ]
29+
"nic_model", "title", "timezone", "video_model", "vnc", "vnc_password",
30+
"plan" ]
3031

3132

3233
def __init__(self, server=None, **kwargs):
@@ -263,6 +264,7 @@ def prepare_post_body(self):
263264
}
264265

265266
# optional
267+
if hasattr(self, "plan"): body["server"]["plan"] = self.plan
266268
if hasattr(self, "core_number"): body["server"]["core_number"] = self.core_number
267269
if hasattr(self, "memory_amount"): body["server"]["memory_amount"] = self.memory_amount
268270
if hasattr(self, "boot_order"): body["server"]["boot_order"] = self.boot_order

0 commit comments

Comments
 (0)