Skip to content

Commit 6926f5e

Browse files
author
Elias Nygren
authored
Merge pull request #29 from UpCloudLtd/0.4-release
0.4 release
2 parents 12f6742 + 9fe4545 commit 6926f5e

29 files changed

+451
-453
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ servers = manager.get_servers()
191191
server1 = manager.get_server(UUID) # e.g servers[0].uuid
192192
storages = manager.get_storages()
193193
storage1 = manager.get_storage(UUID) # e.g sever1.storage_devices[0].uuid
194-
ip_addrs = manager.get_IPs()
195-
ip_addr = manager.get_IP(address) # e.g server1.ip_addresses[0].address
194+
ip_addrs = manager.get_ips()
195+
ip_addr = manager.get_ip(address) # e.g server1.ip_addresses[0].address
196196

197197
```
198198

docs/IP-address-mixin.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,38 @@ manager.method()
1919

2020

2121
```python
22-
def get_IP(self, address):
22+
def get_ip(self, address):
2323
"""
24-
Get an IP_address object with the IP address (string) from the API.
25-
e.g manager.get_IP("80.69.175.210")
24+
Get an IPAddress object with the IP address (string) from the API.
25+
e.g manager.get_ip("80.69.175.210")
2626
"""
2727
```
2828

2929
```python
30-
def get_IPs(self):
30+
def get_ips(self):
3131
"""
32-
Get all IP_address objects from the API.
32+
Get all IPAddress objects from the API.
3333
"""
3434
```
3535

3636
```python
37-
def attach_IP(self, server, family="IPv4"):
37+
def attach_ip(self, server, family="IPv4"):
3838
"""
39-
Attach a new (random) IP_address to the given server (object or UUID)
39+
Attach a new (random) IPAddress to the given server (object or UUID)
4040
"""
4141
```
4242
```python
43-
def modify_IP(self, IP_addr, ptr_record):
43+
def modify_ip(self, ip_addr, ptr_record):
4444
"""
4545
Modify an IP address' ptr-record (Reverse DNS).
46-
Accepts an IP_address instance (object) or its address (string).
46+
Accepts an IPAddress instance (object) or its address (string).
4747
"""
4848
```
4949

5050
```python
51-
def release_IP(self, IP_addr):
51+
def release_ip(self, ip_addr):
5252
"""
53-
Destroy an IP_address. Returns an empty object.
54-
Accepts an IP_address instance (object) or its address (string).
53+
Destroy an IPAddress. Returns an empty object.
54+
Accepts an IPAddress instance (object) or its address (string).
5555
"""
5656
```

docs/IP-address.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ CloudManager returns IP-address objects.
2121

2222
```python
2323

24-
manager.get_IPs()
25-
manager.get_IP("185.20.31.125")
24+
manager.get_ips()
25+
manager.get_ip("185.20.31.125")
2626

2727
```
2828

@@ -33,19 +33,19 @@ The new IP-address must be attached to a server and has a random address.
3333
```python
3434

3535
# params: server uuid or a Server object and family, for which default is IPv4
36-
manager.attach_IP(server_uuid)
37-
manager.attach_IP(server_uuid, "IPv4")
38-
manager.attach_IP(server_uuid, "IPv6")
39-
manager.attach_IP(Server)
40-
manager.attach_IP(Server, "IPv4")
41-
manager.attach_IP(Server, "IPv6")
36+
manager.attach_ip(server_uuid)
37+
manager.attach_ip(server_uuid, "IPv4")
38+
manager.attach_ip(server_uuid, "IPv6")
39+
manager.attach_ip(Server)
40+
manager.attach_ip(Server, "IPv4")
41+
manager.attach_ip(Server, "IPv6")
4242

4343

4444
# or use Server instance
4545
server = manager.get_server(uuid)
46-
server.add_IP() # default is IPv4
47-
server.add_IP("IPv4")
48-
server.add_IP("IPv6")
46+
server.add_ip() # default is IPv4
47+
server.add_ip("IPv4")
48+
server.add_ip("IPv6")
4949

5050
```
5151

@@ -55,7 +55,7 @@ At the moment only the ptr_record (reverse DNS) of an IP can be changed.
5555

5656
```python
5757

58-
ip = manager.get_IP("185.20.31.125")
58+
ip = manager.get_ip("185.20.31.125")
5959
ip.ptr_record = "the.new.ptr.record"
6060
ip.save()
6161

@@ -65,7 +65,7 @@ ip.save()
6565

