Skip to content

Commit 0970dd4

Browse files
image cache clear: fix value of default target
When using the "openstack image cache clear" command, the "clear_cache" method from the OpenStack SDK is used. It expects its only argument to be one of "both", "cache" or "queue". However, when passing neither "--cache" nor "--queue", it is currently passed None as a value. Fix this by specifying "both" as the default value to be passed. Change-Id: I17c6e3d435a84b4ba453845086ff3fe272b54f58
1 parent 2f9a523 commit 0970dd4

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

openstackclient/image/v2/cache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,15 @@ def get_parser(self, prog_name):
194194
"--cache",
195195
action="store_const",
196196
const="cache",
197+
default="both",
197198
dest="target",
198199
help=_("Clears all the cached images"),
199200
)
200201
parser.add_argument(
201202
"--queue",
202203
action="store_const",
203204
const="queue",
205+
default="both",
204206
dest="target",
205207
help=_("Clears all the queued images"),
206208
)

openstackclient/tests/unit/image/v2/test_cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ def setUp(self):
184184
def test_cache_clear_no_option(self):
185185
arglist = []
186186

187-
verifylist = [('target', None)]
187+
verifylist = [('target', 'both')]
188188

189189
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
190190
self.cmd.take_action(parsed_args)
191191

192192
self.assertIsNone(
193-
self.image_client.clear_cache.assert_called_with(None)
193+
self.image_client.clear_cache.assert_called_with('both')
194194
)
195195

196196
def test_cache_clear_queue_option(self):

0 commit comments

Comments
 (0)