Skip to content

Commit 8bbbe48

Browse files
committed
wip
1 parent 5f558e6 commit 8bbbe48

File tree

4 files changed

+168
-1
lines changed

4 files changed

+168
-1
lines changed

sandbox.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import upcloud_api
2+
from upcloud_api import Server, Storage, ZONE, login_user_block
3+
4+
manager = upcloud_api.CloudManager('techconsult', 'LetMeTest123')
5+
manager.authenticate()
6+
7+
8+
storages = manager.get_storages(storage_type='template')

test/json_data/fagfdg.json

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
{
2+
"storages":
3+
{
4+
"storage":
5+
[
6+
{
7+
"access": "public",
8+
"license": 3.36,
9+
"size": 28,
10+
"state": "online",
11+
"title": "Windows Server 2016 Datacenter",
12+
"type": "template",
13+
"uuid": "01000000-0000-4000-8000-000010060200"
14+
},
15+
{
16+
"access": "public",
17+
"license": 0.694,
18+
"size": 29,
19+
"state": "online",
20+
"title": "Windows Server 2016 Standard",
21+
"type": "template",
22+
"uuid": "01000000-0000-4000-8000-000010060300"
23+
},
24+
{
25+
"access": "public",
26+
"license": 3.36,
27+
"size": 25,
28+
"state": "online",
29+
"title": "Windows Server 2019 Datacenter",
30+
"type": "template",
31+
"uuid": "01000000-0000-4000-8000-000010070200"
32+
},
33+
{
34+
"access": "public",
35+
"license": 0.694,
36+
"size": 25,
37+
"state": "online",
38+
"title": "Windows Server 2019 Standard",
39+
"type": "template",
40+
"uuid": "01000000-0000-4000-8000-000010070300"
41+
},
42+
{
43+
"access": "public",
44+
"license": 0,
45+
"size": 3,
46+
"state": "online",
47+
"title": "Debian GNU/Linux 9 (Stretch)",
48+
"type": "template",
49+
"uuid": "01000000-0000-4000-8000-000020040100"
50+
},
51+
{
52+
"access": "public",
53+
"license": 0,
54+
"size": 3,
55+
"state": "online",
56+
"title": "Debian GNU/Linux 10 (Buster)",
57+
"type": "template",
58+
"uuid": "01000000-0000-4000-8000-000020050100"
59+
},
60+
{
61+
"access": "public",
62+
"license": 0,
63+
"size": 3,
64+
"state": "online",
65+
"title": "Ubuntu Server 16.04 LTS (Xenial Xerus)",
66+
"type": "template",
67+
"uuid": "01000000-0000-4000-8000-000030060200"
68+
},
69+
{
70+
"access": "public",
71+
"license": 0,
72+
"size": 4,
73+
"state": "online",
74+
"title": "Ubuntu Server 18.04 LTS (Bionic Beaver)",
75+
"type": "template",
76+
"uuid": "01000000-0000-4000-8000-000030080200"
77+
},
78+
{
79+
"access": "public",
80+
"license": 0,
81+
"size": 4,
82+
"state": "online",
83+
"title": "Ubuntu Server 20.04 LTS (Focal Fossa)",
84+
"type": "template",
85+
"uuid": "01000000-0000-4000-8000-000030200200"
86+
},
87+
{
88+
"access": "public",
89+
"license": 0,
90+
"size": 3,
91+
"state": "online",
92+
"title": "CentOS 6.10",
93+
"type": "template",
94+
"uuid": "01000000-0000-4000-8000-000050010200"
95+
},
96+
{
97+
"access": "public",
98+
"license": 0,
99+
"size": 3,
100+
"state": "online",
101+
"title": "CentOS 7",
102+
"type": "template",
103+
"uuid": "01000000-0000-4000-8000-000050010300"
104+
},
105+
{
106+
"access": "public",
107+
"license": 0,
108+
"size": 3,
109+
"state": "online",
110+
"title": "CentOS 8",
111+
"type": "template",
112+
"uuid": "01000000-0000-4000-8000-000050010400"
113+
},
114+
{
115+
"access": "public",
116+
"license": 0,
117+
"size": 5,
118+
"state": "online",
119+
"title": "Plesk Obsidian",
120+
"type": "template",
121+
"uuid": "01000000-0000-4000-8000-000130010100"
122+
},
123+
{
124+
"access": "private",
125+
"license": 0,
126+
"size": 10,
127+
"state": "online",
128+
"tier": "maxiops",
129+
"title": "import test",
130+
"type": "template",
131+
"uuid": "0124fdf2-e3ae-408b-8711-db8a3dddc85b",
132+
"zone": "fi-hel1"
133+
},
134+
{
135+
"access": "private",
136+
"license": 0,
137+
"size": 30,
138+
"state": "online",
139+
"tier": "maxiops",
140+
"title": "class method test 3",
141+
"type": "template",
142+
"uuid": "0134df64-f6be-408e-b960-6511503471af",
143+
"zone": "fi-hel1"
144+
},
145+
{
146+
"access": "private",
147+
"license": 0,
148+
"size": 10,
149+
"state": "online",
150+
"tier": "maxiops",
151+
"title": "my server template",
152+
"type": "template",
153+
"uuid": "013721b5-07ca-4d7b-b4ff-e21262223e5b",
154+
"zone": "fi-hel2"
155+
}
156+
]
157+
}
158+
}

upcloud_api/cloud_manager/storage_mixin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def get_storages(self, storage_type='normal'):
1919
Storage types: public, private, normal, backup, cdrom, template, favorite
2020
"""
2121
res = self.get_request('/storage/' + storage_type)
22+
print(res)
2223
return Storage._create_storage_objs(res['storages'], cloud_manager=self)
2324

2425
def get_storage(self, storage):

upcloud_api/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def prepare_post_body(self):
344344
# public template
345345
if hasattr(storage, 'os') and storage.os:
346346
storage_body['action'] = 'clone'
347-
storage_body['storage'] = OperatingSystems.get_OS_UUID(storage.os)
347+
storage_body['storage'] = storage.os
348348

349349
# private template
350350
elif hasattr(storage, 'uuid'):

0 commit comments

Comments
 (0)