-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsl_getAutoScaleGroup.py
More file actions
61 lines (49 loc) · 1.28 KB
/
sl_getAutoScaleGroup.py
File metadata and controls
61 lines (49 loc) · 1.28 KB
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
58
59
60
61
#!/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
_maskAutoScaleGroup = '''
virtualGuestMemberCount
'''
client = SoftLayer.Client(username=SL_USERNAME, api_key=SL_API_KEY)
autoScaleGroups = client['Account'].getScaleGroups(mask=_maskAutoScaleGroup)
_tableHeader = [
'id',
'asg name',
'dc',
'status',
'min',
'max',
'now',
'member prefix',
'members',
]
# Table definition
table = PrettyTable(_tableHeader)
table.padding_width = 1
for asg in autoScaleGroups:
m = ""
ms = ""
for a in asg['virtualGuestMembers'][0:]:
# m = str(a['virtualGuest']['id']) + ":" + a['virtualGuest']['hostname'][-4:]
m = a['virtualGuest']['hostname'][-4:]
ms = m + ' ' + ms
table.add_row(
[
asg['id'],
asg['name'],
asg['virtualGuestMemberTemplate']['datacenter']['name'],
asg['status']['keyName'],
asg['minimumMemberCount'],
asg['maximumMemberCount'],
asg['virtualGuestMemberCount'],
asg['virtualGuestMemberTemplate']['hostname'],
ms,
]
)
print(table)
exit()