Skip to content

Commit 5435f11

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "image: Trivial fixes"
2 parents 2ed10e9 + 8a63b51 commit 5435f11

File tree

5 files changed

+118
-102
lines changed

5 files changed

+118
-102
lines changed

openstackclient/image/v2/metadef_namespaces.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _format_namespace(namespace):
6262
return info
6363

6464

65-
class CreateMetadefNameSpace(command.ShowOne):
65+
class CreateMetadefNamespace(command.ShowOne):
6666
_description = _("Create a metadef namespace")
6767

6868
def get_parser(self, prog_name):
@@ -136,26 +136,26 @@ def take_action(self, parsed_args):
136136
return zip(*sorted(info.items()))
137137

138138

139-
class DeleteMetadefNameSpace(command.Command):
139+
class DeleteMetadefNamespace(command.Command):
140140
_description = _("Delete metadef namespace")
141141

142142
def get_parser(self, prog_name):
143143
parser = super().get_parser(prog_name)
144144
parser.add_argument(
145-
"namespace_name",
146-
metavar="<namespace_name>",
145+
"namespace",
146+
metavar="<namespace>",
147147
nargs="+",
148-
help=_("An identifier (a name) for the namespace"),
148+
help=_("Metadef namespace(s) to delete (name)"),
149149
)
150150
return parser
151151

152152
def take_action(self, parsed_args):
153153
image_client = self.app.client_manager.image
154154

155155
result = 0
156-
for i in parsed_args.namespace_name:
156+
for ns in parsed_args.namespace:
157157
try:
158-
namespace = image_client.get_metadef_namespace(i)
158+
namespace = image_client.get_metadef_namespace(ns)
159159
image_client.delete_metadef_namespace(namespace.id)
160160
except Exception as e:
161161
result += 1
@@ -164,18 +164,18 @@ def take_action(self, parsed_args):
164164
"Failed to delete namespace with name or "
165165
"ID '%(namespace)s': %(e)s"
166166
),
167-
{'namespace': i, 'e': e},
167+
{'namespace': ns, 'e': e},
168168
)
169169

170170
if result > 0:
171-
total = len(parsed_args.namespace_name)
171+
total = len(parsed_args.namespace)
172172
msg = _(
173173
"%(result)s of %(total)s namespace failed " "to delete."
174174
) % {'result': result, 'total': total}
175175
raise exceptions.CommandError(msg)
176176

177177

178-
class ListMetadefNameSpaces(command.Lister):
178+
class ListMetadefNamespace(command.Lister):
179179
_description = _("List metadef namespaces")
180180

181181
def get_parser(self, prog_name):
@@ -217,15 +217,15 @@ def take_action(self, parsed_args):
217217
)
218218

219219

220-
class SetMetadefNameSpace(command.Command):
220+
class SetMetadefNamespace(command.Command):
221221
_description = _("Set metadef namespace properties")
222222

