Skip to content

Commit 3da9a3e

Browse files
author
Elias Nygren
committed
add sublime project file, better test/dev info to README.md
1 parent 4e31423 commit 3da9a3e

3 files changed

Lines changed: 70 additions & 23 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ UpCloud.egg-info/
66
build/
77
dist/
88
*.egg-info
9+
*.sublime-workspace

README.md

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pip install --pre upcloud-api-python
1212
pip install upcloud-api-python
1313
```
1414

15-
Alternatively, clone the project and run
15+
Alternatively, clone the project and run
1616
```
1717
python 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.
4242
You must take this into account in your automations.
4343

4444
### Defining and creating Servers
@@ -53,38 +53,38 @@ manager.authenticate() # test credentials
5353
cluster = {
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

101101
for 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+
138155
Tests located in `project_root/tests/` directory. Run with:
139156

140157
```python

upcloud-python-api.sublime-project

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": ".",
6+
"folder_exclude_patterns":
7+
[
8+
".git",
9+
"__pycache__",
10+
"ENV"
11+
],
12+
"file_exclude_patterns":
13+
[
14+
".DS_Store",
15+
"*.pid",
16+
"*.pyc"
17+
]
18+
}
19+
],
20+
"settings":
21+
{
22+
"tab_size": 4,
23+
"translate_tabs_to_spaces": true,
24+
"trim_trailing_white_space_on_save": true,
25+
"ensure_newline_at_eof_on_save": true,
26+
"rulers": [ 79, 99 ],
27+
"line_numbers": true
28+
}
29+
}

0 commit comments

Comments
 (0)