Add 'openstack overcloud plan list' command

Change-Id: I29bb9854985fce0d7b3da195d8971a9d7c0def6c
Implements: blueprint tripleo-ui-mistral-refactoring
Depends-On: Ie2d1109d4ca6c04a5e06246e753006a7331041ea
This commit is contained in:
Julie Pichon 2016-08-02 17:43:10 +01:00
parent e842085935
commit 8d303e43ca
3 changed files with 90 additions and 0 deletions

View File

@ -69,6 +69,7 @@ openstack.tripleoclient.v1 =
overcloud_node_delete = tripleoclient.v1.overcloud_node:DeleteNode
overcloud_node_introspect = tripleoclient.v1.overcloud_node:IntrospectNode
overcloud_node_provide = tripleoclient.v1.overcloud_node:ProvideNode
overcloud_plan_list = tripleoclient.v1.overcloud_plan:ListPlans
overcloud_profiles_match = tripleoclient.v1.overcloud_profiles:MatchProfiles
overcloud_profiles_list = tripleoclient.v1.overcloud_profiles:ListProfiles
overcloud_update_stack = tripleoclient.v1.overcloud_update:UpdateOvercloud

View File

@ -0,0 +1,48 @@
# 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.
import mock
from openstackclient.tests import utils
from tripleoclient.v1 import overcloud_plan
class TestOvercloudPlanList(utils.TestCommand):
def setUp(self):
super(TestOvercloudPlanList, self).setUp()
self.cmd = overcloud_plan.ListPlans(self.app, None)
self.app.client_manager.workflow_engine = mock.Mock()
self.workflow = self.app.client_manager.workflow_engine
def test_list_empty(self):
self.workflow.action_executions.create.return_value = (
mock.Mock(output='{"result": []}'))
result = self.cmd.take_action(None)
self.workflow.action_executions.create.assert_called_once_with(
'tripleo.list_plans')
self.assertEqual(0, len(result[1]))
def test_list(self):
self.workflow.action_executions.create.return_value = (
mock.Mock(output='{"result": ["test-plan-1", "test-plan-2"]}'))
result = self.cmd.take_action(None)
self.workflow.action_executions.create.assert_called_once_with(
'tripleo.list_plans')
self.assertEqual(1, len(result[0]))
self.assertEqual([('test-plan-1',), ('test-plan-2',)], result[1])

View File

@ -0,0 +1,41 @@
# 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.
import json
import logging
from cliff import lister
class ListPlans(lister.Lister):
"""List overcloud deployment plans"""
log = logging.getLogger(__name__ + ".ListPlans")
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
workflow_client = self.app.client_manager.workflow_engine
execution = workflow_client.action_executions.create(
'tripleo.list_plans')
try:
json_results = json.loads(execution.output)['result']
except Exception:
self.log.exception("Error parsing JSON %s", execution.output)
json_results = []
result = []
for r in json_results:
result.append((r,))
return (("Plan Name",), result)