Skip to content

Commit 597f1d8

Browse files
author
Elias Nygren
committed
Merge pull request #12 from UpCloudLtd/0.3.2-devel
0.3.2 devel
2 parents 39b00b3 + 3a797b5 commit 597f1d8

14 files changed

+115
-94
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ dist/
99
*.sublime-workspace
1010
docs/html/
1111
.tox
12+
13+
# pyenv
14+
.python-version
15+

README.md

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ NOTE: This Python client is still evolving. Please test all of your use cases th
99
pip install upcloud-api
1010
```
1111

12-
Alternatively, if you want the newest master or a devel branch - clone the project and run:
12+
Alternatively, if you want the newest master or a devel branch - clone the project and run:
1313
```
1414
python setup.py install
1515
```
1616

1717
**!! SSL security update for python 2 !!**
1818
* short story: `pip install requests[security]` should solve all of your problems.
1919
* long story:
20-
* upcloud-python-api uses [requests](http://docs.python-requests.org/en/latest/)
20+
* upcloud-python-api uses [requests](http://docs.python-requests.org/en/latest/)
2121
for HTTP(S) that in turn uses [urllib3](https://urllib3.readthedocs.org/en/latest/)
2222
* urllib3 may detect that your python2.x's SSL is lacking as described
2323
[here](https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning) and
@@ -71,54 +71,59 @@ You must take this into account in your automations.
7171
### Defining and creating Servers
7272

7373
```python
74-
import upcloud
75-
from upcloud import Server, Storage, ZONE
7674

77-
manager = upcloud.CloudManager("api_user", "password")
75+
import upcloud_api
76+
from upcloud_api import Server, Storage, ZONE
77+
78+
manager = upcloud_api.CloudManager('api_user', 'password')
7879
manager.authenticate() # test credentials
7980

8081
cluster = {
81-
"web1": Server( core_number = 1, # CPU cores
82-
memory_amount = 512, # RAM in MB
83-
hostname = "web1.example.com",
84-
zone = ZONE.London, # ZONE.Helsinki and ZONE.Chicago available also
85-
storage_devices = [
86-
# OS: Ubuntu 14.04 from template
87-
# default tier: maxIOPS, the 100k IOPS storage backend
88-
Storage(os = "Ubuntu 14.04", size=10),
89-
# secondary storage, hdd for reduced cost
90-
Storage(size=100, tier="hdd")
91-
]),
92-
93-
"web2": Server( core_number = 1,
94-
memory_amount = 512,
95-
hostname = "web2.example.com",
96-
zone = ZONE.London,
97-
storage_devices = [
98-
Storage(os = "Ubuntu 14.04", size=10),
99-
Storage(size=100, tier="hdd"),
100-
]),
101-
102-
"db": Server( core_number = 2,
103-
memory_amount = 2048,
104-
hostname = "db.example.com",
105-
zone = ZONE.London,
106-
storage_devices = [
107-
Storage(os = "Ubuntu 14.04", size=10),
108-
Storage(size=100),
109-
]),
110-
111-
"lb": Server( core_number = 2,
112-
memory_amount = 1024,
113-
hostname = "balancer.example.com",
114-
zone = ZONE.London,
115-
storage_devices = [
116-
Storage(os = "Ubuntu 14.04", size=10)
117-
])
82+
'web1': Server(
83+
core_number = 1, # CPU cores
84+
memory_amount = 512, # RAM in MB
85+
hostname = 'web1.example.com',
86+
zone = ZONE.London, # ZONE.Helsinki and ZONE.Chicago available also
87+
storage_devices = [
88+
# OS: Ubuntu 14.04 from template
89+
# default tier: maxIOPS, the 100k IOPS storage backend
90+
Storage(os = 'Ubuntu 14.04', size = 10),
91+
# secondary storage, hdd for reduced cost
92+
Storage(size = 100, tier = 'hdd')
93+
]
94+
),
95+
'web2': Server(
96+
core_number = 1,
97+
memory_amount = 512,
98+
hostname = 'web2.example.com',
99+
zone = ZONE.London,
100+
storage_devices = [
101+
Storage(os = 'Ubuntu 14.04', size = 10),
102+
Storage(size = 100, tier = 'hdd'),
103+
]
104+
),
105+
'db': Server(
106+
plan = '2xCPU-2GB' # use a preconfigured plan, instead of custom
107+
hostname = 'db.example.com',
108+
zone = ZONE.London,
109+
storage_devices = [
110+
Storage(os = 'Ubuntu 14.04', size = 10),
111+
Storage(size = 100),
112+
]
113+
),
114+
'lb': Server(
115+
core_number = 2,
116+
memory_amount = 1024,
117+
hostname = 'balancer.example.com',
118+
zone = ZONE.London,
119+
storage_devices = [
120+
Storage(os = 'Ubuntu 14.04', size = 10)
121+
]
122+
)
118123
}
119124

