From 96db2e6e36535bd28455259b4c59383472e30939 Mon Sep 17 00:00:00 2001 From: Derek Bekoe Date: Tue, 24 Jan 2017 09:46:12 -0800 Subject: [PATCH] Add confirmation prompt to more delete operations (#1826) * Add confirmation prompt to more delete operations - az appservice plan delete - az storage account delete - az vmss delete * Fix tests --- .../azure/cli/command_modules/appservice/commands.py | 2 +- .../command_modules/batch/tests/test_batch_mgmt_commands.py | 4 ++-- .../azure/cli/command_modules/storage/commands.py | 2 +- .../azure/cli/command_modules/storage/tests/test_storage.py | 2 +- .../azure-cli-vm/azure/cli/command_modules/vm/commands.py | 2 +- .../azure/cli/command_modules/vm/tests/test_vm_commands.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/command_modules/azure-cli-appservice/azure/cli/command_modules/appservice/commands.py b/src/command_modules/azure-cli-appservice/azure/cli/command_modules/appservice/commands.py index ecd50641b..098fb137e 100644 --- a/src/command_modules/azure-cli-appservice/azure/cli/command_modules/appservice/commands.py +++ b/src/command_modules/azure-cli-appservice/azure/cli/command_modules/appservice/commands.py @@ -55,7 +55,7 @@ cli_command(__name__, 'appservice web deployment user show', 'azure.mgmt.web.ope factory = lambda _: web_client_factory().server_farms cli_command(__name__, 'appservice plan create', 'azure.cli.command_modules.appservice.custom#create_app_service_plan') -cli_command(__name__, 'appservice plan delete', 'azure.mgmt.web.operations.server_farms_operations#ServerFarmsOperations.delete_server_farm', factory) +cli_command(__name__, 'appservice plan delete', 'azure.mgmt.web.operations.server_farms_operations#ServerFarmsOperations.delete_server_farm', factory, confirmation=True) cli_generic_update_command(__name__, 'appservice plan update', 'azure.mgmt.web.operations.server_farms_operations#ServerFarmsOperations.get_server_farm', 'azure.mgmt.web.operations.server_farms_operations#ServerFarmsOperations.create_or_update_server_farm', custom_function_op='azure.cli.command_modules.appservice.custom#update_app_service_plan', diff --git a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/tests/test_batch_mgmt_commands.py b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/tests/test_batch_mgmt_commands.py index 4c6d2a5ca..7c462dec6 100644 --- a/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/tests/test_batch_mgmt_commands.py +++ b/src/command_modules/azure-cli-batch/azure/cli/command_modules/batch/tests/test_batch_mgmt_commands.py @@ -20,7 +20,7 @@ class BatchMgmtAccountScenarioTest(ResourceGroupVCRTestBase): def tear_down(self): rg = self.resource_group name = self.storage_account_name - self.cmd('storage account delete -g {} -n {}'.format(rg, name)) + self.cmd('storage account delete -g {} -n {} --force'.format(rg, name)) def __init__(self, test_method): super(BatchMgmtAccountScenarioTest, self).__init__(__file__, test_method) @@ -124,7 +124,7 @@ class BatchMgmtApplicationScenarioTest(ResourceGroupVCRTestBase): rg = self.resource_group sname = self.storage_account_name name = self.account_name - self.cmd('storage account delete -g {} -n {}'.format(rg, sname)) + self.cmd('storage account delete -g {} -n {} --force'.format(rg, sname)) self.cmd('batch account delete -g {} -n {}'.format(rg, name)) if os.path.exists(self.package_file_name): os.remove(self.package_file_name) diff --git a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/commands.py b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/commands.py index ae871abbb..39e83ff32 100644 --- a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/commands.py +++ b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/commands.py @@ -28,7 +28,7 @@ from azure.cli.command_modules.storage._format import \ # storage account commands factory = lambda kwargs: storage_client_factory().storage_accounts # noqa: E731 lambda vs def cli_command(__name__, 'storage account check-name', 'azure.mgmt.storage.operations.storage_accounts_operations#StorageAccountsOperations.check_name_availability', factory) -cli_command(__name__, 'storage account delete', 'azure.mgmt.storage.operations.storage_accounts_operations#StorageAccountsOperations.delete', factory) +cli_command(__name__, 'storage account delete', 'azure.mgmt.storage.operations.storage_accounts_operations#StorageAccountsOperations.delete', factory, confirmation=True) cli_command(__name__, 'storage account show', 'azure.mgmt.storage.operations.storage_accounts_operations#StorageAccountsOperations.get_properties', factory) cli_command(__name__, 'storage account create', 'azure.cli.command_modules.storage.custom#create_storage_account') cli_command(__name__, 'storage account list', 'azure.cli.command_modules.storage.custom#list_storage_accounts') diff --git a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/tests/test_storage.py b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/tests/test_storage.py index 5574e4bc4..93cd030c2 100644 --- a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/tests/test_storage.py +++ b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/tests/test_storage.py @@ -92,7 +92,7 @@ class StorageAccountScenarioTest(ResourceGroupVCRTestBase): checks=JMESPathCheck('tags', {})) s.cmd('storage account update -g {} -n {} --sku Standard_GRS'.format(rg, account), checks=JMESPathCheck('sku.name', 'Standard_GRS')) - s.cmd('storage account delete -g {} -n {}'.format(rg, account)) + s.cmd('storage account delete -g {} -n {} --force'.format(rg, account)) s.cmd('storage account check-name --name {}'.format(account), checks=JMESPathCheck('nameAvailable', True)) diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/commands.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/commands.py index 6d7a75ac6..f1c947e6e 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/commands.py +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/commands.py @@ -207,7 +207,7 @@ cli_command(__name__, 'vm list-usage', mgmt_path.format('usage_operations', 'Usa cli_command(__name__, 'vmss create', 'azure.cli.command_modules.vm.mgmt_vmss.lib.operations.vmss_operations#VmssOperations.create_or_update', cf_vmss_create, transform=DeploymentOutputLongRunningOperation('Starting vmss create')) -cli_command(__name__, 'vmss delete', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'delete'), cf_vmss) +cli_command(__name__, 'vmss delete', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'delete'), cf_vmss, confirmation=True) cli_command(__name__, 'vmss list-skus', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'list_skus'), cf_vmss) cli_command(__name__, 'vmss list-instances', mgmt_path.format('virtual_machine_scale_set_vms_operations', 'VirtualMachineScaleSetVMsOperations', 'list'), cf_vmss_vm) diff --git a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/tests/test_vm_commands.py b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/tests/test_vm_commands.py index a3a4d2fe0..159e45ea7 100644 --- a/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/tests/test_vm_commands.py +++ b/src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/tests/test_vm_commands.py @@ -687,7 +687,7 @@ class VMScaleSetDeleteScenarioTest(VCRTestBase): ]) self.cmd('vmss deallocate --resource-group {} --name {}'.format(self.resource_group, self.ss_name), checks=NoneCheck()) - self.cmd('vmss delete --resource-group {} --name {}'.format(self.resource_group, self.ss_name), + self.cmd('vmss delete --resource-group {} --name {} --force'.format(self.resource_group, self.ss_name), checks=NoneCheck()) self.cmd('vmss list --resource-group {}'.format(self.resource_group), checks=NoneCheck())