6666
```python
6767

68-
ip = manager.get_IP("185.20.31.125")
68+
ip = manager.get_ip("185.20.31.125")
6969
ip.destroy()
7070

7171
```

docs/Server.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ server.remove_storage(storage)
121121

122122
### IP-addresses
123123

124-
A Server's Storages can be attached and detached with `.add_IP()` and `.remove_IP()`. Both requests issue an API request instantly. Note that the attached IP is allocated randomly as UpCloud's does not (yet) support floating IPs.
124+
A Server's Storages can be attached and detached with `.add_ip()` and `.remove_ip()`. Both requests issue an API request instantly. Note that the attached IP is allocated randomly as UpCloud's does not (yet) support floating IPs.
125125

126126
```python
127127

128128
# attach
129-
IP = server.add_IP()
129+
IP = server.add_ip()
130130

131131
# detach
132-
server.remove_IP(IP)
132+
server.remove_ip(IP)
133133

134134
```
135135

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.8',
7+
version='0.4.0',
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.8',
15+
download='https://github.com/UpCloudLtd/upcloud-python-api/tarball/v0.4.0',
1616
license='MIT',
1717
install_requires=[
1818
'requests>=2.6.0',

test/helpers/infra_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def server_test(manager, server):
5050
server.memory_amount = '1024'
5151
server.save()
5252

53-
server.add_IP()
53+
server.add_ip()
5454

5555
storage = manager.create_storage(size=10, tier='maxiops', zone=ZONE.London)
5656
server.add_storage(storage)

test/test_ip_manager.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,48 @@ class TestIP(object):
1010
@responses.activate
1111
def test_get_ip(self, manager):
1212
data = Mock.mock_get('ip_address/10.1.0.101')
13-
ip_addr = manager.get_IP('10.1.0.101')
13+
ip_addr = manager.get_ip('10.1.0.101')
1414

15-
assert type(ip_addr).__name__ == 'IP_address'
15+
assert type(ip_addr).__name__ == 'IPAddress'
1616
assert ip_addr.address == '10.1.0.101'
17-
assert ip_addr.ptr == 'a.ptr.record'
17+
assert ip_addr.ptr_record == 'a.ptr.record'
1818

1919
@responses.activate
2020
def test_get_ips(self, manager):
2121
data = Mock.mock_get('ip_address')
22-
ip_addrs = manager.get_IPs()
22+
ip_addrs = manager.get_ips()
2323

2424
for ip_addr in ip_addrs:
25-
assert type(ip_addr).__name__ == 'IP_address'
25+
assert type(ip_addr).__name__ == 'IPAddress'
2626

2727
@responses.activate
2828
def test_modify_ip_oop(self, manager):
2929
# get ip
3030
data = Mock.mock_get('ip_address/10.1.0.101')
31-
ip_addr = manager.get_IP('10.1.0.101')
31+
ip_addr = manager.get_ip('10.1.0.101')
3232

3333
# put ip
3434
data = Mock.mock_put('ip_address/10.1.0.101')
35-
ip_addr.ptr = 'my.ptr.record'
35+
ip_addr.ptr_record = 'my.ptr.record'
3636
ip_addr.save()
3737

38-
assert ip_addr.ptr == 'my.ptr.record'
38+
assert ip_addr.ptr_record == 'my.ptr.record'
3939

4040
@responses.activate
4141
def test_modify_ip(self, manager):
4242
data = Mock.mock_put('ip_address/10.1.0.101')
43-
ip_addr = manager.modify_IP('10.1.0.101', ptr_record='my.ptr.record')
43+
ip_addr = manager.modify_ip('10.1.0.101', ptr_record='my.ptr.record')
4444

45-
assert ip_addr.ptr == 'my.ptr.record'
45+
assert ip_addr.ptr_record == 'my.ptr.record'
4646

4747
@responses.activate
4848
def test_modify_ip(self, manager):
4949
data = Mock.mock_put('ip_address/10.1.0.101')
50-
ip_addr = manager.modify_IP('10.1.0.101', ptr_record='my.ptr.record')
51-
assert ip_addr.ptr == 'my.ptr.record'
50+
ip_addr = manager.modify_ip('10.1.0.101', ptr_record='my.ptr.record')
51+
assert ip_addr.ptr_record == 'my.ptr.record'
5252

5353
@responses.activate
5454
def test_ip_delete(self, manager):
5555
Mock.mock_delete('ip_address/10.1.0.101')
56-
res = manager.release_IP('10.1.0.101')
56+
res = manager.release_ip('10.1.0.101')
5757
assert res == {}

test/test_server.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ def test_restart_server(self, manager):
7171
assert server.state == 'maintenance'
7272

7373
@responses.activate
74-
def test_attach_and_detach_IP(self, manager):
74+
def test_attach_and_detach_ip(self, manager):
7575
data = Mock.mock_get('server/00798b85-efdc-41ca-8021-f6ef457b8531')
7676
server = manager.get_server('00798b85-efdc-41ca-8021-f6ef457b8531')
7777
assert len(server.ip_addresses) == 2
7878

7979
data = Mock.mock_post('ip_address')
80-
server.add_IP()
80+
server.add_ip()
8181
assert len(server.ip_addresses) == 3
8282

8383
Mock.mock_delete('ip_address/'+server.ip_addresses[2].address)
84-
server.remove_IP(server.ip_addresses[2])
84+
server.remove_ip(server.ip_addresses[2])
8585
assert len(server.ip_addresses) == 2
8686

8787
@responses.activate
@@ -114,7 +114,6 @@ def test_attach_and_detach_storage(self, manager):
114114
status = 200,
115115
content_type='application/json'
116116
)
117-
118117
server.remove_storage(server.storage_devices[1])
119118

