X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=client%2Fescalatorclient%2Fv1%2Fshell.py;h=501f01be1878f8504b4787595011c439c069e936;hb=4b445f24d664d0ed720293aeeaa5a6a195e51d06;hp=ab02c9ac23a3b4a5f26dc980e49568c53a99b8e4;hpb=71d4f906c1a52f5dcba114ff8aa70148dafffd24;p=escalator.git diff --git a/client/escalatorclient/v1/shell.py b/client/escalatorclient/v1/shell.py index ab02c9a..501f01b 100644 --- a/client/escalatorclient/v1/shell.py +++ b/client/escalatorclient/v1/shell.py @@ -17,8 +17,10 @@ from __future__ import print_function import copy import functools -from oslo.utils import strutils +from oslo_utils import strutils import escalatorclient.v1.versions +import escalatorclient.v1.clusters +import escalatorclient.v1.update from escalatorclient.common import utils _bool_strict = functools.partial(strutils.bool_from_string, strict=True) @@ -82,3 +84,82 @@ def do_cluster_version_list(dc, args): 'checksum', 'description', 'status', 'VERSION_PATCH'] utils.print_list(versions, columns) + + +@utils.arg('--name', metavar='', + help='Filter version to those that have this name.') +@utils.arg('--status', metavar='', + help='Filter version status.') +@utils.arg('--type', metavar='', + help='Filter by type.') +@utils.arg('--version', metavar='', + help='Filter by version number.') +@utils.arg('--page-size', metavar='', default=None, type=int, + help='Number to request in each paginated request.') +@utils.arg('--sort-key', default='name', + choices=escalatorclient.v1.versions.SORT_KEY_VALUES, + help='Sort version list by specified field.') +@utils.arg('--sort-dir', default='asc', + choices=escalatorclient.v1.versions.SORT_DIR_VALUES, + help='Sort version list in specified direction.') +def do_cluster_list(gc, args): + """List clusters you can access.""" + filter_keys = ['name'] + filter_items = [(key, getattr(args, key)) for key in filter_keys] + filters = dict([item for item in filter_items if item[1] is not None]) + + kwargs = {'filters': filters} + if args.page_size is not None: + kwargs['page_size'] = args.page_size + + kwargs['sort_key'] = args.sort_key + kwargs['sort_dir'] = args.sort_dir + + clusters = gc.clusters.list(**kwargs) + + columns = ['ID', 'Name', 'Description', 'Nodes', 'Networks', + 'Auto_scale', 'Use_dns', 'Status'] + utils.print_list(clusters, columns) + + +@utils.arg('id', metavar='', + help='Filter cluster to those that have this id.') +def do_cluster_detail(gc, args): + """List cluster you can access.""" + filter_keys = ['id'] + filter_items = [(key, getattr(args, key)) for key in filter_keys] + filters = dict([item for item in filter_items if item[1] is not None]) + fields = dict(filter(lambda x: x[1] is not None, vars(args).items())) + kwargs = {'filters': filters} + if filters: + cluster = utils.find_resource(gc.clusters, fields.pop('id')) + _escalator_show(cluster) + else: + cluster = gc.clusters.list(**kwargs) + columns = ['ID', 'Name', 'Description', 'Nodes', + 'Networks', 'Auto_scale', 'Use_dns'] + utils.print_list(cluster, columns) + + +@utils.arg('cluster_id', metavar='', + help='The cluster ID to update os and TECS.') +@utils.arg('--hosts', metavar='', nargs='+', + help='The host ID to update') +@utils.arg('--update-object', metavar='', + help='update object:vplat or tecs or zenic......') +@utils.arg('--version-id', metavar='', + help='if not patch, update version id is used to update.') +@utils.arg('--version-patch-id', metavar='', + help='if update version patch, version patch id is needed') +@utils.arg('--update-script', metavar='', + help='update script in /var/lib/daisy/os') +def do_update(gc, args): + """update TECS.""" + fields = dict(filter(lambda x: x[1] is not None, vars(args).items())) + + # Filter out values we can't use + CREATE_PARAMS = escalatorclient.v1.update.CREATE_PARAMS + fields = dict(filter(lambda x: x[0] in CREATE_PARAMS, fields.items())) + + update = gc.update.update(**fields) + _escalator_show(update)