def __init__(self, auth_type='keystone', **kwargs): req = copy.deepcopy(kwargs) mistral_url = req.get('mistral_url') profile = req.get('profile') if mistral_url and not isinstance(mistral_url, six.string_types): raise RuntimeError('Mistral url should be a string.') auth_handler = auth.get_auth_handler(auth_type) auth_response = auth_handler.authenticate(req) or {} req.update(auth_response) mistral_url = auth_response.get('mistral_url') or mistral_url if not mistral_url: mistral_url = _DEFAULT_MISTRAL_URL if profile: osprofiler_profiler.init(profile) http_client = httpclient.HTTPClient(mistral_url, **req) # Create all resource managers. self.workbooks = workbooks.WorkbookManager(http_client) self.executions = executions.ExecutionManager(http_client) self.tasks = tasks.TaskManager(http_client) self.actions = actions.ActionManager(http_client) self.workflows = workflows.WorkflowManager(http_client) self.cron_triggers = cron_triggers.CronTriggerManager(http_client) self.environments = environments.EnvironmentManager(http_client) self.action_executions = action_executions.ActionExecutionManager( http_client) self.services = services.ServiceManager(http_client) self.members = members.MemberManager(http_client)
def __init__(self, auth_type='keystone', **kwargs): # We get the session at this point, as some instances of session # objects might have mutexes that can't be deep-copied. session = kwargs.pop('session', None) req = copy.deepcopy(kwargs) mistral_url = req.get('mistral_url') profile = req.get('profile') if mistral_url and not isinstance(mistral_url, str): raise RuntimeError('Mistral url should be a string.') # If auth url was provided then we perform an authentication, otherwise # just ignore this step if req.get('auth_url') or req.get('target_auth_url'): auth_handler = auth.get_auth_handler(auth_type) auth_response = auth_handler.authenticate(req, session=session) else: auth_response = {} if session is None: # If the session was None and we're using keystone auth, it will be # created by the auth_handler. session = auth_response.pop('session', None) req.update(auth_response) mistral_url = auth_response.get('mistral_url') or mistral_url if not mistral_url: mistral_url = _DEFAULT_MISTRAL_URL if profile: osprofiler_profiler.init(profile) http_client = httpclient.HTTPClient(mistral_url, session=session, **req) # Create all resource managers. self.workbooks = workbooks.WorkbookManager(http_client) self.executions = executions.ExecutionManager(http_client) self.tasks = tasks.TaskManager(http_client) self.actions = actions.ActionManager(http_client) self.workflows = workflows.WorkflowManager(http_client) self.cron_triggers = cron_triggers.CronTriggerManager(http_client) self.event_triggers = event_triggers.EventTriggerManager(http_client) self.environments = environments.EnvironmentManager(http_client) self.action_executions = action_executions.ActionExecutionManager( http_client) self.services = services.ServiceManager(http_client) self.members = members.MemberManager(http_client) self.code_sources = code_sources.CodeSourceManager(http_client) self.dynamic_actions = dynamic_actions.DynamicActionManager( http_client)
def __init__(self, mistral_url=None, username=None, api_key=None, project_name=None, auth_url=None, project_id=None, endpoint_type='publicURL', service_type='workflowv2', auth_token=None, user_id=None, cacert=None, insecure=False): if mistral_url and not isinstance(mistral_url, six.string_types): raise RuntimeError('Mistral url should be string') if auth_url: (mistral_url, auth_token, project_id, user_id) = (self.authenticate(mistral_url, username, api_key, project_name, auth_url, project_id, endpoint_type, service_type, auth_token, user_id, cacert, insecure)) if not mistral_url: mistral_url = "http://localhost:8989/v2" self.http_client = httpclient.HTTPClient(mistral_url, auth_token, project_id, user_id) # Create all resource managers. self.workbooks = workbooks.WorkbookManager(self) self.executions = executions.ExecutionManager(self) self.tasks = tasks.TaskManager(self) self.actions = actions.ActionManager(self) self.workflows = workflows.WorkflowManager(self) self.cron_triggers = cron_triggers.CronTriggerManager(self) self.environments = environments.EnvironmentManager(self) self.action_executions = action_executions.ActionExecutionManager(self) self.services = services.ServiceManager(self)
def data(TEST): # MistralActions TEST.mistralclient_actions = test_data_utils.TestDataContainer() action_1 = actions.Action( actions.ActionManager(None), {'name': 'a', 'is_system': True, 'input': 'param1', 'description': 'my cool action', 'tags': ['test'], 'created_at': '1', 'updated_at': '1' } ) TEST.mistralclient_actions.add(action_1) # MistralExecutions TEST.mistralclient_executions = test_data_utils.TestDataContainer() execution_1 = executions.Execution( executions.ExecutionManager(None), {'id': '123', 'workflow_name': 'my_wf', 'description': '', 'state': 'RUNNING', 'input': { 'person': { 'first_name': 'John', 'last_name': 'Doe' } }} ) TEST.mistralclient_executions.add(execution_1) # Tasks TEST.mistralclient_tasks = test_data_utils.TestDataContainer() task_1 = tasks.Task( tasks.TaskManager(None), {'id': '1', 'workflow_execution_id': '123', 'name': 'my_task', 'workflow_name': 'my_wf', 'state': 'RUNNING', 'type': 'ACTION', 'tags': ['deployment', 'demo'], 'result': {'some': 'result'}}) TEST.mistralclient_tasks.add(task_1) # Workbooks TEST.mistralclient_workbooks = test_data_utils.TestDataContainer() workbook_1 = workbooks.Workbook( workbooks.WorkbookManager(None), {'name': 'a', 'tags': ['a', 'b'], 'created_at': '1', 'updated_at': '1', 'definition': WB_DEF} ) TEST.mistralclient_workbooks.add(workbook_1) # Workflows TEST.mistralclient_workflows = test_data_utils.TestDataContainer() workflow_1 = workflows.Workflow( workflows.WorkflowManager(None), {'name': 'a', 'tags': ['a', 'b'], 'input': 'param', 'created_at': '1', 'updated_at': '1', 'definition': WF_DEF} ) TEST.mistralclient_workflows.add(workflow_1) # MistralActionsExecutions TEST.mistralclient_action_executions = test_data_utils.TestDataContainer() action_executions_1 = action_executions.ActionExecution( action_executions.ActionExecutionManager(None), {'id': '1', 'name': 'a', 'tags': ['a', 'b'], 'workflow_name': 'my work flow', 'task_execution_id': '1', 'task_name': 'b', 'description': '', 'created_at': '1', 'updated_at': '1', 'accepted': True, 'state': 'RUNNING' } ) TEST.mistralclient_action_executions.add(action_executions_1) # MistralCronTriggers TEST.mistralclient_cron_triggers = test_data_utils.TestDataContainer() cron_triggers_1 = cron_triggers.CronTrigger( cron_triggers.CronTriggerManager(None), {'id': '1', 'name': 'a', 'workflow_name': 'my work flow', 'pattern': '', 'next_execution_time': '', 'remaining_executions': '', 'first_execution_time': '', 'created_at': '1', 'updated_at': '1' }) TEST.mistralclient_cron_triggers.add(cron_triggers_1)
def __init__(self, mistral_url=None, username=None, api_key=None, project_name=None, auth_url=None, project_id=None, endpoint_type='publicURL', service_type='workflowv2', auth_token=None, user_id=None, cacert=None, insecure=False, profile=None, auth_type=auth_types.KEYSTONE, client_id=None, client_secret=None, target_username=None, target_api_key=None, target_project_name=None, target_auth_url=None, target_project_id=None, target_auth_token=None, target_user_id=None, target_cacert=None, target_insecure=False, **kwargs): if mistral_url and not isinstance(mistral_url, six.string_types): raise RuntimeError('Mistral url should be a string.') if auth_url: if auth_type == auth_types.KEYSTONE: (mistral_url, auth_token, project_id, user_id) = ( keystone.authenticate( mistral_url, username, api_key, project_name, auth_url, project_id, endpoint_type, service_type, auth_token, user_id, cacert, insecure ) ) elif auth_type == auth_types.KEYCLOAK_OIDC: auth_token = keycloak.authenticate( auth_url, client_id, client_secret, project_name, username, api_key, auth_token, cacert, insecure ) # In case of KeyCloak OpenID Connect we can treat project # name and id in the same way because KeyCloak realm is # essentially a different OpenID Connect Issuer which in # KeyCloak is represented just as a URL path component # (see http://openid.net/specs/openid-connect-core-1_0.html). project_id = project_name else: raise RuntimeError( 'Invalid authentication type [value=%s, valid_values=%s]' % (auth_type, auth_types.ALL) ) if not mistral_url: mistral_url = _DEFAULT_MISTRAL_URL if profile: osprofiler_profiler.init(profile) if target_auth_url: keystone.authenticate( mistral_url, target_username, target_api_key, target_project_name, target_auth_url, target_project_id, endpoint_type, service_type, target_auth_token, target_user_id, target_cacert, target_insecure ) http_client = httpclient.HTTPClient( mistral_url, auth_token, project_id, user_id, cacert=cacert, insecure=insecure, target_token=target_auth_token, target_auth_uri=target_auth_url, **kwargs ) # Create all resource managers. self.workbooks = workbooks.WorkbookManager(http_client) self.executions = executions.ExecutionManager(http_client) self.tasks = tasks.TaskManager(http_client) self.actions = actions.ActionManager(http_client) self.workflows = workflows.WorkflowManager(http_client) self.cron_triggers = cron_triggers.CronTriggerManager(http_client) self.environments = environments.EnvironmentManager(http_client) self.action_executions = action_executions.ActionExecutionManager( http_client) self.services = services.ServiceManager(http_client) self.members = members.MemberManager(http_client)