Skip to content

Commit 56c4ebf

Browse files
J JayasilanJ Jayasilan
authored andcommitted
bandwidth pools-create with single locations as option
1 parent f34e9c3 commit 56c4ebf

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

SoftLayer/CLI/bandwidth/pools_create.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,31 @@
2121
"FRA": "FRA"
2222
}
2323

24+
regions = ['SJC/DAL/WDC/TOR/MON', 'AMS/LON/MAD/PAR', 'SNG/HKG/OSA/TOK', 'SYD', 'MEX', 'SAO', 'CHE', 'MIL', 'SEO', 'FRA']
25+
help_stmt = "Ex: 'HKG' or 'SNG/HKG/OSA/TOK'"
26+
27+
def check_region_param(ctx,param,value):
28+
"""Check if provided region is region group or part of region"""
29+
#:params string value: Region or Region-Groups
30+
# return string Region-Groups
31+
32+
region_group = None
33+
for key in location_groups.keys():
34+
if value in key or value is key:
35+
region_group = key
36+
else:
37+
continue
38+
39+
if region_group:
40+
return region_group
41+
else:
42+
raise click.BadParameter(f"{value} is not a region or part of any region. \nAvailable Choices: \033[1;32m{regions}")
2443

2544
@click.command(cls=SLCommand)
2645
@click.option('--name', required=True, help="Pool name")
2746
@click.option('--region', required=True,
28-
type=click.Choice(['SJC/DAL/WDC/TOR/MON', 'AMS/LON/MAD/PAR', 'SNG/HKG/OSA/TOK',
29-
'SYD', 'MEX', 'SAO', 'CHE', 'MIL', 'SEO', 'FRA']),
30-
help="Region selected")
47+
help=f"Choose Region/Region-Group {regions}", callback=check_region_param)
48+
@click.help_option('--help','-h',help=f"Specify Region or Region group - \033[1;32m{help_stmt}")
3149
@environment.pass_env
3250
def cli(env, name, region):
3351
"""Create bandwidth pool."""

slcli

100644100755
File mode changed.

0 commit comments

Comments
 (0)