From 26c6730ed7466766828e92ebf582330fec8e6f23 Mon Sep 17 00:00:00 2001 From: "Brad P. Crochet" Date: Tue, 17 Mar 2015 09:34:29 -0400 Subject: [PATCH] Implement undercloud install Change-Id: I7383a278105f76f85f1077e7216345506f094609 --- .../tests/v1/plugin/__init__.py | 0 .../tests/v1/plugin/undercloud.py | 57 +++++++++++++++++++ rdomanager_oscplugin/tests/v1/test_plugin.py | 6 -- rdomanager_oscplugin/v1/plugin/undercloud.py | 3 +- 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 rdomanager_oscplugin/tests/v1/plugin/__init__.py create mode 100644 rdomanager_oscplugin/tests/v1/plugin/undercloud.py diff --git a/rdomanager_oscplugin/tests/v1/plugin/__init__.py b/rdomanager_oscplugin/tests/v1/plugin/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/rdomanager_oscplugin/tests/v1/plugin/undercloud.py b/rdomanager_oscplugin/tests/v1/plugin/undercloud.py new file mode 100644 index 000000000..1b83009bc --- /dev/null +++ b/rdomanager_oscplugin/tests/v1/plugin/undercloud.py @@ -0,0 +1,57 @@ +# Copyright 2015 Red Hat, Inc. +# +# 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 sys + +from rdomanager_oscplugin.tests import base +from rdomanager_oscplugin.tests import fakes +from rdomanager_oscplugin.tests.v1.test_plugin import TestPluginV1 +from rdomanager_oscplugin.v1.plugin import undercloud + +# Load the plugin init module for the plugin list and show commands +import rdomanager_oscplugin.plugin +plugin_name = 'rdomanager_oscplugin' +plugin_client = 'rdomanager_oscplugin.plugin' + + +class FakePluginV1Client(object): + def __init__(self, **kwargs): + self.auth_token = kwargs['token'] + self.management_url = kwargs['endpoint'] + + +class TestUndercloudInstall(TestPluginV1): + + def setUp(self): + super(TestUndercloudInstall, self).setUp() + + self.app.ext_modules = [ + sys.modules[plugin_client], + ] + + # Get the command object to test + self.cmd = plugin.undercloud.InstallPlugin(self.app, None) + + @mock.patch('subprocess.call') + def test_undercloud_install(self, mock_subprocess): + arglist = [] + verifylist = [] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # DisplayCommandBase.take_action() returns two tuples + self.cmd.take_action(parsed_args) + + + mock_subprocess.assert_called_with('instack-install-undercloud') diff --git a/rdomanager_oscplugin/tests/v1/test_plugin.py b/rdomanager_oscplugin/tests/v1/test_plugin.py index 9f333fad0..b0fec9f76 100644 --- a/rdomanager_oscplugin/tests/v1/test_plugin.py +++ b/rdomanager_oscplugin/tests/v1/test_plugin.py @@ -27,8 +27,6 @@ plugin_client = 'rdomanager_oscplugin.plugin' class FakePluginV1Client(object): def __init__(self, **kwargs): - #self.servers = mock.Mock() - #self.servers.resource_class = fakes.FakeResource(None, {}) self.auth_token = kwargs['token'] self.management_url = kwargs['endpoint'] @@ -41,7 +39,3 @@ class TestPluginV1(base.TestCommand): endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN, ) - - # Get a shortcut to the Service Catalog Mock - #self.catalog_mock = self.app.client_manager.identity.service_catalog - #self.catalog_mock.reset_mock() diff --git a/rdomanager_oscplugin/v1/plugin/undercloud.py b/rdomanager_oscplugin/v1/plugin/undercloud.py index 9319eb20b..130ebca67 100644 --- a/rdomanager_oscplugin/v1/plugin/undercloud.py +++ b/rdomanager_oscplugin/v1/plugin/undercloud.py @@ -17,6 +17,7 @@ import logging import six +import subprocess import sys from cliff import command @@ -35,6 +36,6 @@ class InstallPlugin(command.Command): def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) - self.log.debug("To be implemented") + subprocess.call("instack-install-undercloud") return