template list - client side

Change-Id: Ib0a1ad7c18b05714348ba495ca113e73135a45a3
This commit is contained in:
liathartal 2016-06-21 10:06:41 +00:00
parent e14ae69639
commit 4191c746fd
4 changed files with 29 additions and 4 deletions

@ -11,9 +11,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log
from oslo_utils import importutils
LOG = log.getLogger(__name__)
def import_versioned_module(version, submodule=None):
module = 'vitrageclient.v%s' % version

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

@ -12,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from cliff import lister
from cliff import show
from oslo_log import log
from vitrageclient.common.exc import CommandException
from vitrageclient.common import utils
LOG = log.getLogger(__name__)
@ -40,3 +43,18 @@ class TemplateValidate(show.ShowOne):
result = self.app.client.template.validate(path=parsed_args.path)
return self.dict2columns(result)
class TemplateList(lister.Lister):
"""Template list"""
def get_parser(self, prog_name):
parser = super(TemplateList, self).get_parser(prog_name)
return parser
def take_action(self, parsed_args):
templates = self.app.client.template.list()
return utils.list2cols(('name',
'status',
'status details',
'date'), templates)

@ -22,15 +22,19 @@ LOG = log.getLogger(__name__)
class Template(object):
URL = 'v1/template/'
url = 'v1/template/'
def __init__(self, api):
self.api = api
def list(self):
"""Get templates list"""
return self.api.get(self.url).json()
def validate(self, path=None):
"""Template validation
Make sure that the template file is correct in terms of synax
Make sure that the template file is correct in terms of syntax
and content.
It is possible to pass a specific file path in order to validate one
template, or directory path for validation of several templates (the
@ -53,7 +57,7 @@ class Template(object):
params = dict(templates=templates)
return self.api.post(self.URL, json=params).json()
return self.api.post(self.url, json=params).json()
@staticmethod
def load_template_definition(path):