aboutsummaryrefslogtreecommitdiff
path: root/python/list_servers.py
blob: e7bd2af9a27ed5c5a205dc60678a77bffd30da10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
try:
    from ovh import ovh
except ImportError:
    # In case it's installed globally
    import ovh

client = ovh.Client()

print("OVH cloud instances:")
projects_list = client.get('/cloud/project/')
for project_id in projects_list:
    project = client.get('/cloud/project/{}'.format(project_id))
    print("\t{}:".format(project["description"]))
    instances_list = client.get('/cloud/project/{}/instance'.format(project_id))
    for instance in instances_list:
        print("\t\t{}: {}".format(instance["name"], instance["id"]))

vps_list = client.get('/vps/')

print("OVH VPS SSD servers:")
for vps in vps_list:
    print("\t{}".format(vps))