add template show api

Change-Id: If84fea76667acf0735d38adf0073a53cb5f4775d
This commit is contained in:
liathartal 2016-07-03 11:40:16 +00:00
parent c046551caa
commit 55a21d2fd8
3 changed files with 26 additions and 1 deletions

View File

@ -47,6 +47,7 @@ class VitrageCommandManager(commandmanager.CommandManager):
'rca show': rca.RcaShow,
'template validate': template.TemplateValidate,
'template list': template.TemplateList,
'template show': template.TemplateShow,
}
def load_commands(self, namespace):

View File

@ -54,7 +54,25 @@ class TemplateList(lister.Lister):
def take_action(self, parsed_args):
templates = self.app.client.template.list()
return utils.list2cols(('name',
return utils.list2cols(('uuid',
'name',
'status',
'status details',
'date'), templates)
class TemplateShow(show.ShowOne):
"""Template show"""
def get_parser(self, prog_name):
parser = super(TemplateShow, self).get_parser(prog_name)
parser.add_argument('uuid', help='Template UUID')
return parser
def formatter_default(self):
return 'json'
def take_action(self, parsed_args):
uuid = parsed_args.uuid
template = self.app.client.template.show(uuid=uuid)
return self.dict2columns(template)

View File

@ -31,6 +31,12 @@ class Template(object):
"""Get templates list"""
return self.api.get(self.url).json()
def show(self, uuid):
"""Show template content"""
url = self.url + uuid
return self.api.get(url).json()
def validate(self, path=None):
"""Template validation