@@ -12,7 +12,7 @@ pip install --pre upcloud-api-python
1212pip install upcloud-api-python
1313```
1414
15- Alternatively, clone the project and run
15+ Alternatively, clone the project and run
1616```
1717python setup.py install
1818```
@@ -38,7 +38,7 @@ python setup.py install
3838
3939## Examples
4040
41- Note that operations are not instant, for example a server is not fully shut down when the API responds.
41+ Note that operations are not instant, for example a server is not fully shut down when the API responds.
4242You must take this into account in your automations.
4343
4444### Defining and creating Servers
@@ -53,38 +53,38 @@ manager.authenticate() # test credentials
5353cluster = {
5454 " web1" : Server( core_number = 1 , # CPU cores
5555 memory_amount = 512 , # RAM in MB
56- hostname = " web1.example.com" ,
56+ hostname = " web1.example.com" ,
5757 zone = ZONE .London, # ZONE.Helsinki and ZONE.Chicago available also
5858 storage_devices = [
5959 # OS: Ubuntu 14.04 from template
6060 # default tier: maxIOPS, the 100k IOPS storage backend
61- Storage(os = " Ubuntu 14.04" , size = 10 ),
61+ Storage(os = " Ubuntu 14.04" , size = 10 ),
6262 # secondary storage, hdd for reduced cost
63- Storage(size = 100 , tier = " hdd" )
63+ Storage(size = 100 , tier = " hdd" )
6464 ]),
65-
66- " web2" : Server( core_number = 1 ,
67- memory_amount = 512 ,
68- hostname = " web2.example.com" ,
69- zone = ZONE .London,
65+
66+ " web2" : Server( core_number = 1 ,
67+ memory_amount = 512 ,
68+ hostname = " web2.example.com" ,
69+ zone = ZONE .London,
7070 storage_devices = [
71- Storage(os = " Ubuntu 14.04" , size = 10 ),
71+ Storage(os = " Ubuntu 14.04" , size = 10 ),
7272 Storage(size = 100 , tier = " hdd" ),
7373 ]),
7474
75- " db" : Server( core_number = 2 ,
76- memory_amount = 2048 ,
77- hostname = " db.example.com" ,
78- zone = ZONE .London,
75+ " db" : Server( core_number = 2 ,
76+ memory_amount = 2048 ,
77+ hostname = " db.example.com" ,
78+ zone = ZONE .London,
7979 storage_devices = [
8080 Storage(os = " Ubuntu 14.04" , size = 10 ),
8181 Storage(size = 100 ),
8282 ]),
8383
84- " lb" : Server( core_number = 2 ,
85- memory_amount = 1024 ,
86- hostname = " balancer.example.com" ,
87- zone = ZONE .London,
84+ " lb" : Server( core_number = 2 ,
85+ memory_amount = 1024 ,
86+ hostname = " balancer.example.com" ,
87+ zone = ZONE .London,
8888 storage_devices = [
8989 Storage(os = " Ubuntu 14.04" , size = 10 )
9090 ])
@@ -100,13 +100,13 @@ for server in cluster:
100100
101101for server in cluster:
102102 server.shutdown()
103- # OR:
103+ # OR:
104104 server.start()
105- # OR:
105+ # OR:
106106 server.destroy()
107- for storage in server.storage_devices:
107+ for storage in server.storage_devices:
108108 storage.destroy()
109-
109+
110110```
111111
112112### Upgrade a Server
@@ -135,6 +135,23 @@ ip_addr = manager.get_IP(address) # e.g server1.ip_addresses[0].address
135135
136136## Tests
137137
138+ Set up environment and install dependencies:
139+
140+ ```
141+ # run at project root, python3 and virtualenv must be installed
142+ virtualenv ENV
143+ source ENV/bin/activate
144+ pip install -r requirements
145+ ```
146+
147+ Install the package in editable mode, as mentioned in
148+ [ https://pytest.org/latest/goodpractises.html ] ( https://pytest.org/latest/goodpractises.html )
149+
150+ ``` python
151+ # run at project root
152+ pip install - e .
153+ ```
154+
138155Tests located in ` project_root/tests/ ` directory. Run with:
139156
140157``` python
0 commit comments