Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6ccdcbd
removed legacy LB commands, added LBaaS and Netscaler support
allmightyspiff Jul 10, 2019
c68eafa
#1047 manage health checks
allmightyspiff Jul 11, 2019
1b907bf
lbaas member-add and member-del commands
allmightyspiff Jul 15, 2019
feab68d
LB pool management commands
allmightyspiff Jul 17, 2019
6132b58
work around l7 pools
allmightyspiff Jul 18, 2019
f378a8e
loadbalancer order options command
allmightyspiff Jul 29, 2019
c3f3638
lb ordering done
allmightyspiff Jul 31, 2019
9322d60
cancel lb support
allmightyspiff Aug 1, 2019
fe403e1
tox style fixes
allmightyspiff Aug 5, 2019
c9bb5f0
unit tests for lb-manager
allmightyspiff Aug 15, 2019
bbac83a
#1158 lb manager unit tests
allmightyspiff Aug 19, 2019
2249724
#1158 tox style fixes
allmightyspiff Aug 19, 2019
4219b23
unit test lodabalancer List.py, pool.py
Aug 23, 2019
171d15a
Fix error H306
Aug 26, 2019
439b07e
add fixture load balancer listener and L7pool
Aug 26, 2019
8d48042
added try-except blocks
ATGE Aug 26, 2019
3db7f93
added required datatypes
ATGE Aug 26, 2019
96753cd
added health, detail, members test
ATGE Aug 26, 2019
0366651
Merge pull request #1164 from ATGE/loadbalancers
allmightyspiff Aug 26, 2019
1dbff5b
Merge branch 'loadbalancers' into loadbalancers
allmightyspiff Aug 26, 2019
584a142
fixed merge conflict error.
allmightyspiff Aug 26, 2019
61f16b7
Merge pull request #1163 from caberos/loadbalancers
allmightyspiff Aug 26, 2019
6df3787
Unit test for loadbal order, ns-list, ns-detail.
Aug 28, 2019
de382b3
Fix file analysis.
Aug 28, 2019
745ec85
Fix file analysis.
Aug 28, 2019
8448ccd
#1158 added LB docs
allmightyspiff Aug 28, 2019
8dfee70
Merge pull request #1165 from FernandoOjeda/fo_loadbal_unit_test
allmightyspiff Aug 28, 2019
614e653
Merge branch 'loadbalancers' of github.com:softlayer/softlayer-python…
allmightyspiff Aug 28, 2019
b29a24a
Merge pull request #1166 from allmightyspiff/loadbalancers
allmightyspiff Aug 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions SoftLayer/CLI/loadbal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
"""Load balancers."""

from SoftLayer.CLI import exceptions


def parse_id(input_id):
"""Parse the load balancer kind and actual id from the "kind:id" form."""
parts = input_id.split(':')
if len(parts) != 2:
raise exceptions.CLIAbort(
'Invalid ID %s: ID should be of the form "kind:id"' % input_id)
return parts[0], int(parts[1])
29 changes: 0 additions & 29 deletions SoftLayer/CLI/loadbal/cancel.py

This file was deleted.

25 changes: 0 additions & 25 deletions SoftLayer/CLI/loadbal/create.py

This file was deleted.

35 changes: 0 additions & 35 deletions SoftLayer/CLI/loadbal/create_options.py

This file was deleted.

157 changes: 100 additions & 57 deletions SoftLayer/CLI/loadbal/detail.py
Original file line number Diff line number Diff line change
@@ -1,81 +1,124 @@
"""Get Load balancer details."""
# :license: MIT, see LICENSE for more details.

"""Get Load Balancer as a Service details."""
import click

import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.CLI import loadbal
from SoftLayer import utils


@click.command()
@click.argument('identifier')
@environment.pass_env
def cli(env, identifier):
"""Get Load balancer details."""
"""Get Load Balancer as a Service details."""
mgr = SoftLayer.LoadBalancerManager(env.client)
_, lbid = mgr.get_lbaas_uuid_id(identifier)
this_lb = mgr.get_lb(lbid)
if this_lb.get('previousErrorText'):
print(this_lb.get('previousErrorText'))
table = lbaas_table(this_lb)

_, loadbal_id = loadbal.parse_id(identifier)
env.fout(table)

load_balancer = mgr.get_local_lb(loadbal_id)

def lbaas_table(this_lb):
"""Generates a table from a list of LBaaS devices"""
table = formatting.KeyValueTable(['name', 'value'])
table.align['name'] = 'l'
table.align['name'] = 'r'
table.align['value'] = 'l'
table.add_row(['ID', 'local:%s' % load_balancer['id']])
table.add_row(['IP Address', load_balancer['ipAddress']['ipAddress']])
name = load_balancer['loadBalancerHardware'][0]['datacenter']['name']
table.add_row(['Datacenter', name])
table.add_row(['Connections limit', load_balancer['connectionLimit']])
table.add_row(['Dedicated', load_balancer['dedicatedFlag']])
table.add_row(['HA', load_balancer['highAvailabilityFlag']])
table.add_row(['SSL Enabled', load_balancer['sslEnabledFlag']])
table.add_row(['SSL Active', load_balancer['sslActiveFlag']])
table.add_row(['Id', this_lb.get('id')])
table.add_row(['UUI', this_lb.get('uuid')])
table.add_row(['Address', this_lb.get('address')])
table.add_row(['Location', utils.lookup(this_lb, 'datacenter', 'longName')])
table.add_row(['Description', this_lb.get('description')])
table.add_row(['Name', this_lb.get('name')])
table.add_row(['Status', "{} / {}".format(this_lb.get('provisioningStatus'), this_lb.get('operatingStatus'))])

