-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsl_getLocation.py
More file actions
58 lines (43 loc) · 976 Bytes
/
sl_getLocation.py
File metadata and controls
58 lines (43 loc) · 976 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'takechika'
from prettytable import PrettyTable
import SoftLayer
import sluser
SL_USERNAME = sluser.SL_USERNAME
SL_API_KEY = sluser.SL_API_KEY
_mask = '''
id,
fullyQualifiedDomainName,
datacenter,
location.pathString
'''
_TableHeader = [
'VM ID',
'FQDN',
'Datacenter',
'Location'
]
client = SoftLayer.Client(username=SL_USERNAME, api_key=SL_API_KEY)
virtualGuests = client['Account'].getVirtualGuests(mask=_mask)
# Table definition
table = PrettyTable(_TableHeader)
table.padding_width = 1
# Get list
count = 0
#for vg in sorted(virtualGuests):
for vg in virtualGuests:
# print(vg)
table.add_row(
[
vg['id'],
vg['fullyQualifiedDomainName'],
vg['datacenter']['longName'],
vg['location']['pathString']
]
)
count = count + 1
print(table)
print(count, "VMs")
print(virtualGuests)
exit()