Skip to content

Commit e67bb03

Browse files
caberoscaberos
authored andcommitted
new command account hooks
1 parent e03d17b commit e67bb03

File tree

7 files changed

+58
-0
lines changed

7 files changed

+58
-0
lines changed

SoftLayer/CLI/account/hooks.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Show all Provisioning Scripts."""
2+
# :license: MIT, see LICENSE for more details.
3+
import click
4+
5+
6+
from SoftLayer.CLI.command import SLCommand as SLCommand
7+
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import formatting
9+
from SoftLayer.managers import account
10+
11+
12+
@click.command(cls=SLCommand)
13+
@environment.pass_env
14+
def cli(env):
15+
"""Show all Provisioning Scripts."""
16+
17+
manager = account.AccountManager(env.client)
18+
hooks = manager.get_provisioning_scripts()
19+
20+
table = formatting.Table(["Id", "Name", "Uri"])
21+
22+
for hook in hooks:
23+
table.add_row([hook.get('id'), hook.get('name'), hook.get('uri')])
24+
25+
env.fout(table)

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
('account:cancel-item', 'SoftLayer.CLI.account.cancel_item:cli'),
2525
('account:orders', 'SoftLayer.CLI.account.orders:cli'),
2626
('account:bandwidth-pools', 'SoftLayer.CLI.account.bandwidth_pools:cli'),
27+
('account:hooks', 'SoftLayer.CLI.account.hooks:cli'),
2728

2829
('virtual', 'SoftLayer.CLI.virt'),
2930
('virtual:bandwidth', 'SoftLayer.CLI.virt.bandwidth:cli'),

SoftLayer/fixtures/SoftLayer_Account.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,3 +1469,14 @@
14691469
'keyName': 'ACTIVE'
14701470
}
14711471
}]
1472+
1473+
getPostProvisioningHooks = [{
1474+
"id": 147258369,
1475+
"name": "testProv",
1476+
"uri": "http://test.com"
1477+
},
1478+
{
1479+
"id": 123654,
1480+
"name": "GettestProv12345",
1481+
"uri": "http://test.com"
1482+
}]

SoftLayer/managers/account.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,11 @@ def getBandwidthDetail(self, identifier):
387387
virtualGuests[outboundPublicBandwidthUsage,bandwidthAllotmentDetail[allocation]],
388388
bareMetalInstances[outboundBandwidthUsage,bandwidthAllotmentDetail[allocation]]"""
389389
return self.client['SoftLayer_Network_Bandwidth_Version1_Allotment'].getObject(id=identifier, mask=_mask)
390+
391+
def get_provisioning_scripts(self):
392+
"""Gets a provisioning hooks.
393+
394+
:returns: provisioning hook
395+
"""
396+
397+
return self.client.call('Account', 'getPostProvisioningHooks')

docs/cli/account.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ Account Commands
5151
.. click:: SoftLayer.CLI.account.bandwidth_pools_detail:cli
5252
:prog: account bandwidth-pools-detail
5353
:show-nested:
54+
55+
.. click:: SoftLayer.CLI.account.hooks:cli
56+
:prog: account hooks
57+
:show-nested:

tests/CLI/modules/account_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,8 @@ def test_acccount_bandwidth_pool_detail(self):
159159
result = self.run_command(['account', 'bandwidth-pools-detail', '123456'])
160160
self.assert_no_fail(result)
161161
self.assert_called_with('SoftLayer_Network_Bandwidth_Version1_Allotment', 'getObject')
162+
163+
def test_acccount_provisioning_hook(self):
164+
result = self.run_command(['account', 'hooks'])
165+
self.assert_no_fail(result)
166+
self.assert_called_with('SoftLayer_Account', 'getPostProvisioningHooks')

tests/managers/account_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,7 @@ def test_get_bandwidth_pool_counts(self):
176176
total = self.manager.get_bandwidth_pool_counts(1234)
177177
self.assert_called_with('SoftLayer_Network_Bandwidth_Version1_Allotment', 'getObject', identifier=1234)
178178
self.assertEqual(total, 2)
179+
180+
def test_get_provisioning_scripts(self):
181+
self.manager.get_provisioning_scripts()
182+
self.assert_called_with("SoftLayer_Account", "getPostProvisioningHooks")

0 commit comments

Comments
 (0)