From 1d4aabab2e7b5d5de5ee313556c147a96f74d426 Mon Sep 17 00:00:00 2001 From: Tim Bishop Date: Mon, 22 Jul 2024 16:55:34 +0100 Subject: [PATCH] Respect --skip-resource when deleting. When running project cleanup and using the --skip-resource flag, this flag is only used during the --dry-run stage. This change ensures it is also used when deleting the resources which fixes the bug mentioned below. Closes-Bug: #2074109 Change-Id: I8e50fd14dcde069b932cc8ec4bb4fc809f7d2eb7 --- openstackclient/common/project_cleanup.py | 5 ++- .../tests/unit/common/test_project_cleanup.py | 35 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/openstackclient/common/project_cleanup.py b/openstackclient/common/project_cleanup.py index 2ac156cba5..0c143fad3f 100644 --- a/openstackclient/common/project_cleanup.py +++ b/openstackclient/common/project_cleanup.py @@ -150,5 +150,8 @@ class ProjectCleanup(command.Command): self.log.warning(_('Deleting resources')) project_connect.project_cleanup( - dry_run=False, status_queue=status_queue, filters=filters + dry_run=False, + status_queue=status_queue, + filters=filters, + skip_resources=parsed_args.skip_resource, ) diff --git a/openstackclient/tests/unit/common/test_project_cleanup.py b/openstackclient/tests/unit/common/test_project_cleanup.py index 019d6cf157..50d4e6487c 100644 --- a/openstackclient/tests/unit/common/test_project_cleanup.py +++ b/openstackclient/tests/unit/common/test_project_cleanup.py @@ -83,7 +83,12 @@ class TestProjectCleanup(test_utils.TestCommand): filters=filters, skip_resources=None, ), - mock.call(dry_run=False, status_queue=mock.ANY, filters=filters), + mock.call( + dry_run=False, + status_queue=mock.ANY, + filters=filters, + skip_resources=None, + ), ] self.project_cleanup_mock.assert_has_calls(calls) @@ -114,7 +119,12 @@ class TestProjectCleanup(test_utils.TestCommand): filters={}, skip_resources=None, ), - mock.call(dry_run=False, status_queue=mock.ANY, filters={}), + mock.call( + dry_run=False, + status_queue=mock.ANY, + filters={}, + skip_resources=None, + ), ] self.project_cleanup_mock.assert_has_calls(calls) @@ -144,7 +154,12 @@ class TestProjectCleanup(test_utils.TestCommand): filters={}, skip_resources=None, ), - mock.call(dry_run=False, status_queue=mock.ANY, filters={}), + mock.call( + dry_run=False, + status_queue=mock.ANY, + filters={}, + skip_resources=None, + ), ] self.project_cleanup_mock.assert_has_calls(calls) @@ -230,7 +245,12 @@ class TestProjectCleanup(test_utils.TestCommand): filters={}, skip_resources=None, ), - mock.call(dry_run=False, status_queue=mock.ANY, filters={}), + mock.call( + dry_run=False, + status_queue=mock.ANY, + filters={}, + skip_resources=None, + ), ] self.project_cleanup_mock.assert_has_calls(calls) @@ -260,7 +280,12 @@ class TestProjectCleanup(test_utils.TestCommand): filters={}, skip_resources=[skip_resource], ), - mock.call(dry_run=False, status_queue=mock.ANY, filters={}), + mock.call( + dry_run=False, + status_queue=mock.ANY, + filters={}, + skip_resources=[skip_resource], + ), ] self.project_cleanup_mock.assert_has_calls(calls)