|
22 | 22 | } |
23 | 23 |
|
24 | 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 | 25 |
|
27 | 26 |
|
28 | | -def check_region_param(ctx, param, value): |
| 27 | +def check_region_param(ctx, param, value): # pylint: disable=unused-argument |
29 | 28 | """Check if provided region is region group or part of region""" |
30 | 29 |
|
31 | 30 | # :params string value: Region or Region-Groups |
32 | 31 | # return string Region-Groups |
33 | 32 |
|
34 | | - _ = [ctx, param] |
35 | 33 | region_group = None |
36 | 34 | for key in location_groups: |
37 | 35 | if value in key or value is key: |
38 | 36 | region_group = key |
39 | | - else: |
40 | | - continue |
41 | 37 |
|
42 | 38 | if region_group: |
43 | 39 | return region_group |
44 | 40 | else: |
45 | | - raise click.BadParameter(f"{value} is not a region or part of any region.\ |
46 | | - \nAvailable Choices: \033[1;32m{regions}") |
| 41 | + raise click.BadParameter(f"{value} is not a region or part of any region." |
| 42 | + " Available Choices: ['SJC/DAL/WDC/TOR/MON', 'AMS/LON/MAD/PAR'," |
| 43 | + " 'SNG/HKG/OSA/TOK', 'SYD', 'MEX', 'SAO', 'CHE', 'MIL', 'SEO', 'FRA']") |
47 | 44 |
|
48 | 45 |
|
49 | 46 | @click.command(cls=SLCommand) |
50 | 47 | @click.option('--name', required=True, help="Pool name") |
51 | 48 | @click.option('--region', required=True, |
52 | 49 | help=f"Choose Region/Region-Group {regions}", callback=check_region_param) |
53 | | -@click.help_option('--help', '-h', help=f"Specify Region or Region group - \033[1;32m{HELP_STMT}") |
| 50 | +@click.help_option('--help', '-h') |
54 | 51 | @environment.pass_env |
55 | 52 | def cli(env, name, region): |
56 | | - """Create bandwidth pool.""" |
| 53 | + """Create bandwidth pool. |
| 54 | +
|
| 55 | + Region can be the full zone name 'SJC/DAL/WDC/TOR/MON', or just a single datacenter like 'SJC'. |
| 56 | + Example:: |
| 57 | + slcli bandwidth pool-create --name testPool --region DAL |
| 58 | + slcli bandwidth pool-create --name testPool --region SJC/DAL/WDC/TOR/MON |
| 59 | + """ |
57 | 60 |
|
58 | 61 | manager = BandwidthManager(env.client) |
59 | 62 | locations = manager.get_location_group() |
|
0 commit comments