From 83a2c3de4de0e06aa7d6b1069f0c4a8084c6b93f Mon Sep 17 00:00:00 2001 From: caberos Date: Thu, 23 Mar 2023 15:57:58 -0400 Subject: [PATCH 1/3] new feature on account hook-delete --- SoftLayer/CLI/account/hook_delete.py | 24 +++++++++++++++++++ SoftLayer/CLI/routes.py | 1 + .../fixtures/SoftLayer_Provisioning_Hook.py | 1 + SoftLayer/managers/account.py | 9 +++++++ docs/cli/account.rst | 4 ++++ tests/CLI/modules/account_tests.py | 5 ++++ tests/managers/account_tests.py | 4 ++++ 7 files changed, 48 insertions(+) create mode 100644 SoftLayer/CLI/account/hook_delete.py create mode 100644 SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py diff --git a/SoftLayer/CLI/account/hook_delete.py b/SoftLayer/CLI/account/hook_delete.py new file mode 100644 index 000000000..c4eda42ba --- /dev/null +++ b/SoftLayer/CLI/account/hook_delete.py @@ -0,0 +1,24 @@ +"""Delete a provisioning script""" +# :license: MIT, see LICENSE for more details. + +import click +import SoftLayer + +from SoftLayer.CLI.command import SLCommand as SLCommand +from SoftLayer.CLI import environment +from SoftLayer.managers.account import AccountManager as AccountManager + + +@click.command(cls=SLCommand) +@click.argument('identifier') +@environment.pass_env +def cli(env, identifier): + """Delete a provisioning script""" + + manager = AccountManager(env.client) + + try: + manager.delete_provisioning(identifier) + click.secho("%s deleted successfully" % identifier, fg='green') + except SoftLayer.SoftLayerAPIError as ex: + click.secho("Failed to delete %s\n%s" % (identifier, ex), fg='red') diff --git a/SoftLayer/CLI/routes.py b/SoftLayer/CLI/routes.py index b1cb139d3..0b6849cf8 100644 --- a/SoftLayer/CLI/routes.py +++ b/SoftLayer/CLI/routes.py @@ -25,6 +25,7 @@ ('account:orders', 'SoftLayer.CLI.account.orders:cli'), ('account:bandwidth-pools', 'SoftLayer.CLI.account.bandwidth_pools:cli'), ('account:hooks', 'SoftLayer.CLI.account.hooks:cli'), + ('account:hook-delete', 'SoftLayer.CLI.account.hook_delete:cli'), ('virtual', 'SoftLayer.CLI.virt'), ('virtual:bandwidth', 'SoftLayer.CLI.virt.bandwidth:cli'), diff --git a/SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py b/SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py new file mode 100644 index 000000000..1fe3e5de4 --- /dev/null +++ b/SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py @@ -0,0 +1 @@ +deleteObject = True diff --git a/SoftLayer/managers/account.py b/SoftLayer/managers/account.py index 72744fd35..27716a687 100644 --- a/SoftLayer/managers/account.py +++ b/SoftLayer/managers/account.py @@ -395,3 +395,12 @@ def get_provisioning_scripts(self): """ return self.client.call('Account', 'getPostProvisioningHooks') + + def delete_provisioning(self, identifier): + """Delete a provisioning script + + param: identifier provisioning script identifier + + Returns: boolean + """ + return self.client.call("SoftLayer_Provisioning_Hook", "deleteObject", id=identifier) diff --git a/docs/cli/account.rst b/docs/cli/account.rst index 33ac4e6b4..3076dac7f 100644 --- a/docs/cli/account.rst +++ b/docs/cli/account.rst @@ -55,3 +55,7 @@ Account Commands .. click:: SoftLayer.CLI.account.hooks:cli :prog: account hooks :show-nested: + +.. click:: SoftLayer.CLI.account.hook_delete:cli + :prog: account hook-delete + :show-nested: diff --git a/tests/CLI/modules/account_tests.py b/tests/CLI/modules/account_tests.py index 022ef5405..5ffb1ce09 100644 --- a/tests/CLI/modules/account_tests.py +++ b/tests/CLI/modules/account_tests.py @@ -164,3 +164,8 @@ def test_acccount_provisioning_hook(self): result = self.run_command(['account', 'hooks']) self.assert_no_fail(result) self.assert_called_with('SoftLayer_Account', 'getPostProvisioningHooks') + + def test_delete_provisioning_hook(self): + result = self.run_command(['account', 'hook-delete', '123456']) + self.assert_no_fail(result) + self.assert_called_with('SoftLayer_Provisioning_Hook', 'deleteObject') diff --git a/tests/managers/account_tests.py b/tests/managers/account_tests.py index efacbf693..08f299583 100644 --- a/tests/managers/account_tests.py +++ b/tests/managers/account_tests.py @@ -180,3 +180,7 @@ def test_get_bandwidth_pool_counts(self): def test_get_provisioning_scripts(self): self.manager.get_provisioning_scripts() self.assert_called_with("SoftLayer_Account", "getPostProvisioningHooks") + + def test_delete_provisioning_scripts(self): + self.manager.delete_provisioning(123456) + self.assert_called_with("SoftLayer_Provisioning_Hook", "deleteObject") From 172671edde4ca7a786206f2dadefc98b836eeaea Mon Sep 17 00:00:00 2001 From: caberos Date: Thu, 23 Mar 2023 16:26:53 -0400 Subject: [PATCH 2/3] fix the tox tool --- SoftLayer/CLI/routes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/SoftLayer/CLI/routes.py b/SoftLayer/CLI/routes.py index fcd6805e4..aaa3dee63 100644 --- a/SoftLayer/CLI/routes.py +++ b/SoftLayer/CLI/routes.py @@ -211,6 +211,7 @@ ('image:import', 'SoftLayer.CLI.image.import:cli'), ('image:export', 'SoftLayer.CLI.image.export:cli'), ('image:datacenter', 'SoftLayer.CLI.image.datacenter:cli'), + ('image:share', 'SoftLayer.CLI.image.share:cli'), ('image:share-deny', 'SoftLayer.CLI.image.share_deny:cli'), ('ipsec', 'SoftLayer.CLI.vpn.ipsec'), From 8b0e140d3ceb5ca07d9e096545670760b44392bc Mon Sep 17 00:00:00 2001 From: caberos Date: Thu, 23 Mar 2023 16:29:46 -0400 Subject: [PATCH 3/3] fix the tox tool --- SoftLayer/CLI/routes.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/SoftLayer/CLI/routes.py b/SoftLayer/CLI/routes.py index aaa3dee63..921ad2475 100644 --- a/SoftLayer/CLI/routes.py +++ b/SoftLayer/CLI/routes.py @@ -400,11 +400,6 @@ ('report', 'SoftLayer.CLI.report'), ('report:bandwidth', 'SoftLayer.CLI.report.bandwidth:cli'), ('report:datacenter-closures', 'SoftLayer.CLI.report.dc_closures:cli'), - - ('autoscale', 'SoftLayer.CLI.autoscale'), - ('autoscale:list', 'SoftLayer.CLI.autoscale.list:cli'), - ('autoscale:detail', 'SoftLayer.CLI.autoscale.detail:cli'), - ('autoscale:delete', 'SoftLayer.CLI.autoscale.delete:cli'), ] ALL_ALIASES = {