Skip to content

Commit f70556b

Browse files
committed
Changes from local branch
1 parent c5880bd commit f70556b

18 files changed

+73
-140
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ You must take this into account in your automations.
6868
```python
6969

7070
import upcloud_api
71-
from upcloud_api import Server, Storage, ZONE, login_user_block
71+
from upcloud_api import Server, Storage, login_user_block
7272

7373
manager = upcloud_api.CloudManager('api_user', 'password')
7474
manager.authenticate()
@@ -85,11 +85,11 @@ cluster = {
8585
core_number=1, # CPU cores
8686
memory_amount=1024, # RAM in MB
8787
hostname='web1.example.com',
88-
zone=ZONE.London, # ZONE.Helsinki and ZONE.Chicago available also
88+
zone='uk-lon1', # All available zones with ids can be retrieved by using manager.get_zones()
8989
storage_devices=[
90-
# OS: Ubuntu 14.04 from template
90+
# OS: 01000000-0000-4000-8000-000030060200, all available os templates can be retrieved by calling manager.get_templates()
9191
# default tier: maxIOPS, the 100k IOPS storage backend
92-
Storage(os='Ubuntu 14.04', size=10),
92+
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
9393
# secondary storage, hdd for reduced cost
9494
Storage(size=100, tier='hdd')
9595
],
@@ -99,19 +99,19 @@ cluster = {
9999
core_number=1,
100100
memory_amount=1024,
101101
hostname='web2.example.com',
102-
zone=ZONE.London,
102+
zone='uk-lon1',
103103
storage_devices=[
104-
Storage(os='Ubuntu 14.04', size=10),
104+
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
105105
Storage(size=100, tier='hdd'),
106106
],
107107
login_user=login_user
108108
),
109109
'db': Server(
110110
plan='2xCPU-4GB', # use a preconfigured plan, instead of custom
111111
hostname='db.example.com',
112-
zone=ZONE.London,
112+
zone='uk-lon1',
113113
storage_devices=[
114-
Storage(os='Ubuntu 14.04', size=10),
114+
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
115115
Storage(size=100),
116116
],
117117
login_user=login_user
@@ -120,9 +120,9 @@ cluster = {
120120
core_number=2,
121121
memory_amount=1024,
122122
hostname='balancer.example.com',
123-
zone=ZONE.London,
123+
zone='uk-lon1',
124124
storage_devices=[
125-
Storage(os='Ubuntu 14.04', size=10)
125+
Storage(os='01000000-0000-4000-8000-000030060200', size=10)
126126
],
127127
login_user=login_user
128128
)
@@ -187,7 +187,7 @@ clone = Server(
187187
core_number=1,
188188
memory_amount=1024,
189189
hostname='cloned.server',
190-
zone=ZONE.Helsinki,
190+
zone='fi-hel1',
191191
storage_devices=[
192192
Storage(
193193
uuid='012bea57-0f70-4194-82d0-b3d25f4a018b',

docs/CloudManager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ manager.get_account()
2626

2727
# Zone
2828

29-
Zones are already hardcoded as Enums in `upcloud_api.ZONE`. However, they can be queried from the API too.
29+
Zones can be queried from the api.
3030

3131
```python
3232

docs/Server.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ The examples use the following:
33
import upcloud_api
44
from upcloud_api import Server
55
from upcloud_api import Storage
6-
from upcloud_api import ZONE
76

87
manager = upcloud_api.CloudManager("username", "password")
98
```
@@ -53,9 +52,9 @@ server = Server(
5352
core_number = 1,
5453
memory_amount = 1024,
5554
hostname = "web1.example.com",
56-
zone = ZONE.London,
55+
zone = 'uk-lon1',
5756
storage_devices = [
58-
Storage(os = "Ubuntu 14.04", size=10),
57+
Storage(os = "01000000-0000-4000-8000-000030060200", size=10),
5958
Storage(size=10, tier="hdd")
6059
])
6160

@@ -68,11 +67,7 @@ Currently available Storage operating systems are the following UpCloud public t
6867
```python
6968
# upcloud_api/tools.py
7069

71-
Operating Systems:
72-
"CentOS 6.5", "CentOS 7.0",
73-
"Debian 7.8", "Ubuntu 12.04", "Ubuntu 14.04",
74-
"Windows 2003", "Windows 2008", "Windows 2012"
75-
70+
Valid Operating Systems cam be retrieved with 'manager.get_templates()'. More information on this method can be found in storage_mixin documentation.
7671
```
7772

7873

@@ -110,7 +105,7 @@ A Server's Storages can be attached and detached with `.add_storage()` and `.rem
110105
```python
111106

112107
# attach
113-
storage = manager.create_storage( size=100, zone=ZONE.Helsinki )
108+
storage = manager.create_storage( size=100, zone='fi-hel1' )
114109
server.add_storage(storage)
115110

116111
# detach

docs/Storage.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ The code examples use the following:
33
```python
44
import upcloud_api
55
from upcloud_api import Storage
6-
from upcloud_api import ZONE
76

87
manager = upcloud_api.CloudManager("username", "password")
98
```
@@ -24,7 +23,7 @@ Tiers:
2423

2524
### Templates
2625

27-
Public templates such as the Ubuntu 14.04 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.
26+
Public templates such as the 01000000-0000-4000-8000-000030060200 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.
2827

2928
## List / Get
3029

@@ -54,9 +53,9 @@ Storage can be created with the CloudManager's `.create_storage(size=10, tier="m
5453
storage1 = manager.create_storage( size=10,
5554
tier="maxiops",
5655
title="my storage disk",
57-
zone=ZONE.Helsinki )
56+
zone='fi-hel1' )
5857

