def initialize_app(self, argv): self._clear_shell_commands() ver = client.determine_client_version(self.options.mistral_version) self._set_shell_commands(self._get_commands(ver)) # bash-completion and help messages should not require client creation need_client = not (('bash-completion' in argv) or ('help' in argv) or ('-h' in argv) or ('--help' in argv) or not argv) # Set default for auth_url if not supplied. The default is not # set at the parser to support use cases where auth is not enabled. # An example use case would be a developer's environment. if not self.options.auth_url: if self.options.password or self.options.token: self.options.auth_url = 'http://localhost:35357/v3' if (self.options.auth_type == 'keystone' and not self.options.auth_url.endswith("/v2.0")): # Assume that keystone V3 is used and try to be more user-friendly, # i.e provide default values for domains if (not self.options.project_domain_id and not self.options.project_domain_name): self.options.project_domain_id = "default" if (not self.options.user_domain_id and not self.options.user_domain_name): self.options.user_domain_id = "default" if (not self.options.target_project_domain_id and not self.options.target_project_domain_name): self.options.target_project_domain_id = "default" if (not self.options.target_user_domain_id and not self.options.target_user_domain_name): self.options.target_user_domain_id = "default" if self.options.auth_url and not self.options.token: if not self.options.username: raise exe.IllegalArgumentException( ("You must provide a username " "via --os-username env[OS_USERNAME]")) if not self.options.password: raise exe.IllegalArgumentException( ("You must provide a password " "via --os-password env[OS_PASSWORD]")) self.client = self._create_client() if need_client else None # Adding client_manager variable to make mistral client work with # unified OpenStack client. ClientManager = type('ClientManager', (object, ), dict(workflow_engine=self.client)) self.client_manager = ClientManager()
def initialize_app(self, argv): self._clear_shell_commands() ver = client.determine_client_version(self.options.mistral_version) self._set_shell_commands(self._get_commands(ver)) do_help = ('help' in argv) or ('-h' in argv) or not argv # Set default for auth_url if not supplied. The default is not # set at the parser to support use cases where auth is not enabled. # An example use case would be a developer's environment. if not self.options.auth_url: if self.options.password or self.options.token: self.options.auth_url = 'http://localhost:35357/v3' # bash-completion should not require authentification. if do_help or ('bash-completion' in argv): self.options.auth_url = None if self.options.auth_url and not self.options.token: if not self.options.username: raise exe.IllegalArgumentException( ("You must provide a username " "via --os-username env[OS_USERNAME]")) if not self.options.password: raise exe.IllegalArgumentException( ("You must provide a password " "via --os-password env[OS_PASSWORD]")) kwargs = { 'cert': self.options.os_cert, 'key': self.options.os_key, 'user_domain_name': self.options.user_domain_name, 'project_domain_name': self.options.project_domain_name } self.client = client.client( mistral_url=self.options.mistral_url, username=self.options.username, api_key=self.options.password, project_name=self.options.tenant_name, auth_url=self.options.auth_url, project_id=self.options.tenant_id, endpoint_type=self.options.endpoint_type, service_type=self.options.service_type, auth_token=self.options.token, cacert=self.options.os_cacert, insecure=self.options.insecure, profile=self.options.profile, auth_type=self.options.auth_type, client_id=self.options.client_id, client_secret=self.options.client_secret, target_username=self.options.target_username, target_api_key=self.options.target_password, target_project_name=self.options.target_tenant_name, target_auth_url=self.options.target_auth_url, target_project_id=self.options.target_tenant_id, target_auth_token=self.options.target_token, target_cacert=self.options.target_cacert, target_region_name=self.options.target_region_name, target_insecure=self.options.target_insecure, **kwargs) # Adding client_manager variable to make mistral client work with # unified OpenStack client. ClientManager = type('ClientManager', (object, ), dict(workflow_engine=self.client)) self.client_manager = ClientManager()