python-tripleoclient/tripleoclient/v1/overcloud_credentials.py
Dougal Matthews 4da6ecdba6 Add a new command to get the overcloudrc files
If a user deploys via the GUI, then this file wont automatically be
created. We can now create it via a Mistral action - this command
provides CLI users a way to call that action and save the file.

While adding tests a typo was spotted in utils.py, this is also resolved
by this patch and covered by the tests.

Change-Id: I7808cd2c43a95bbb154ec6c6f77896b97551e354
2017-04-03 12:57:00 +00:00

44 lines
1.7 KiB
Python

# 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 logging
from osc_lib.command import command
from tripleoclient import utils
from tripleoclient.workflows import deployment
class OvercloudCredentials(command.Command):
"""Create the overcloudrc and overcloudrc.v3 files"""
log = logging.getLogger(__name__ + ".OvercloudCredentials")
def get_parser(self, prog_name):
parser = super(OvercloudCredentials, self).get_parser(prog_name)
parser.add_argument('plan', help=("The name of the plan you want to "
"create rc files for."))
parser.add_argument('--directory', default=".", nargs='?', help=(
"The directory to create the rc files. Defaults to the current "
"directory."))
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
workflow_engine = self.app.client_manager.workflow_engine
plan = parsed_args.plan
dir_ = parsed_args.directory
overcloudrcs = deployment.overcloudrc(workflow_engine, container=plan)
utils.write_overcloudrc(plan, overcloudrcs, dir_)