forked from szepeviktor/debian-server-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upcloud_create_server.py
executable file
·36 lines (30 loc) · 1011 Bytes
/
upcloud_create_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
#
# Create a new instance at UpCloud.
#
# pip3 install --user upcloud-api
# chmod 600 upcloud_create_server.py
import upcloud_api
from upcloud_api import Server, Storage, ZONE, login_user_block
# EDIT
manager = upcloud_api.CloudManager('USERNAME', 'PASSWORD')
user_viktor = login_user_block(
username='root',
ssh_keys=['ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJnaM2JLvO4DWkmmSXys+jn0KhTRVkCfAAhv/1Pszs0DJTheQgOR9e3ThNCgR7CxIqZ5kXrZ+BIDtDs5IGrg9IA= szv-ecdsa'],
create_password=False
)
new_server_config = Server(
hostname='upcloud.keszul.tk',
zone=ZONE.Frankfurt,
plan='2xCPU-2GB',
storage_devices=[
Storage(os='Debian 8.0', size=50)
],
login_user=user_viktor,
# Docker + pip
user_data='https://github.com/szepeviktor/debian-server-tools/raw/master/upcloud-init.sh'
)
manager.authenticate()
new_server = manager.create_server(new_server_config)
# Print IP
print(new_server.get_public_ip() + '\n')