223223
def get_parser(self, prog_name):
224224
parser = super().get_parser(prog_name)
225225
parser.add_argument(
226226
"namespace",
227227
metavar="<namespace>",
228-
help=_("Namespace (name) for the namespace"),
228+
help=_("Metadef namespace to modify (name)"),
229229
)
230230
parser.add_argument(
231231
"--display-name",
@@ -243,14 +243,16 @@ def get_parser(self, prog_name):
243243
action="store_const",
244244
const="public",
245245
dest="visibility",
246-
help=_("Set namespace visibility 'public'"),
246+
help=_("Metadef namespace is accessible to the public"),
247247
)
248248
visibility_group.add_argument(
249249
"--private",
250250
action="store_const",
251251
const="private",
252252
dest="visibility",
253-
help=_("Set namespace visibility 'private'"),
253+
help=_(
254+
"Metadef namespace is inaccessible to the public (default)"
255+
),
254256
)
255257
protected_group = parser.add_mutually_exclusive_group()
256258
protected_group.add_argument(
@@ -291,24 +293,24 @@ def take_action(self, parsed_args):
291293
image_client.update_metadef_namespace(namespace, **kwargs)
292294

293295

294-
class ShowMetadefNameSpace(command.ShowOne):
296+
class ShowMetadefNamespace(command.ShowOne):
295297
_description = _("Show a metadef namespace")
296298

297299
def get_parser(self, prog_name):
298300
parser = super().get_parser(prog_name)
299301
parser.add_argument(
300-
"namespace_name",
301-
metavar="<namespace_name>",
302-
help=_("Namespace (name) for the namespace"),
302+
"namespace",
303+
metavar="<namespace>",
304+
help=_("Metadef namespace to show (name)"),
303305
)
304306
return parser
305307

306308
def take_action(self, parsed_args):
307309
image_client = self.app.client_manager.image
308310

309-
namespace_name = parsed_args.namespace_name
311+
namespace = parsed_args.namespace
310312

311-
data = image_client.get_metadef_namespace(namespace_name)
313+
data = image_client.get_metadef_namespace(namespace)
312314
info = _format_namespace(data)
313315

314316
return zip(*sorted(info.items()))

openstackclient/image/v2/metadef_objects.py

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def get_parser(self, prog_name):
5555
parser.add_argument(
5656
"--namespace",
5757
metavar="<namespace>",
58-
help=_("Metadef namespace to create the metadef object in (name)"),
58+
help=_("Metadef namespace to create the object in (name)"),
5959
)
6060
parser.add_argument(
6161
"name",
@@ -81,79 +81,75 @@ def take_action(self, parsed_args):
8181

8282

8383
class ShowMetadefObjects(command.ShowOne):
84-
_description = _(
85-
"Describe a specific metadata definitions object inside a namespace"
86-
)
84+
_description = _("Show a particular metadef object")
8785

8886
def get_parser(self, prog_name):
8987
parser = super().get_parser(prog_name)
9088
parser.add_argument(
91-
"namespace_name",
92-
metavar="<namespace_name>",
93-
help=_("Namespace (name) for the namespace"),
89+
"namespace",
90+
metavar="<namespace>",
91+
help=_("Metadef namespace of the object (name)"),
9492
)
9593
parser.add_argument(
96-
"object_name",
97-
metavar="<object_name>",
98-
help=_("Name of an object."),
94+
"object",
95+
metavar="<object>",
96+
help=_("Metadef object to show"),
9997
)
10098
return parser
10199

102100
def take_action(self, parsed_args):
103101
image_client = self.app.client_manager.image
104102

105-
namespace_name = parsed_args.namespace_name
106-
object_name = parsed_args.object_name
103+
namespace = parsed_args.namespace
104+
object = parsed_args.object
107105

108-
data = image_client.get_metadef_object(object_name, namespace_name)
106+
data = image_client.get_metadef_object(object, namespace)
109107

110108
fields, value = _format_object(data)
111109

112110
return fields, value
113111

114112

115113
class DeleteMetadefObject(command.Command):
116-
_description = _(
117-
"Delete a specific metadata definitions object inside a namespace"
118-
)
114+
_description = _("Delete metadata definitions object(s)")
119115

120116
def get_parser(self, prog_name):
121117
parser = super().get_parser(prog_name)
122118
parser.add_argument(
123-
"namespace_name",
124-
metavar="<namespace_name>",
125-
help=_("Namespace (name) for the namespace"),
119+
"namespace",
120+
metavar="<namespace>",
121+
help=_("Metadef namespace of the object (name)"),
126122
)
127123
parser.add_argument(
128-
"object_name",
129-
metavar="<object_name>",
124+
"objects",
125+
metavar="<object>",
130126
nargs="+",
131-
help=_("Name of an object."),
127+
help=_("Metadef object(s) to delete (name)"),
132128
)
133129
return parser
134130

135131
def take_action(self, parsed_args):
136132
image_client = self.app.client_manager.image
137133

138-
namespace_name = parsed_args.namespace_name
134+
namespace = parsed_args.namespace
139135

140136
result = 0
141-
for i in parsed_args.object_name:
137+
for obj in parsed_args.objects:
142138
try:
143-
object = image_client.get_metadef_object(i, namespace_name)
144-
image_client.delete_metadef_object(object, namespace_name)
139+
object = image_client.get_metadef_object(obj, namespace)
140+
image_client.delete_metadef_object(object, namespace)
145141
except Exception as e:
146142
result += 1
147143
LOG.error(
148144
_(
149145
"Failed to delete object with name or "
150146
"ID '%(object)s': %(e)s"
151147
),
152-
{'object': i, 'e': e},
148+
{'object': obj, 'e': e},
153149
)
154150

155151
if result > 0:
156-
total = len(parsed_args.namespace_name)
152+
total = len(parsed_args.namespace)
157153
msg = _("%(result)s of %(total)s object failed to delete.") % {
158154
'result': result,
159155
'total': total,
@@ -176,10 +172,10 @@ def get_parser(self, prog_name):
176172
def take_action(self, parsed_args):
177173
image_client = self.app.client_manager.image
178174

179-
namespace_name = parsed_args.namespace
175+
namespace = parsed_args.namespace
180176
columns = ['name', 'description']
181177

182-
md_objects = list(image_client.metadef_objects(namespace_name))
178+
md_objects = list(image_client.metadef_objects(namespace))
183179
column_headers = columns
184180
return (
185181
column_headers,

0 commit comments

Comments
 (0)