120119
assert len(server.storage_devices) == 1

test/test_server_creation.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,22 @@ class TestCreateServer(object):
1515

1616
def test_storage_prepare_post_body(self, manager):
1717
s1 = Storage(os='Ubuntu 14.04', size=10)
18-
body1 = s1.prepare_post_body('my.example.com', 1)
19-
20-
assert body1['title'] == 'my.example.com OS disk'
18+
body1 = s1.to_dict()
2119
assert body1['tier'] == 'maxiops'
2220
assert body1['size'] == 10
23-
assert body1['storage'] == '01000000-0000-4000-8000-000030040200'
24-
assert body1['action'] == 'clone'
2521

2622
s2 = Storage(size=100)
27-
body2 = s2.prepare_post_body('my.example.com', 1)
28-
29-
assert body2['title'] == 'my.example.com storage disk 1'
23+
body2 = s2.to_dict()
3024
assert body2['tier'] == 'maxiops'
31-
assert body2['action'] == 'create'
3225
assert body2['size'] == 100
3326

3427
def test_storage_prepare_post_body_optional_attributes(self, manager):
35-
s2 = Storage(size=100, address='virtio:0', type='disk')
36-
body2 = s2.prepare_post_body('my.example.com', 1)
28+
s2 = Storage(size=100, address='virtio:0')
29+
body2 = s2.to_dict()
3730

38-
assert body2['title'] == 'my.example.com storage disk 1'
3931
assert body2['tier'] == 'maxiops'
40-
assert body2['action'] == 'create'
4132
assert body2['size'] == 100
4233
assert body2['address'] == 'virtio:0'
43-
assert body2['type'] == 'disk'
4434

4535
def test_server_init(self, manager):
4636
server1 = Server(
@@ -159,7 +149,7 @@ def test_create_server(self, manager):
159149

160150
# assert ips and storages have correct types
161151
assert type(server1.storage_devices[0]).__name__ == 'Storage'
162-
assert type(server1.ip_addresses[0]).__name__ == 'IP_address'
152+
assert type(server1.ip_addresses[0]).__name__ == 'IPAddress'
163153

164154
# assert new data was populated
165155
assert server1.video_model == 'cirrus'
@@ -196,7 +186,7 @@ def test_create_server_with_dict(self, manager):
196186

197187
# assert ips and storages have correct types
198188
assert type(server1.storage_devices[0]).__name__ == 'Storage'
199-
assert type(server1.ip_addresses[0]).__name__ == 'IP_address'
189+
assert type(server1.ip_addresses[0]).__name__ == 'IPAddress'
200190

201191
# assert new data was populated
202192
assert server1.video_model == 'cirrus'

test/test_storage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def test_storage_update_oop(self, manager):
4949
storage = manager.get_storage("01d4fcd4-e446-433b-8a9c-551a1284952e")
5050

5151
Mock.mock_put("storage/01d4fcd4-e446-433b-8a9c-551a1284952e")
52-
storage.update(title="my bigger data collection", size=15)
52+
storage.title = "my bigger data collection"
53+
storage.size = 15
54+
storage.save()
5355
assert storage.title == "my bigger data collection"
5456
assert storage.size == 15
5557

0 commit comments

Comments
 (0)