From c240c44b64ac5bcbbfcc7913f342529ac9803321 Mon Sep 17 00:00:00 2001 From: Madhuri Kumari Date: Fri, 3 Feb 2017 06:19:28 +0000 Subject: [PATCH] Add the OSC 'cluster template list' command There is OSC command support for 'cluster-template-list' but it was not exposed. So this patch adds the command to setup.cfg. Also fix the wrong class name used in the file. Change-Id: Ia3a632ce2cf2b9cca646351902315b03fd0adb69 --- magnumclient/osc/cluster_templates.py | 39 -------------- magnumclient/osc/v1/__init__.py | 0 magnumclient/osc/v1/cluster_templates.py | 65 ++++++++++++++++++++++++ setup.cfg | 1 + 4 files changed, 66 insertions(+), 39 deletions(-) delete mode 100644 magnumclient/osc/cluster_templates.py create mode 100644 magnumclient/osc/v1/__init__.py create mode 100644 magnumclient/osc/v1/cluster_templates.py diff --git a/magnumclient/osc/cluster_templates.py b/magnumclient/osc/cluster_templates.py deleted file mode 100644 index d76ad587..00000000 --- a/magnumclient/osc/cluster_templates.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2016 EasyStack. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# 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 osc_lib.command import command -from osc_lib import utils -from oslo_log import log as logging - - -class ListTemplateCluster(command.ShowOne): - """List TemplateCluster.""" - - log = logging.getLogger(__name__ + ".ListService") - - def get_parser(self, prog_name): - parser = super(ListTemplateCluster, self).get_parser(prog_name) - return parser - - def take_action(self, parsed_args): - self.log.debug("take_action(%s)", parsed_args) - - mag_client = self.app.client_manager.container_infra - columns = ['uuid', 'name'] - services = mag_client.cluster_templates.list() - return ( - columns, - (utils.get_item_properties(s, columns) for s in services) - ) diff --git a/magnumclient/osc/v1/__init__.py b/magnumclient/osc/v1/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/magnumclient/osc/v1/cluster_templates.py b/magnumclient/osc/v1/cluster_templates.py new file mode 100644 index 00000000..e71b6be9 --- /dev/null +++ b/magnumclient/osc/v1/cluster_templates.py @@ -0,0 +1,65 @@ +# Copyright 2016 EasyStack. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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 magnumclient.i18n import _ + +from osc_lib.command import command +from osc_lib import utils +from oslo_log import log as logging + + +class ListTemplateCluster(command.Lister): + """List Cluster Templates.""" + + log = logging.getLogger(__name__ + ".ListTemplateCluster") + + def get_parser(self, prog_name): + parser = super(ListTemplateCluster, self).get_parser(prog_name) + parser.add_argument( + '--limit', + metavar='', + type=int, + help=_('Maximum number of cluster templates to return')) + parser.add_argument( + '--sort-key', + metavar='', + help=_('Column to sort results by')) + parser.add_argument( + '--sort-dir', + metavar='', + choices=['desc', 'asc'], + help=_('Direction to sort. "asc" or "desc".')) + parser.add_argument( + '--fields', + default=None, + metavar='', + help=_('Comma-separated list of fields to display. ' + 'Available fields: uuid, name, coe, image_id, public, ' + 'link, apiserver_port, server_type, tls_disabled, ' + 'registry_enabled' + ) + ) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)", parsed_args) + + mag_client = self.app.client_manager.container_infra + columns = ['uuid', 'name'] + cts = mag_client.cluster_templates.list() + return ( + columns, + (utils.get_item_properties(ct, columns) for ct in cts) + ) diff --git a/setup.cfg b/setup.cfg index f864908d..e09300ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,6 +31,7 @@ openstack.cli.extension = container_infra = magnumclient.osc.plugin openstack.container_infra.v1 = + cluster_template_list = magnumclient.osc.v1.cluster_templates:ListTemplateCluster [build_sphinx] source-dir = doc/source