Skip to content

Commit c810acf

Browse files
Merge pull request #2009 from ramkishor-ch/issue_2003
Removed Deduplicate code in LB of protocol edit cli commands for Issue 2003
2 parents 68b20d0 + c9b3a57 commit c810acf

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

SoftLayer/CLI/loadbal/protocol_edit.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,18 @@
33

44
import SoftLayer
55
from SoftLayer.CLI import environment
6-
from SoftLayer.CLI import exceptions
76
from SoftLayer.CLI import formatting
8-
9-
10-
# pylint: disable=unused-argument
11-
def parse_proto(ctx, param, value):
12-
"""Parses the frontend and backend cli options"""
13-
proto = {'protocol': 'HTTP', 'port': 80}
14-
splitout = value.split(':')
15-
if len(splitout) != 2:
16-
raise exceptions.ArgumentError("{}={} is not properly formatted.".format(param, value))
17-
proto['protocol'] = splitout[0]
18-
proto['port'] = int(splitout[1])
19-
return proto
7+
from SoftLayer.CLI.loadbal import protocol_add
208

219

2210
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
2311
@click.argument('identifier')
2412
@click.option('--uuid', help="Load Balancer Uuid.")
25-
@click.option('--frontend', '-f', required=True, default='HTTP:80', show_default=True, callback=parse_proto,
13+
@click.option('--frontend', '-f', required=True, default='HTTP:80', show_default=True,
14+
callback=protocol_add.parse_proto,
2615
help='PROTOCOL:PORT string for incoming internet connections.')
27-
@click.option('--backend', '-b', required=True, default='HTTP:80', show_default=True, callback=parse_proto,
16+
@click.option('--backend', '-b', required=True, default='HTTP:80', show_default=True,
17+
callback=protocol_add.parse_proto,
2818
help='PROTOCOL:PORT string for connecting to backend servers.')
2919
@click.option('--method', '-m', help="Balancing Method.", default='ROUNDROBIN', show_default=True,
3020
type=click.Choice(['ROUNDROBIN', 'LEASTCONNECTION', 'WEIGHTED_RR']))

0 commit comments

Comments
 (0)