Beispiel #1
0
    def initialize_app(self, argv):
        self.LOG.debug('initialize_app')
        super(HOSTCLI, self).initialize_app(argv)
        try:
            self.cloud_config = cloud_config.OSC_Config(
                override_defaults={
                    'interface': None,
                    'auth_type': self._auth_type,
                },
                pw_func=shell.prompt_for_password,
            )
        except (IOError, OSError):
            self.log.critical("Could not read clouds.yaml configuration file")
            self.print_help_if_requested()
            raise
        if not self.options.debug:
            self.options.debug = None

        setattr(
            clientmanager.ClientManager, resthandler.API_NAME,
            clientmanager.ClientCache(getattr(resthandler, 'make_instance')))
        self.client_manager = clientmanager.ClientManager(
            cli_options=self.cloud,
            api_version=self.api_version,
            pw_func=shell.prompt_for_password,
        )
Beispiel #2
0
    def initialize_app(self, argv):
        """Global app init bits:

        * set up API versions
        * validate authentication info
        * authenticate against Identity if requested
        """

        # Parent __init__ parses argv into self.options
        super(OpenStackShell, self).initialize_app(argv)
        self.log.info("START with options: %s",
                      strutils.mask_password(" ".join(self.command_options)))
        self.log.debug("options: %s", strutils.mask_password(self.options))

        # Callout for stuff between superclass init and o-c-c
        self._final_defaults()

        # Do configuration file handling
        try:
            self.cloud_config = cloud_config.OSC_Config(
                pw_func=prompt_for_password,
                override_defaults={
                    'interface': None,
                    'auth_type': self._auth_type,
                },
            )
        except (IOError, OSError) as e:
            self.log.critical("Could not read clouds.yaml configuration file")
            self.print_help_if_requested()
            raise e

        # TODO(thowe): Change cliff so the default value for debug
        # can be set to None.
        if not self.options.debug:
            self.options.debug = None

        # NOTE(dtroyer): Need to do this with validate=False to defer the
        #                auth plugin handling to ClientManager.setup_auth()
        self.cloud = self.cloud_config.get_one(
            cloud=self.options.cloud,
            argparse=self.options,
            validate=False,
        )

        self.log_configurator.configure(self.cloud)
        self.dump_stack_trace = self.log_configurator.dump_trace
        self.log.debug("defaults: %s", self.cloud_config.defaults)
        self.log.debug("cloud cfg: %s",
                       strutils.mask_password(self.cloud.config))

        # Callout for stuff between o-c-c and ClientManager
        # self._initialize_app_2(self.options)

        self._load_plugins()

        self._load_commands()

        # Handle deferred help and exit
        self.print_help_if_requested()

        self.client_manager = clientmanager.ClientManager(
            cli_options=self.cloud,
            api_version=self.api_version,
            pw_func=prompt_for_password,
        )