120125
for server in cluster:
121-
manager.create_server( cluster[server] ) # automatically populates the Server objects with data from API
126+
manager.create_server(cluster[server]) # automatically populates the Server objects with data from API
122127

123128
```
124129

@@ -141,7 +146,7 @@ for server in cluster:
141146

142147
```
143148

144-
New in 0.3.0: as the success of server.start() or server.destroy() and storage.destroy()
149+
New in 0.3.0: as the success of server.start() or server.destroy() and storage.destroy()
145150
depend on the Server's `state`, new helpers have been added. The helpers may be called regardless of
146151
the server's current state.
147152

docs/CloudManager.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ manager.get_account()
1313

1414
# Zone
1515

16-
Zones are already hardcoded as Enums in `upcloud.ZONE`. However, they can be queried from the API too.
16+
Zones are already hardcoded as Enums in `upcloud_api.ZONE`. However, they can be queried from the API too.
1717

1818
```python
1919

@@ -47,4 +47,4 @@ List the possible server CPU-ram configurations.
4747

4848
manager.get_server_sizes
4949

50-
```
50+
```

docs/Firewall.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
The code examples use the following:
22

33
```python
4-
import upcloud
5-
from upcloud import FirewallRule
4+
import upcloud_api
5+
from upcloud_api import FirewallRule
66

7-
manager = upcloud.CloudManager("username", "password")
7+
manager = upcloud_api.CloudManager("username", "password")
88
```
99

1010
# About

docs/Server.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
The examples use the following:
22
```python
3-
import upcloud
4-
from upcloud import Server
5-
from upcloud import Storage
6-
from upcloud import ZONE
3+
import upcloud_api
4+
from upcloud_api import Server
5+
from upcloud_api import Storage
6+
from upcloud_api import ZONE
77

8-
manager = upcloud.CloudManager("username", "password")
8+
manager = upcloud_api.CloudManager("username", "password")
99
```
1010

1111
# Start / Stop / Restart
1212

1313
```python
1414

15-
server.stop()
15+
server.stop()
1616
server.start()
1717
server.restart()
1818

@@ -24,7 +24,7 @@ server.populate()
2424
Please note that the server might not be stopped/started/restarted immediately when the API responds. The `.populate()` method updates the object's fields from the API and is thus useful for checking `server.state`.
2525

2626
```
27-
Server states:
27+
Server states:
2828
"started","stopped" -- server is shut down or running
2929
"maintenance" -- when shutting down or (re)starting
3030
"error" -- erronous state in UpCloud's backend
@@ -50,10 +50,10 @@ Creation of servers in the API is handled by the CloudManager. It accepts a Serv
5050
```python
5151

