Skip to content

Commit e8487b1

Browse files
caberoscaberos
authored andcommitted
fix the team code review comments
1 parent 3a2ed8f commit e8487b1

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

SoftLayer/CLI/loadbal/protocol_add.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def parse_proto(ctx, param, value):
2828
@click.option('--method', '-m', help="Balancing Method.", default='ROUNDROBIN', show_default=True,
2929
type=click.Choice(['ROUNDROBIN', 'LEASTCONNECTION', 'WEIGHTED_RR']))
3030
@click.option('--session', '-s', required=True,
31-
help="Session stickiness type. Valid values are SOURCE_IP” “HTTP_COOKIE")
32-
@click.option('--max', help="Use a Public to Public loadbalancer.")
31+
help="Session stickiness type. Valid values are SOURCE_IP or HTTP_COOKIE ")
32+
@click.option('--max', help="Max Connections setting", type=int)
3333
@environment.pass_env
3434
def cli(env, identifier, **args):
3535
"""Add a new load balancer protocol."""
3636

3737
mgr = SoftLayer.LoadBalancerManager(env.client)
3838

39-
uuid = mgr.get_lb(identifier)['uuid']
39+
uuid = mgr.get_lb_uuid(identifier)
4040

4141
backend = args.get('backend')
4242
frontend = args.get('frontend')
@@ -60,7 +60,7 @@ def cli(env, identifier, **args):
6060
table.add_row(['Id', protocol.get('id')])
6161
table.add_row(['UUI', protocol.get('uuid')])
6262
table.add_row(['Address', protocol.get('address')])
63-
table.add_row(['Type', SoftLayer.LoadBalancerManager.TYPE.get(protocol.get('type'))])
63+
table.add_row(['Type', mgr.get_lb_type(protocol.get('type'))])
6464
table.add_row(['Description', protocol.get('description')])
6565

6666
env.fout(table)

SoftLayer/CLI/loadbal/protocol_edit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def parse_proto(ctx, param, value):
2929
@click.option('--method', '-m', help="Balancing Method.", default='ROUNDROBIN', show_default=True,
3030
type=click.Choice(['ROUNDROBIN', 'LEASTCONNECTION', 'WEIGHTED_RR']))
3131
@click.option('--session', '-s', required=True,
32-
help="Session stickiness type. Valid values are SOURCE_IP” “HTTP_COOKIE")
33-
@click.option('--max', help="Use a Public to Public loadbalancer.")
32+
help="Session stickiness type. Valid values are SOURCE_IP or HTTP_COOKIE ")
33+
@click.option('--max', help="Max Connections setting", type=int)
3434
@environment.pass_env
3535
def cli(env, identifier, **args):
3636
"""Edit a load balancer protocol."""
3737

3838
mgr = SoftLayer.LoadBalancerManager(env.client)
3939

40-
uuid_lb = mgr.get_lb(identifier)['uuid']
40+
uuid = mgr.get_lb_uuid(identifier)
4141

4242
backend = args.get('backend')
4343
frontend = args.get('frontend')
@@ -53,15 +53,15 @@ def cli(env, identifier, **args):
5353
}
5454
]
5555
protocol_configurations[0]['listenerUuid'] = args.get('uuid')
56-
protocol = mgr.add_protocols(uuid_lb, protocol_configurations)
56+
protocol = mgr.add_protocols(uuid, protocol_configurations)
5757

5858
table = formatting.KeyValueTable(['name', 'value'])
5959
table.align['name'] = 'r'
6060
table.align['value'] = 'l'
6161
table.add_row(['Id', protocol.get('id')])
6262
table.add_row(['UUI', protocol.get('uuid')])
6363
table.add_row(['Address', protocol.get('address')])
64-
table.add_row(['Type', SoftLayer.LoadBalancerManager.TYPE.get(protocol.get('type'))])
64+
table.add_row(['Type', mgr.get_lb_type(protocol.get('type'))])
6565
table.add_row(['Description', protocol.get('description')])
6666

6767
env.fout(table)

SoftLayer/managers/load_balancer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
:license: MIT, see LICENSE for more details.
77
"""
8+
import SoftLayer
89
from SoftLayer import exceptions
910
from SoftLayer.managers import ordering
1011
from SoftLayer import utils
@@ -295,3 +296,15 @@ def delete_protocol(self, uuid_lb, uuid):
295296
"""
296297
return self.client.call('SoftLayer_Network_LBaaS_Listener', 'deleteLoadBalancerProtocols',
297298
uuid_lb, [uuid])
299+
300+
def get_lb_uuid(self, identifier):
301+
"""this sample show the uuid from loadbalancer.
302+
303+
:param identifier int: loadbalancer identifier.
304+
"""
305+
lb = self.lbaas.getObject(id=identifier, mask="mask[id,uuid]")
306+
return lb.get('uuid')
307+
308+
def get_lb_type(self, lb_type):
309+
310+
return SoftLayer.LoadBalancerManager.TYPE.get(lb_type)

0 commit comments

Comments
 (0)