Skip to content

Commit 941b49e

Browse files
J JayasilanJ Jayasilan
authored andcommitted
Bandwidth pools_create additional changes
1 parent 0da5b34 commit 941b49e

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

SoftLayer/CLI/bandwidth/pools_create.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,41 @@
2222
}
2323

2424
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'"
2625

2726

28-
def check_region_param(ctx, param, value):
27+
def check_region_param(ctx, param, value): # pylint: disable=unused-argument
2928
"""Check if provided region is region group or part of region"""
3029

3130
# :params string value: Region or Region-Groups
3231
# return string Region-Groups
3332

34-
_ = [ctx, param]
3533
region_group = None
3634
for key in location_groups:
3735
if value in key or value is key:
3836
region_group = key
39-
else:
40-
continue
4137

4238
if region_group:
4339
return region_group
4440
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']")
4744

4845

4946
@click.command(cls=SLCommand)
5047
@click.option('--name', required=True, help="Pool name")
5148
@click.option('--region', required=True,
5249
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')
5451
@environment.pass_env
5552
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+
"""
5760

5861
manager = BandwidthManager(env.client)
5962
locations = manager.get_location_group()

tests/CLI/modules/bandwidth_tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def test_create_bandwidth(self):
5656
self.assertEqual('NewRegion', json_output['Name Pool'])
5757
self.assertEqual('SJC/DAL/WDC/TOR/MON', json_output['Region'])
5858

59+
def test_create_bandwidth_single_region(self):
60+
result = self.run_command(['bandwidth', 'pools-create', '--name=NewRegion', '--region=AMS'])
61+
self.assert_no_fail(result)
62+
self.assert_called_with('SoftLayer_Network_Bandwidth_Version1_Allotment', 'createObject')
63+
json_output = json.loads(result.output)
64+
pp(json_output)
65+
self.assertEqual(123456789, json_output['Id'])
66+
self.assertEqual('NewRegion', json_output['Name Pool'])
67+
self.assertEqual('AMS/LON/MAD/PAR', json_output['Region'])
68+
5969

6070
def _bandwidth_advanced_search():
6171
result = [

0 commit comments

Comments
 (0)