Skip to content

Commit 2a3c966

Browse files
author
Elias Nygren
committed
improve README example code style
1 parent 66b55b7 commit 2a3c966

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

README.md

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -71,54 +71,59 @@ You must take this into account in your automations.
7171
### Defining and creating Servers
7272

7373
```python
74+
7475
import upcloud_api
7576
from upcloud_api import Server, Storage, ZONE
7677

77-
manager = upcloud_api.CloudManager("api_user", "password")
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

0 commit comments

Comments
 (0)