Exemple #1
0
 def invoke(self, *args, **kwargs):
     if any(x in ['create', 'create_chain', 'create_flow_classifier'] for
            x in args):
         return str(uuid.uuid4())
     elif 'execute_workflow' in args:
         mock_execution = mock.Mock()
         mock_execution.id.return_value = \
             "ba6bf017-f6f7-45f1-a280-57b073bf78ea"
         return mock_execution
     elif ('prepare_and_create_workflow' in args and
           'delete' == kwargs['action'] and
           DUMMY_NS_2 == kwargs['kwargs']['ns']['id']):
         raise nfvo.NoTasksException()
     elif ('prepare_and_create_workflow' in args and
           'create' == kwargs['action'] and
           utils.DUMMY_NS_2_NAME == kwargs['kwargs']['ns']['ns']['name']):
         raise nfvo.NoTasksException()
Exemple #2
0
 def prepare_and_create_workflow(self, resource, action,
                                 kwargs, auth_dict=None):
     mistral_client = self.get_mistral_client(auth_dict)
     wg = workflow_generator.WorkflowGenerator(resource, action)
     wg.task(**kwargs)
     if not wg.get_tasks():
         raise nfvo.NoTasksException(resource=resource, action=action)
     definition_yaml = yaml.safe_dump(wg.definition)
     workflow = mistral_client.workflows.create(definition_yaml)
     return {'id': workflow[0].id, 'input': wg.get_input_dict()}