Merge "add capsule describe"
This commit is contained in:
commit
509f4d17f6
@ -104,3 +104,9 @@ class CapsuleManager(base.Manager):
|
||||
def delete(self, id, force):
|
||||
return self._delete(self._path(id),
|
||||
qparams={'force': force})
|
||||
|
||||
def describe(self, id):
|
||||
try:
|
||||
return self._list(self._path(id))[0]
|
||||
except IndexError:
|
||||
return None
|
||||
|
@ -12,6 +12,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import yaml
|
||||
|
||||
from zunclient.common import cliutils as utils
|
||||
from zunclient.common import template_utils
|
||||
from zunclient.common import utils as zun_utils
|
||||
@ -93,3 +96,25 @@ def do_capsule_delete(cs, args):
|
||||
except Exception as e:
|
||||
print("Delete for capsule %(capsule)s failed: %(e)s" %
|
||||
{'capsule': capsule, 'e': e})
|
||||
|
||||
|
||||
@utils.arg('capsule',
|
||||
metavar='<capsule>',
|
||||
help='ID or name of the capsule to show.')
|
||||
@utils.arg('-f', '--format',
|
||||
metavar='<format>',
|
||||
action='store',
|
||||
choices=['json', 'yaml', 'table'],
|
||||
default='table',
|
||||
help='Print representation of the capsule. '
|
||||
'The choices of the output format is json,table,yaml. '
|
||||
'Defaults to table. ')
|
||||
def do_capsule_describe(cs, args):
|
||||
"""Show details of a capsule."""
|
||||
capsule = cs.capsules.describe(args.capsule)
|
||||
if args.format == 'json':
|
||||
print(json.dumps(capsule._info, indent=4, sort_keys=True))
|
||||
elif args.format == 'yaml':
|
||||
print(yaml.safe_dump(capsule._info, default_flow_style=False))
|
||||
elif args.format == 'table':
|
||||
_show_capsule(capsule)
|
||||
|
Loading…
Reference in New Issue
Block a user