-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresize_cserver.py
More file actions
executable file
·41 lines (31 loc) · 883 Bytes
/
resize_cserver.py
File metadata and controls
executable file
·41 lines (31 loc) · 883 Bytes
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
37
38
39
40
41
#!/usr/bin/python
import cloudservers
import ConfigParser
# get our config from the config file
config = ConfigParser.ConfigParser()
config.read("./cf.ini")
USERNAME = config.get("auth", "username")
AUTH_URL = config.get("auth", "url")
API_KEY = config.get("auth", "key")
# Server ID to resize
SERVER = '10003688'
FLAVOR = '2'
# create connection object
cnx = cloudservers.CloudServers(USERNAME, API_KEY, auth_url=AUTH_URL)
# get a list of servers on the account
servers = cnx.servers.list()
for server in servers:
print server
# get a list of available flavors
flavors = cnx.flavors.list()
for flavor in flavors:
print flavor
# get a list of server IDs
for server in servers:
print server.id
# get a list of flavor IDs
for flavor in flavors:
print flavor.id
# resize specified server
cnx.servers.resize(SERVER, FLAVOR)
cnx.servers.confirm_resize(SERVER)