Skip to content

Commit c13eeb0

Browse files
Merge branch 'issue1995' of github.com:edsonarios/softlayer-python
2 parents 36d7c19 + 88bab43 commit c13eeb0

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Delete bandwidth pool."""
2+
# :license: MIT, see LICENSE for more details.
3+
import click
4+
5+
from SoftLayer import BandwidthManager
6+
from SoftLayer.CLI.command import SLCommand as SLCommand
7+
from SoftLayer.CLI import environment
8+
9+
10+
@click.command(cls=SLCommand)
11+
@click.argument('identifier')
12+
@environment.pass_env
13+
def cli(env, identifier):
14+
"""Delete bandwidth pool."""
15+
16+
manager = BandwidthManager(env.client)
17+
bandwidth_pool = manager.delete_pool(identifier)
18+
19+
if bandwidth_pool:
20+
env.fout(f"Bandwidth pool with ID {identifier} was programmed to will delete")

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@
426426
('bandwidth:pools-detail', 'SoftLayer.CLI.bandwidth.pools_detail:cli'),
427427
('bandwidth:pools-create', 'SoftLayer.CLI.bandwidth.pools_create:cli'),
428428
('bandwidth:pools-edit', 'SoftLayer.CLI.bandwidth.pools_edit:cli'),
429+
('bandwidth:pools-delete', 'SoftLayer.CLI.bandwidth.pools_delete:cli'),
429430
]
430431

431432
ALL_ALIASES = {

SoftLayer/fixtures/SoftLayer_Network_Bandwidth_Version1_Allotment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@
158158
}
159159

160160
editObject = True
161+
162+
requestVdrCancellation = True

SoftLayer/managers/bandwidth.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,10 @@ def edit_pool(self, identifier, new_name_pool):
6969
}
7070

7171
return self.client.call('Network_Bandwidth_Version1_Allotment', 'editObject', template, id=identifier)
72+
73+
def delete_pool(self, identifier):
74+
"""Delete bandwidth pool
75+
76+
:return: Boolean value
77+
"""
78+
return self.client.call('Network_Bandwidth_Version1_Allotment', 'requestVdrCancellation', id=identifier)

docs/cli/bandwidth.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ bandwidth Commands
2323
.. click:: SoftLayer.CLI.bandwidth.pools_edit:cli
2424
:prog: bandwidth pools-edit
2525
:show-nested:
26+
27+
.. click:: SoftLayer.CLI.bandwidth.pools_delete:cli
28+
:prog: bandwidth pools-delete
29+
:show-nested:

tests/CLI/modules/bandwidth_tests.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ def test_edit_bandwidth(self):
6161
self.assertEqual('MexRegionEdited', json_output['Name Pool'])
6262
self.assertEqual('MEX', json_output['Region'])
6363

64+
def test_delete_bandwidth(self):
65+
result = self.run_command(['bandwidth', 'pools-delete', '123456'])
66+
self.assert_no_fail(result)
67+
self.assert_called_with('SoftLayer_Network_Bandwidth_Version1_Allotment', 'requestVdrCancellation')
68+
json_output = json.loads(result.output)
69+
self.assertEqual("Bandwidth pool with ID 123456 was programmed to will delete", json_output)
70+
6471

6572
def _bandwidth_advanced_search():
6673
result = [

0 commit comments

Comments
 (0)