2015-07-19 12:15:04 -06:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
|
|
|
"""Configuration action implementations"""
|
|
|
|
|
2016-06-20 12:37:22 +02:00
|
|
|
from keystoneauth1.loading import base
|
2016-05-13 17:27:12 -05:00
|
|
|
from osc_lib.command import command
|
2015-07-19 12:15:04 -06:00
|
|
|
import six
|
|
|
|
|
2016-06-07 19:16:24 +08:00
|
|
|
from openstackclient.i18n import _
|
2015-09-01 16:43:07 -07:00
|
|
|
|
2015-07-19 12:15:04 -06:00
|
|
|
REDACTED = "<redacted>"
|
|
|
|
|
|
|
|
|
2016-01-10 21:54:53 +09:00
|
|
|
class ShowConfiguration(command.ShowOne):
|
2016-11-13 09:42:09 -05:00
|
|
|
_description = _("Display configuration details")
|
2015-07-19 12:15:04 -06:00
|
|
|
|
|
|
|
def get_parser(self, prog_name):
|
|
|
|
parser = super(ShowConfiguration, self).get_parser(prog_name)
|
|
|
|
mask_group = parser.add_mutually_exclusive_group()
|
|
|
|
mask_group.add_argument(
|
|
|
|
"--mask",
|
|
|
|
dest="mask",
|
|
|
|
action="store_true",
|
|
|
|
default=True,
|
2016-06-07 19:16:24 +08:00
|
|
|
help=_("Attempt to mask passwords (default)"),
|
2015-07-19 12:15:04 -06:00
|
|
|
)
|
|
|
|
mask_group.add_argument(
|
|
|
|
"--unmask",
|
|
|
|
dest="mask",
|
|
|
|
action="store_false",
|
2016-06-07 19:16:24 +08:00
|
|
|
help=_("Show password in clear text"),
|
2015-07-19 12:15:04 -06:00
|
|
|
)
|
|
|
|
return parser
|
|
|
|
|
|
|
|
def take_action(self, parsed_args):
|
|
|
|
|
2016-06-20 12:37:22 +02:00
|
|
|
auth_plg_name = self.app.client_manager.auth_plugin_name
|
|
|
|
secret_opts = [o.dest for o in base.get_plugin_options(auth_plg_name)
|
|
|
|
if o.secret]
|
|
|
|
|
2015-07-19 12:15:04 -06:00
|
|
|
info = self.app.client_manager.get_configuration()
|
|
|
|
for key, value in six.iteritems(info.pop('auth', {})):
|
2016-06-20 12:37:22 +02:00
|
|
|
if parsed_args.mask and key.lower() in secret_opts:
|
2015-07-19 12:15:04 -06:00
|
|
|
value = REDACTED
|
|
|
|
info['auth.' + key] = value
|
|
|
|
return zip(*sorted(six.iteritems(info)))
|