diff --git a/src/azure-cli/azure/cli/command_modules/backup/_params.py b/src/azure-cli/azure/cli/command_modules/backup/_params.py index e78f6e0ca79..1ee4db6f0dd 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/_params.py +++ b/src/azure-cli/azure/cli/command_modules/backup/_params.py @@ -253,6 +253,7 @@ def load_arguments(self, _): c.argument('protectable_item_type', protectable_item_type) with self.argument_context('backup protectable-item list') as c: + c.argument('server_name', options_list=['--server-name'], help='Parent Server name of the item.') c.argument('protectable_item_type', protectable_item_type) c.argument('backup_management_type', arg_type=get_enum_type(allowed_backup_management_types + ["MAB"]), help=backup_management_type_help) diff --git a/src/azure-cli/azure/cli/command_modules/backup/custom_base.py b/src/azure-cli/azure/cli/command_modules/backup/custom_base.py index 5e3728e5449..2d1f4c23b27 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/custom_base.py +++ b/src/azure-cli/azure/cli/command_modules/backup/custom_base.py @@ -193,7 +193,8 @@ def list_associated_items_for_policy(client, resource_group_name, vault_name, na def list_protectable_items(cmd, client, resource_group_name, vault_name, workload_type, - backup_management_type="AzureWorkload", container_name=None, protectable_item_type=None): + backup_management_type="AzureWorkload", container_name=None, protectable_item_type=None, + server_name=None): if backup_management_type != "AzureWorkload": raise ValidationError(""" @@ -215,7 +216,7 @@ def list_protectable_items(cmd, client, resource_group_name, vault_name, workloa """) container_uri = container.name return custom_wl.list_protectable_items(client, resource_group_name, vault_name, workload_type, - backup_management_type, container_uri, protectable_item_type) + backup_management_type, container_uri, protectable_item_type, server_name) def show_protectable_item(cmd, client, resource_group_name, vault_name, name, server_name, protectable_item_type, diff --git a/src/azure-cli/azure/cli/command_modules/backup/custom_wl.py b/src/azure-cli/azure/cli/command_modules/backup/custom_wl.py index 985ea10036d..f9a6d47b29e 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/custom_wl.py +++ b/src/azure-cli/azure/cli/command_modules/backup/custom_wl.py @@ -290,7 +290,8 @@ def show_protectable_instance(items, server_name, protectable_item_type): def list_protectable_items(client, resource_group_name, vault_name, workload_type, - backup_management_type="AzureWorkload", container_uri=None, protectable_item_type=None): + backup_management_type="AzureWorkload", container_uri=None, protectable_item_type=None, + server_name=None): workload_type = _check_map(workload_type, workload_type_map) if protectable_item_type is not None: @@ -308,6 +309,10 @@ def list_protectable_items(client, resource_group_name, vault_name, workload_typ # Protectable Item Type filter paged_items = [item for item in paged_items if item.properties.protectable_item_type.lower() == protectable_item_type.lower()] + if server_name is not None: + # Server Name filter + paged_items = [item for item in paged_items if + item.properties.server_name.lower() == server_name.lower()] if container_uri: return [item for item in paged_items if cust_help.get_protection_container_uri_from_id(item.id).lower() == container_uri.lower()]