Skip to content

Commit feb8f9a

Browse files
autoscale details mostly done
1 parent 6f60c7c commit feb8f9a

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

SoftLayer/CLI/autoscale/detail.py

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def cli(env, identifier):
2323
group = autoscale.details(identifier)
2424
# print(groups)
2525
# pp(group)
26-
table = formatting.KeyValueTable(["Name", "Value"])
26+
27+
# Group Config Table
28+
table = formatting.KeyValueTable(["Group", "Value"])
2729

2830
table.add_row(['Id', group.get('id')])
2931
# Ideally we would use regionalGroup->preferredDatacenter, but that generates an error.
@@ -32,6 +34,7 @@ def cli(env, identifier):
3234
table.add_row(['Minimum Members', group.get('minimumMemberCount')])
3335
table.add_row(['Maximum Members', group.get('maximumMemberCount')])
3436
table.add_row(['Current Members', group.get('virtualGuestMemberCount')])
37+
table.add_row(['Cooldown', "{} seconds".format(group.get('cooldown'))])
3538
table.add_row(['Last Action', utils.clean_time(group.get('lastActionDate'))])
3639

3740
for network in group.get('networkVlans'):
@@ -41,7 +44,62 @@ def cli(env, identifier):
4144
vlan_name = "{}.{}".format(router, vlan_number)
4245
table.add_row([network_type, vlan_name])
4346

47+
env.fout(table)
4448

4549

50+
# Template Config Table
51+
config_table = formatting.KeyValueTable(["Template", "Value"])
52+
template = group.get('virtualGuestMemberTemplate')
53+
54+
config_table.add_row(['Hostname', template.get('hostname')])
55+
config_table.add_row(['Domain', template.get('domain')])
56+
config_table.add_row(['Core', template.get('startCpus')])
57+
config_table.add_row(['Ram', template.get('maxMemory')])
58+
network = template.get('networkComponents')
59+
config_table.add_row(['Network', network[0]['maxSpeed']])
60+
ssh_keys = template.get('sshKeys', [])
61+
ssh_manager = SoftLayer.SshKeyManager(env.client)
62+
for key in ssh_keys:
63+
# Label isn't included when retrieved from the AutoScale group...
64+
ssh_key = ssh_manager.get_key(key.get('id'))
65+
config_table.add_row(['SSH Key {}'.format(ssh_key.get('id')), ssh_key.get('label')])
66+
disks = template.get('blockDevices')
67+
disk_type = "SAN"
68+
if template.get('localDiskFlag'):
69+
disk_type = "Local"
70+
for disk in disks:
71+
disk_image = disk.get('diskImage')
72+
config_table.add_row(['{} Disk {}'.format(disk_type, disk.get('device')), disk_image.get('capacity')])
73+
config_table.add_row(['OS', template.get('operatingSystemReferenceCode')])
74+
config_table.add_row(['Post Install', template.get('postInstallScriptUri') or 'None'])
4675

47-
env.fout(table)
76+
env.fout(config_table)
77+
78+
79+
# Policy Config Table
80+
policy_table = formatting.KeyValueTable(["Policy", "Cooldown"])
81+
policies = group.get('policies')
82+
# pp(policies)
83+
for policy in policies:
84+
policy_table.add_row([policy.get('name'), policy.get('cooldown') or group.get('cooldown')])
85+
# full_policy = autoscale.get_policy(policy.get('id'))
86+
# pp(full_policy)
87+
88+
env.fout(policy_table)
89+
90+
# LB Config Table
91+
# Not sure if this still still a thing?
92+
# lb_table = formatting.KeyValueTable(["Load Balancer", "Value"])
93+
# loadbal = group.get('loadBalancers')
94+
95+
# env.fout(lb_table)
96+
97+
# Active Guests
98+
member_table = formatting.Table(['Id', 'Hostname', 'Created'], title="Active Guests")
99+
guests = group.get('virtualGuestMembers')
100+
for guest in guests:
101+
real_guest = guest.get('virtualGuest')
102+
member_table.add_row([
103+
guest.get('id'), real_guest.get('hostname'), utils.clean_time(real_guest.get('provisionDate'))
104+
])
105+
env.fout(member_table)

SoftLayer/managers/autoscale.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ def list(self, mask=None):
2222

2323
def details(self, identifier, mask=None):
2424
if not mask:
25-
mask = """mask[virtualGuestMembers, terminationPolicy, policies, virtualGuestMemberCount,
25+
mask = """mask[virtualGuestMembers[id,virtualGuest[hostname,domain,provisionDate]], terminationPolicy,
26+
virtualGuestMemberCount, virtualGuestMemberTemplate[sshKeys],
27+
policies[id,name,createDate,cooldown,actions,triggers,scaleActions],
2628
networkVlans[networkVlanId,networkVlan[networkSpace,primaryRouter[hostname]]],
2729
loadBalancers, regionalGroup[locations]]"""
28-
return self.client.call('SoftLayer_Scale_Group', 'getObject', id=identifier, mask=mask)
30+
return self.client.call('SoftLayer_Scale_Group', 'getObject', id=identifier, mask=mask)
31+
32+
def get_policy(self, identifier, mask=None):
33+
if not mask:
34+
mask = """mask[cooldown, createDate, id, name, actions, triggers[type]
35+
36+
]"""
37+
38+
return self.client.call('SoftLayer_Scale_Policy', 'getObject', id=identifier, mask=mask)

0 commit comments

Comments
 (0)