5252
server = Server(
53-
core_number = 1,
54-
memory_amount = 512,
55-
hostname = "web1.example.com",
56-
zone = ZONE.London,
53+
core_number = 1,
54+
memory_amount = 512,
55+
hostname = "web1.example.com",
56+
zone = ZONE.London,
5757
storage_devices = [
5858
Storage(os = "Ubuntu 14.04", size=10),
5959
Storage(size=10, tier="hdd")
@@ -66,11 +66,11 @@ manager.create_server( server )
6666
Currently available Storage operating systems are the following UpCloud public templates:
6767

6868
```python
69-
# upcloud/tools.py
69+
# upcloud_api/tools.py
7070

7171
Operating Systems:
72-
"CentOS 6.5", "CentOS 7.0",
73-
"Debian 7.8", "Ubuntu 12.04", "Ubuntu 14.04",
72+
"CentOS 6.5", "CentOS 7.0",
73+
"Debian 7.8", "Ubuntu 12.04", "Ubuntu 14.04",
7474
"Windows 2003", "Windows 2008", "Windows 2012"
7575

7676
```
@@ -93,11 +93,11 @@ server.save()
9393

9494
```
9595

96-
The following fields of Server instance may be updated, all other fields are read-only. Trying to assign values to other fields leads to an error.
97-
96+
The following fields of Server instance may be updated, all other fields are read-only. Trying to assign values to other fields leads to an error.
97+
9898
```python
99-
Updateable attributes:
100-
"boot_order", "core_number", "firewall", "hostname", "memory_amount",
99+
Updateable attributes:
100+
"boot_order", "core_number", "firewall", "hostname", "memory_amount",
101101
"nic_model", "title", "timezone", "video_model", "vnc", "vnc_password"
102102
```
103103

@@ -141,4 +141,4 @@ Destroys the Server instance and its IP-addresses. However, does not destroy the
141141

142142
server.destroy()
143143

144-
```
144+
```

docs/Storage.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
The code examples use the following:
22

33
```python
4-
import upcloud
5-
from upcloud import Storage
6-
from upcloud import ZONE
4+
import upcloud_api
5+
from upcloud_api import Storage
6+
from upcloud_api import ZONE
77

8-
manager = upcloud.CloudManager("username", "password")
8+
manager = upcloud_api.CloudManager("username", "password")
99
```
1010

1111
# About
@@ -40,7 +40,7 @@ manager.get_storage(storage.uuid)
4040
`get_storages()` accepts one of the following parameters to filter the query:
4141
```
4242
Storages list filters:
43-
"normal" (default), "public", "private",
43+
"normal" (default), "public", "private",
4444
"backup", "cdrom", "template", "favorite"
4545
```
4646

@@ -51,9 +51,9 @@ Storage can be created with the CloudManager's `.create_storage(size=10, tier="m
5151

5252
```python
5353

54-
storage1 = manager.create_storage( size=10,
55-
tier="maxiops",
56-
title="my storage disk",
54+
storage1 = manager.create_storage( size=10,
55+
tier="maxiops",
56+
title="my storage disk",
5757
zone=ZONE.Helsinki )
5858

5959
storage2 = manager.create_storage(100, zone=ZONE.Helsinki)
@@ -63,7 +63,7 @@ storage2 = manager.create_storage(100, zone=ZONE.Helsinki)
6363

6464
## Update
6565

66-
Only the size and title of a storage can be updated. Please note that size can not be reduced and that OS level actions are required to account for the increased size.
66+
Only the size and title of a storage can be updated. Please note that size can not be reduced and that OS level actions are required to account for the increased size.
6767

6868
```python
6969

@@ -80,4 +80,4 @@ Warning: data loss is permanent.
8080

8181
storage.destroy()
8282

83-
```
83+
```

docs/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ The documentation is divided into two parts. Usage describes the basic CRUD func
1313
The code examples use the following:
1414

1515
```python
16-
import upcloud
17-
from upcloud import Storage
18-
from upcloud import Server
19-
from upcloud import ZONE
16+
import upcloud_api
17+
from upcloud_api import Storage
18+
from upcloud_api import Server
19+
from upcloud_api import ZONE
2020

21-
manager = upcloud.CloudManager("username", "password")
21+
manager = upcloud_api.CloudManager("username", "password")
2222
```

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
setup(
66
name='upcloud-api',
7-
version='0.3.1',
7+
version='0.3.2',
88
description='UpCloud API Client',
99
author='Elias Nygren',
1010
author_email='elias.nygren@upcloud.com',
1111
maintainer='Elias Nygren',
1212
maintainer_email='elias.nygren@upcloud.com',
1313
url='https://github.com/UpCloudLtd/upcloud-python-api',
1414
packages=['upcloud_api', 'upcloud_api.cloud_manager'],
15-
download='https://github.com/UpCloudLtd/upcloud-python-api/tarball/v0.3.1',
15+
download='https://github.com/UpCloudLtd/upcloud-python-api/tarball/v0.3.2',
1616
license='MIT',
1717
install_requires=[
1818
'future==0.14.3',

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
}

0 commit comments

Comments
 (0)