index0 = 1
for virtual_server in load_balancer['virtualServers']:
for group in virtual_server['serviceGroups']:
service_group_table = formatting.KeyValueTable(['name', 'value'])
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_HealthMonitor/
hp_table = formatting.Table(['UUID', 'Interval', 'Retries', 'Type', 'Timeout', 'Modify', 'Active'])
for health in this_lb.get('healthMonitors', []):
hp_table.add_row([
health.get('uuid'),
health.get('interval'),
health.get('maxRetries'),
health.get('monitorType'),
health.get('timeout'),
utils.clean_time(health.get('modifyDate')),
health.get('provisioningStatus')
])
table.add_row(['Checks', hp_table])

table.add_row(['Service Group %s' % index0, service_group_table])
index0 += 1
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_L7Pool/
l7_table = formatting.Table(['Id', 'UUID', 'Balancer', 'Name', 'Protocol', 'Modify', 'Active'])
for layer7 in this_lb.get('l7Pools', []):
l7_table.add_row([
layer7.get('id'),
layer7.get('uuid'),
layer7.get('loadBalancingAlgorithm'),
layer7.get('name'),
layer7.get('protocol'),
utils.clean_time(layer7.get('modifyDate')),
layer7.get('provisioningStatus')
])
table.add_row(['L7 Pools', l7_table])

service_group_table.add_row(['Guest ID',
virtual_server['id']])
service_group_table.add_row(['Port', virtual_server['port']])
service_group_table.add_row(['Allocation',
'%s %%' %
virtual_server['allocation']])
service_group_table.add_row(['Routing Type',
'%s:%s' %
(group['routingTypeId'],
group['routingType']['name'])])
service_group_table.add_row(['Routing Method',
'%s:%s' %
(group['routingMethodId'],
group['routingMethod']['name'])])
pools = {}
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Listener/
listener_table = formatting.Table(['UUID', 'Max Connection', 'Mapping', 'Balancer', 'Modify', 'Active'])
for listener in this_lb.get('listeners', []):
pool = listener.get('defaultPool')
priv_map = "{}:{}".format(pool['protocol'], pool['protocolPort'])
pools[pool['uuid']] = priv_map
mapping = "{}:{} -> {}".format(listener.get('protocol'), listener.get('protocolPort'), priv_map)
listener_table.add_row([
listener.get('uuid'),
listener.get('connectionLimit', 'None'),
mapping,
pool.get('loadBalancingAlgorithm', 'None'),
utils.clean_time(listener.get('modifyDate')),
listener.get('provisioningStatus')
])
table.add_row(['Pools', listener_table])

index1 = 1
for service in group['services']:
service_table = formatting.KeyValueTable(['name', 'value'])
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Member/
member_col = ['UUID', 'Address', 'Weight', 'Modify', 'Active']
for uuid in pools:
member_col.append(pools[uuid])
member_table = formatting.Table(member_col)
for member in this_lb.get('members', []):
row = [
member.get('uuid'),
member.get('address'),
member.get('weight'),
utils.clean_time(member.get('modifyDate')),
member.get('provisioningStatus')
]
for uuid in pools:
row.append(get_member_hp(this_lb.get('health'), member.get('uuid'), uuid))
member_table.add_row(row)
table.add_row(['Members', member_table])

service_group_table.add_row(['Service %s' % index1,
service_table])
index1 += 1
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_SSLCipher/
ssl_table = formatting.Table(['Id', 'Name'])
for ssl in this_lb.get('sslCiphers', []):
ssl_table.add_row([ssl.get('id'), ssl.get('name')])
table.add_row(['Ciphers', ssl_table])
return table

health_check = service['healthChecks'][0]
service_table.add_row(['Service ID', service['id']])
service_table.add_row(['IP Address',
service['ipAddress']['ipAddress']])
service_table.add_row(['Port', service['port']])
service_table.add_row(['Health Check',
'%s:%s' %
(health_check['healthCheckTypeId'],
health_check['type']['name'])])
service_table.add_row(
['Weight', service['groupReferences'][0]['weight']])
service_table.add_row(['Enabled', service['enabled']])
service_table.add_row(['Status', service['status']])

env.fout(table)
def get_member_hp(checks, member_uuid, pool_uuid):
"""Helper function to find a members health in a given pool

:param checks list: https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Pool/#healthMonitor
:param member_uuid: server UUID we are looking for
:param pool_uuid: Connection pool uuid to search for
"""
status = "---"
for check in checks:
if check.get('poolUuid') == pool_uuid:
for hp_member in check.get('membersHealth'):
if hp_member.get('uuid') == member_uuid:
status = hp_member.get('status')

return status
41 changes: 0 additions & 41 deletions SoftLayer/CLI/loadbal/group_add.py

This file was deleted.

28 changes: 0 additions & 28 deletions SoftLayer/CLI/loadbal/group_delete.py

This file was deleted.

Loading