59-
storage2 = manager.create_storage(100, zone=ZONE.Helsinki)
58+
storage2 = manager.create_storage(100, zone='fi-hel1')
6059

6160
```
6261

@@ -91,7 +90,7 @@ Method requires title and zone to be passed while tier is optional.
9190

9291
```python
9392

94-
storage_clone = storage.clone(title='title of storage clone', zone=ZONE.Helsinki, tier=None)
93+
storage_clone = storage.clone(title='title of storage clone', zone='fi-hel1', tier=None)
9594

9695
```
9796

docs/server-mixin.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def create_server(self, server):
4343
server1 = Server( core_number = 1,
4444
memory_amount = 1024,
4545
hostname = "my.example.1",
46-
zone = ZONE.London,
46+
zone = "uk-lon1",
4747
storage_devices = [
48-
Storage(os = "Ubuntu 14.04", size=10, tier=maxiops, title='The OS drive'),
48+
Storage(os="01000000-0000-4000-8000-000030060200", size=10, tier=maxiops, title='The OS drive'),
4949
Storage(size=10),
5050
Storage()
5151
title = "My Example Server"
@@ -56,11 +56,8 @@ def create_server(self, server):
5656
- size defaults to 10,
5757
- title defaults to hostname + " OS disk" and hostname + " storage disk id" (id is a running starting from 1)
5858
- tier defaults to maxiops
59-
- valid operating systems are:
60-
"CentOS 6.5", "CentOS 7.0"
61-
"Debian 7.8"
62-
"Ubuntu 12.04", "Ubuntu 14.04"
63-
"Windows 2003","Windows 2008" ,"Windows 2012"
59+
- valid operating systems with names and ids can be retrieved by calling manager.get_templates():
60+
More detailed documentation of this method can be found in storage_mixin documentation.
6461
6562
"""
6663
```

docs/storage-mixin.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ def get_storage(self, UUID):
2929
"""
3030
```
3131

32+
```python
33+
def get_templates(self):
34+
"""
35+
Return a list of Storages that are templates in a dict with title as key and uuid as value.
36+
"""
37+
```
38+
3239
```python
3340
def create_storage(self, size=10, tier="maxiops", title="Storage disk", zone="fi-hel1"):
3441
"""

sandbox.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/helpers/infra.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import division
44
from __future__ import absolute_import
55

6-
from upcloud_api import CloudManager, Storage, FirewallRule, ZONE, Tag, IPAddress
6+
from upcloud_api import CloudManager, Storage, FirewallRule, Tag, IPAddress
77
from upcloud_api.server import Server, login_user_block
88

99

@@ -12,21 +12,21 @@
1212
core_number=1,
1313
memory_amount=1024,
1414
hostname='web1.example.com',
15-
zone=ZONE.London,
15+
zone='uk-lon1',
1616
password_delivery='none',
1717
storage_devices=[
18-
Storage(os='Ubuntu 14.04', size=10),
18+
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
1919
Storage(size=10, tier='maxiops')
2020
]),
2121

2222
'web2': Server(
2323
core_number=1,
2424
memory_amount=1024,
2525
hostname='web2.example.com',
26-
zone=ZONE.London,
26+
zone='uk-lon1',
2727
password_delivery='none',
2828
storage_devices=[
29-
Storage(os='Ubuntu 14.04', size=10),
29+
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
3030
Storage(size=10, tier='maxiops'),
3131
],
3232
ip_addresses=[
@@ -37,10 +37,10 @@
3737
core_number=1,
3838
memory_amount=1024,
3939
hostname='db.example.com',
40-
zone=ZONE.London,
40+
zone='uk-lon1',
4141
password_delivery='none',
4242
storage_devices=[
43-
Storage(os='CentOS 7.6', size=10),
43+
Storage(os='01000000-0000-4000-8000-000050010300', size=10),
4444
Storage(size=10),
4545
],
4646
login_user=login_user_block('testuser', ['ssh-rsa AAAAB3NzaC1yc2EAA[...]ptshi44x user@some.host'], True),
@@ -50,7 +50,7 @@
5050
'lb': Server(
5151
plan= '1xCPU-1GB',
5252
hostname='balancer.example.com',
53-
zone=ZONE.London,
53+
zone='uk-lon1',
5454
password_delivery='none',
5555
storage_devices=[
5656
Storage(os='Debian 10.0', size=30)

test/helpers/infra_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import division
44
from __future__ import absolute_import
55

6-
from upcloud_api import ZONE, Tag
6+
from upcloud_api import Tag
77

88

99
def create_cluster(manager, cluster):
@@ -52,7 +52,7 @@ def server_test(manager, server):
5252

5353
server.add_ip()
5454

55-
storage = manager.create_storage(size=10, tier='maxiops', zone=ZONE.London)
55+
storage = manager.create_storage(size=10, tier='maxiops', zone='uk-lon1')
5656
server.add_storage(storage)
5757

5858
server.start()

test/json_data/server_create.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"address" : "virtio:0",
2727
"storage" : "01215a5a-c330-4565-81ca-0e0e22eac672",
2828
"storage_size" : 20,
29-
"storage_title" : "Ubuntu 14.04 from template",
29+
"storage_title" : "01000000-0000-4000-8000-000030060200 from template",
3030
"type" : "disk"
3131
},
3232
{

0 commit comments

Comments
 (0)