Ejemplo n.º 1
0
    def setUpClass(cls):
        super(TestActionExecutionService, cls).setUpClass()
        cls.runner = RunnerTypeAPI(**RUNNER)
        cls.runnerdb = RunnerType.add_or_update(
            RunnerTypeAPI.to_model(cls.runner))

        runner_api = RunnerTypeAPI(**RUNNER_ACTION_CHAIN)
        RunnerType.add_or_update(RunnerTypeAPI.to_model(runner_api))

        cls.actions = {
            ACTION['name']:
            ActionAPI(**ACTION),
            ACTION_WORKFLOW['name']:
            ActionAPI(**ACTION_WORKFLOW),
            ACTION_OVR_PARAM['name']:
            ActionAPI(**ACTION_OVR_PARAM),
            ACTION_OVR_PARAM_MUTABLE['name']:
            ActionAPI(**ACTION_OVR_PARAM_MUTABLE),
            ACTION_OVR_PARAM_IMMUTABLE['name']:
            ActionAPI(**ACTION_OVR_PARAM_IMMUTABLE),
            ACTION_OVR_PARAM_BAD_ATTR['name']:
            ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR),
            ACTION_OVR_PARAM_BAD_ATTR_NOOP['name']:
            ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR_NOOP)
        }

        cls.actiondbs = {
            name: Action.add_or_update(ActionAPI.to_model(action))
            for name, action in six.iteritems(cls.actions)
        }

        cls.container = RunnerContainer()
Ejemplo n.º 2
0
    def setUpClass(cls):
        super(TestActionAPIValidator, cls).setUpClass()

        runner_api_dict = fixture.ARTIFACTS['runners']['run-local']
        runner_api = RunnerTypeAPI(**runner_api_dict)
        runner_model = RunnerTypeAPI.to_model(runner_api)

        RunnerType.add_or_update(runner_model)
Ejemplo n.º 3
0
    def setUpClass(cls):
        super(TestActionAPIValidator, cls).setUpClass()

        runner_api_dict = fixture.ARTIFACTS['runners']['run-local']
        runner_api = RunnerTypeAPI(**runner_api_dict)
        runner_model = RunnerTypeAPI.to_model(runner_api)

        RunnerType.add_or_update(runner_model)
    def setUpClass(cls):
        super(SchedulerTest, cls).setUpClass()

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))
    def setUpClass(cls):
        super(DSLTransformTestCase, cls).setUpClass()

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))
Ejemplo n.º 6
0
    def setUpClass(cls):
        super(MistralValidationControllerTest, cls).setUpClass()

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))
Ejemplo n.º 7
0
    def setUpClass(cls):
        super(DSLTransformTestCase, cls).setUpClass()
        runners_registrar.register_runner_types()

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))
Ejemplo n.º 8
0
    def setUpClass(cls):
        super(MistralValidationTest, cls).setUpClass()

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))

        cls.validator = wf_validation_utils.get_validator()
Ejemplo n.º 9
0
    def setUpClass(cls):
        super(MistralValidationTest, cls).setUpClass()

        for _, fixture in six.iteritems(FIXTURES["runners"]):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES["actions"]):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))

        cls.validator = wf_validation_utils.get_validator()
Ejemplo n.º 10
0
    def put(self, runner_type_api, name_or_id, requester_user):
        # Note: We only allow "enabled" attribute of the runner to be changed
        runner_type_db = self._get_by_name_or_id(name_or_id=name_or_id)

        permission_type = PermissionType.RUNNER_MODIFY
        rbac_utils.assert_user_has_resource_db_permission(user_db=requester_user,
                                                          resource_db=runner_type_db,
                                                          permission_type=permission_type)

        old_runner_type_db = runner_type_db
        LOG.debug('PUT /runnertypes/ lookup with id=%s found object: %s', name_or_id,
                  runner_type_db)

        try:
            if runner_type_api.id and runner_type_api.id != name_or_id:
                LOG.warning('Discarding mismatched id=%s found in payload and using uri_id=%s.',
                            runner_type_api.id, name_or_id)

            runner_type_db.enabled = runner_type_api.enabled
            runner_type_db = RunnerType.add_or_update(runner_type_db)
        except (ValidationError, ValueError) as e:
            LOG.exception('Validation failed for runner type data=%s', runner_type_api)
            abort(http_client.BAD_REQUEST, six.text_type(e))
            return

        extra = {'old_runner_type_db': old_runner_type_db, 'new_runner_type_db': runner_type_db}
        LOG.audit('Runner Type updated. RunnerType.id=%s.' % (runner_type_db.id), extra=extra)
        runner_type_api = RunnerTypeAPI.from_model(runner_type_db)
        return runner_type_api
Ejemplo n.º 11
0
    def put(self, name_or_id, runner_type_api):
        # Note: We only allow "enabled" attribute of the runner to be changed
        runner_type_db = self._get_by_name_or_id(name_or_id=name_or_id)
        old_runner_type_db = runner_type_db
        LOG.debug('PUT /runnertypes/ lookup with id=%s found object: %s',
                  name_or_id, runner_type_db)

        try:
            if runner_type_api.id and runner_type_api.id != name_or_id:
                LOG.warning(
                    'Discarding mismatched id=%s found in payload and using uri_id=%s.',
                    runner_type_api.id, name_or_id)

            runner_type_db.enabled = runner_type_api.enabled
            runner_type_db = RunnerType.add_or_update(runner_type_db)
        except (ValidationError, ValueError) as e:
            LOG.exception('Validation failed for runner type data=%s',
                          runner_type_api)
            pecan.abort(http_client.BAD_REQUEST, str(e))
            return

        extra = {
            'old_runner_type_db': old_runner_type_db,
            'new_runner_type_db': runner_type_db
        }
        LOG.audit('Runner Type updated. RunnerType.id=%s.' %
                  (runner_type_db.id),
                  extra=extra)
        runner_type_api = RunnerTypeAPI.from_model(runner_type_db)
        return runner_type_api
Ejemplo n.º 12
0
def register_runner(runner_type, experimental):
    # For backward compatibility reasons, we also register runners under the old names
    runner_names = [runner_type['name']] + runner_type.get('aliases', [])
    for runner_name in runner_names:
        runner_type['name'] = runner_name
        runner_experimental = runner_type.get('experimental', False)

        if runner_experimental and not experimental:
            LOG.debug('Skipping experimental runner "%s"' % (runner_name))
            continue

        # Remove additional, non db-model attributes
        non_db_attributes = ['experimental', 'aliases']
        for attribute in non_db_attributes:
            if attribute in runner_type:
                del runner_type[attribute]

        try:
            runner_type_db = get_runnertype_by_name(runner_name)
            update = True
        except StackStormDBObjectNotFoundError:
            runner_type_db = None
            update = False

        # Note: We don't want to overwrite "enabled" attribute which is already in the database
        # (aka we don't want to re-enable runner which has been disabled by the user)
        if runner_type_db and runner_type_db['enabled'] != runner_type[
                'enabled']:
            runner_type['enabled'] = runner_type_db['enabled']

        # If package is not provided, assume it's the same as module name for backward
        # compatibility reasons
        if not runner_type.get('runner_package', None):
            runner_type['runner_package'] = runner_type['runner_module']

        runner_type_api = RunnerTypeAPI(**runner_type)
        runner_type_api.validate()
        runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

        if runner_type_db:
            runner_type_model.id = runner_type_db.id

        try:

            runner_type_db = RunnerType.add_or_update(runner_type_model)

            extra = {'runner_type_db': runner_type_db}
            if update:
                LOG.audit('RunnerType updated. RunnerType %s',
                          runner_type_db,
                          extra=extra)
            else:
                LOG.audit('RunnerType created. RunnerType %s',
                          runner_type_db,
                          extra=extra)
        except Exception:
            LOG.exception('Unable to register runner type %s.',
                          runner_type['name'])
            return 0
    return 1
Ejemplo n.º 13
0
 def setup_runner(cls):
     test_runner = {
         'name': 'test-runner',
         'description': 'A test runner.',
         'enabled': True,
         'runner_parameters': {
             'runnerstr': {
                 'description': 'Foo str param.',
                 'type': 'string',
                 'default': 'defaultfoo'
             },
             'runnerint': {
                 'description': 'Foo int param.',
                 'type': 'number'
             },
             'runnerdummy': {
                 'description': 'Dummy param.',
                 'type': 'string',
                 'default': 'runnerdummy'
             }
         },
         'runner_module': 'tests.test_runner'
     }
     runnertype_api = RunnerTypeAPI(**test_runner)
     ActionDBUtilsTestCase.runnertype_db = RunnerType.add_or_update(
         RunnerTypeAPI.to_model(runnertype_api))
Ejemplo n.º 14
0
 def setUpClass(cls):
     super(TestActionExecutionService, cls).setUpClass()
     cls.runner = RunnerTypeAPI(**RUNNER)
     cls.runnerdb = RunnerType.add_or_update(RunnerTypeAPI.to_model(cls.runner))
     cls.action = ActionAPI(**ACTION)
     cls.actiondb = Action.add_or_update(ActionAPI.to_model(cls.action))
     cls.container = RunnerContainer()
Ejemplo n.º 15
0
    def put(self, runner_type_api, name_or_id, requester_user):
        # Note: We only allow "enabled" attribute of the runner to be changed
        runner_type_db = self._get_by_name_or_id(name_or_id=name_or_id)

        permission_type = PermissionType.RUNNER_MODIFY
        rbac_utils = get_rbac_backend().get_utils_class()
        rbac_utils.assert_user_has_resource_db_permission(user_db=requester_user,
                                                          resource_db=runner_type_db,
                                                          permission_type=permission_type)

        old_runner_type_db = runner_type_db
        LOG.debug('PUT /runnertypes/ lookup with id=%s found object: %s', name_or_id,
                  runner_type_db)

        try:
            if runner_type_api.id and runner_type_api.id != name_or_id:
                LOG.warning('Discarding mismatched id=%s found in payload and using uri_id=%s.',
                            runner_type_api.id, name_or_id)

            runner_type_db.enabled = runner_type_api.enabled
            runner_type_db = RunnerType.add_or_update(runner_type_db)
        except (ValidationError, ValueError) as e:
            LOG.exception('Validation failed for runner type data=%s', runner_type_api)
            abort(http_client.BAD_REQUEST, six.text_type(e))
            return

        extra = {'old_runner_type_db': old_runner_type_db, 'new_runner_type_db': runner_type_db}
        LOG.audit('Runner Type updated. RunnerType.id=%s.' % (runner_type_db.id), extra=extra)
        runner_type_api = RunnerTypeAPI.from_model(runner_type_db)
        return runner_type_api
Ejemplo n.º 16
0
 def setup_runner(cls):
     test_runner = {
         "name": "test-runner",
         "description": "A test runner.",
         "enabled": True,
         "runner_parameters": {
             "runnerstr": {
                 "description": "Foo str param.",
                 "type": "string",
                 "default": "defaultfoo",
             },
             "runnerint": {
                 "description": "Foo int param.",
                 "type": "number"
             },
             "runnerdummy": {
                 "description": "Dummy param.",
                 "type": "string",
                 "default": "runnerdummy",
             },
         },
         "runner_module": "tests.test_runner",
     }
     runnertype_api = RunnerTypeAPI(**test_runner)
     ActionDBUtilsTestCase.runnertype_db = RunnerType.add_or_update(
         RunnerTypeAPI.to_model(runnertype_api))
 def setUpClass(cls):
     super(TestActionExecutionService, cls).setUpClass()
     cls.runner = RunnerTypeAPI(**RUNNER)
     cls.runnerdb = RunnerType.add_or_update(RunnerTypeAPI.to_model(cls.runner))
     cls.action = ActionAPI(**ACTION)
     cls.actiondb = Action.add_or_update(ActionAPI.to_model(cls.action))
     cls.container = RunnerContainer()
Ejemplo n.º 18
0
 def setUpClass(cls):
     super(ActionParamsUtilsTest, cls).setUpClass()
     cls.runnertype = RunnerTypeAPI(
         **FIXTURES['runners']['testrunner1.yaml'])
     cls.runnertype_db = RunnerType.add_or_update(
         RunnerTypeAPI.to_model(cls.runnertype))
     cls.action = ActionAPI(**FIXTURES['actions']['action1.yaml'])
     cls.action_db = Action.add_or_update(ActionAPI.to_model(cls.action))
Ejemplo n.º 19
0
    def setUpClass(cls):
        super(PolicyTest, cls).setUpClass()

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['policytypes']):
            instance = PolicyTypeAPI(**fixture)
            PolicyType.add_or_update(PolicyTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['policies']):
            instance = PolicyAPI(**fixture)
            Policy.add_or_update(PolicyAPI.to_model(instance))
Ejemplo n.º 20
0
def register_runner_types(experimental=False):
    """
    :param experimental: True to also register experimental runners.
    :type experimental: ``bool``
    """
    LOG.debug('Start : register default RunnerTypes.')

    for runner_type in RUNNER_TYPES:
        runner_type = copy.deepcopy(runner_type)

        # For backward compatibility reasons, we also register runners under the old names
        runner_names = [runner_type['name']] + runner_type.get('aliases', [])
        for runner_name in runner_names:
            runner_type['name'] = runner_name
            runner_experimental = runner_type.get('experimental', False)

            if runner_experimental and not experimental:
                LOG.debug('Skipping experimental runner "%s"' % (runner_name))
                continue

            # Remove additional, non db-model attributes
            non_db_attributes = ['experimental', 'aliases']
            for attribute in non_db_attributes:
                if attribute in runner_type:
                    del runner_type[attribute]

            try:
                runner_type_db = get_runnertype_by_name(runner_name)
                update = True
            except StackStormDBObjectNotFoundError:
                runner_type_db = None
                update = False

            runner_type_api = RunnerTypeAPI(**runner_type)
            runner_type_api.validate()
            runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

            if runner_type_db:
                runner_type_model.id = runner_type_db.id

            try:
                runner_type_db = RunnerType.add_or_update(runner_type_model)

                extra = {'runner_type_db': runner_type_db}
                if update:
                    LOG.audit('RunnerType updated. RunnerType %s',
                              runner_type_db,
                              extra=extra)
                else:
                    LOG.audit('RunnerType created. RunnerType %s',
                              runner_type_db,
                              extra=extra)
            except Exception:
                LOG.exception('Unable to register runner type %s.',
                              runner_type['name'])

    LOG.debug('End : register default RunnerTypes.')
Ejemplo n.º 21
0
def register_runner_types(experimental=False):
    """
    :param experimental: True to also register experimental runners.
    :type experimental: ``bool``
    """
    LOG.debug('Start : register default RunnerTypes.')

    for runner_type in RUNNER_TYPES:
        runner_type = copy.deepcopy(runner_type)

        # For backward compatibility reasons, we also register runners under the old names
        runner_names = [runner_type['name']] + runner_type.get('aliases', [])
        for runner_name in runner_names:
            runner_type['name'] = runner_name
            runner_experimental = runner_type.get('experimental', False)

            if runner_experimental and not experimental:
                LOG.debug('Skipping experimental runner "%s"' % (runner_name))
                continue

            # Remove additional, non db-model attributes
            non_db_attributes = ['experimental', 'aliases']
            for attribute in non_db_attributes:
                if attribute in runner_type:
                    del runner_type[attribute]

            try:
                runner_type_db = get_runnertype_by_name(runner_name)
                update = True
            except StackStormDBObjectNotFoundError:
                runner_type_db = None
                update = False

            # Note: We don't want to overwrite "enabled" attribute which is already in the database
            # (aka we don't want to re-enable runner which has been disabled by the user)
            if runner_type_db and runner_type_db['enabled'] != runner_type['enabled']:
                runner_type['enabled'] = runner_type_db['enabled']

            runner_type_api = RunnerTypeAPI(**runner_type)
            runner_type_api.validate()
            runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

            if runner_type_db:
                runner_type_model.id = runner_type_db.id

            try:
                runner_type_db = RunnerType.add_or_update(runner_type_model)

                extra = {'runner_type_db': runner_type_db}
                if update:
                    LOG.audit('RunnerType updated. RunnerType %s', runner_type_db, extra=extra)
                else:
                    LOG.audit('RunnerType created. RunnerType %s', runner_type_db, extra=extra)
            except Exception:
                LOG.exception('Unable to register runner type %s.', runner_type['name'])

    LOG.debug('End : register default RunnerTypes.')
Ejemplo n.º 22
0
    def setUp(self):
        EventletTestCase.setUpClass()
        DbTestCase.setUpClass()

        for _, fixture in six.iteritems(FIXTURES["runners"]):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES["actions"]):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES["policytypes"]):
            instance = PolicyTypeAPI(**fixture)
            PolicyType.add_or_update(PolicyTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES["policies"]):
            instance = PolicyAPI(**fixture)
            Policy.add_or_update(PolicyAPI.to_model(instance))
Ejemplo n.º 23
0
    def setUpClass(cls):
        EventletTestCase.setUpClass()
        DbTestCase.setUpClass()

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['policytypes']):
            instance = PolicyTypeAPI(**fixture)
            PolicyType.add_or_update(PolicyTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['policies']):
            instance = PolicyAPI(**fixture)
            Policy.add_or_update(PolicyAPI.to_model(instance))
Ejemplo n.º 24
0
def register_runner(runner_type, experimental):
    # For backward compatibility reasons, we also register runners under the old names
    runner_names = [runner_type['name']] + runner_type.get('aliases', [])
    for runner_name in runner_names:
        runner_type['name'] = runner_name
        runner_experimental = runner_type.get('experimental', False)

        if runner_experimental and not experimental:
            LOG.debug('Skipping experimental runner "%s"' % (runner_name))
            continue

        # Remove additional, non db-model attributes
        non_db_attributes = ['experimental', 'aliases']
        for attribute in non_db_attributes:
            if attribute in runner_type:
                del runner_type[attribute]

        try:
            runner_type_db = get_runnertype_by_name(runner_name)
            update = True
        except StackStormDBObjectNotFoundError:
            runner_type_db = None
            update = False

        # Note: We don't want to overwrite "enabled" attribute which is already in the database
        # (aka we don't want to re-enable runner which has been disabled by the user)
        if runner_type_db and runner_type_db['enabled'] != runner_type['enabled']:
            runner_type['enabled'] = runner_type_db['enabled']

        # If package is not provided, assume it's the same as module name for backward
        # compatibility reasons
        if not runner_type.get('runner_package', None):
            runner_type['runner_package'] = runner_type['runner_module']

        runner_type_api = RunnerTypeAPI(**runner_type)
        runner_type_api.validate()
        runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

        if runner_type_db:
            runner_type_model.id = runner_type_db.id

        try:

            runner_type_db = RunnerType.add_or_update(runner_type_model)

            extra = {'runner_type_db': runner_type_db}
            if update:
                LOG.audit('RunnerType updated. RunnerType %s', runner_type_db, extra=extra)
            else:
                LOG.audit('RunnerType created. RunnerType %s', runner_type_db, extra=extra)
        except Exception:
            LOG.exception('Unable to register runner type %s.', runner_type['name'])
            return 0
    return 1
Ejemplo n.º 25
0
def register_runner_types(experimental=False):
    """
    :param experimental: True to also register experimental runners.
    :type experimental: ``bool``
    """
    LOG.debug("Start : register default RunnerTypes.")

    for runner_type in RUNNER_TYPES:
        runner_type = copy.deepcopy(runner_type)

        # For backward compatibility reasons, we also register runners under the old names
        runner_names = [runner_type["name"]] + runner_type.get("aliases", [])
        for runner_name in runner_names:
            runner_type["name"] = runner_name
            runner_experimental = runner_type.get("experimental", False)

            if runner_experimental and not experimental:
                LOG.debug('Skipping experimental runner "%s"' % (runner_name))
                continue

            # Remove additional, non db-model attributes
            non_db_attributes = ["experimental", "aliases"]
            for attribute in non_db_attributes:
                if attribute in runner_type:
                    del runner_type[attribute]

            try:
                runner_type_db = get_runnertype_by_name(runner_name)
                update = True
            except StackStormDBObjectNotFoundError:
                runner_type_db = None
                update = False

            runner_type_api = RunnerTypeAPI(**runner_type)
            runner_type_api.validate()
            runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

            if runner_type_db:
                runner_type_model.id = runner_type_db.id

            try:
                runner_type_db = RunnerType.add_or_update(runner_type_model)

                extra = {"runner_type_db": runner_type_db}
                if update:
                    LOG.audit("RunnerType updated. RunnerType %s", runner_type_db, extra=extra)
                else:
                    LOG.audit("RunnerType created. RunnerType %s", runner_type_db, extra=extra)
            except Exception:
                LOG.exception("Unable to register runner type %s.", runner_type["name"])

    LOG.debug("End : register default RunnerTypes.")
Ejemplo n.º 26
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name="python")
     created.description = ""
     created.enabled = True
     if not metadata:
         created.runner_parameters = {"r1": None, "r2": None}
     else:
         created.runner_parameters = {
             "r1": {"type": "object", "properties": {"r1a": {"type": "string"}}},
             "r2": {"type": "string", "required": True},
         }
     created.runner_module = "nomodule"
     return RunnerType.add_or_update(created)
Ejemplo n.º 27
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name='python')
     created.description = ''
     created.enabled = True
     if not metadata:
         created.runner_parameters = {'r1': None, 'r2': None}
     else:
         created.runner_parameters = {
             'r1': {'type': 'object', 'properties': {'r1a': {'type': 'string'}}},
             'r2': {'type': 'string', 'required': True}
         }
     created.runner_module = 'nomodule'
     return RunnerType.add_or_update(created)
Ejemplo n.º 28
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name='python')
     created.description = ''
     created.enabled = True
     if not metadata:
         created.runner_parameters = {'r1': None, 'r2': None}
     else:
         created.runner_parameters = {
             'r1': {'type': 'object', 'properties': {'r1a': {'type': 'string'}}},
             'r2': {'type': 'string', 'required': True}
         }
     created.runner_module = 'nomodule'
     return RunnerType.add_or_update(created)
Ejemplo n.º 29
0
    def setUpClass(cls):
        super(TestActionExecutionService, cls).setUpClass()
        cls.runner = RunnerTypeAPI(**RUNNER)
        cls.runnerdb = RunnerType.add_or_update(RunnerTypeAPI.to_model(cls.runner))

        runner_api = RunnerTypeAPI(**RUNNER_ACTION_CHAIN)
        RunnerType.add_or_update(RunnerTypeAPI.to_model(runner_api))

        cls.actions = {
            ACTION['name']: ActionAPI(**ACTION),
            ACTION_WORKFLOW['name']: ActionAPI(**ACTION_WORKFLOW),
            ACTION_OVR_PARAM['name']: ActionAPI(**ACTION_OVR_PARAM),
            ACTION_OVR_PARAM_MUTABLE['name']: ActionAPI(**ACTION_OVR_PARAM_MUTABLE),
            ACTION_OVR_PARAM_IMMUTABLE['name']: ActionAPI(**ACTION_OVR_PARAM_IMMUTABLE),
            ACTION_OVR_PARAM_BAD_ATTR['name']: ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR),
            ACTION_OVR_PARAM_BAD_ATTR_NOOP['name']: ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR_NOOP)
        }

        cls.actiondbs = {name: Action.add_or_update(ActionAPI.to_model(action))
                         for name, action in six.iteritems(cls.actions)}

        cls.container = RunnerContainer()
Ejemplo n.º 30
0
    def setUpClass(cls):
        super(ActionParamsUtilsTest, cls).setUpClass()

        cls.runnertype_dbs = {}
        cls.action_dbs = {}

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            runnertype_db = RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))
            cls.runnertype_dbs[runnertype_db.name] = runnertype_db

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            action_db = Action.add_or_update(ActionAPI.to_model(instance))
            cls.action_dbs[action_db.name] = action_db
Ejemplo n.º 31
0
    def setUpClass(cls):
        super(ActionParamsUtilsTest, cls).setUpClass()

        cls.runnertype_dbs = {}
        cls.action_dbs = {}

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            runnertype_db = RunnerType.add_or_update(
                RunnerTypeAPI.to_model(instance))
            cls.runnertype_dbs[runnertype_db.name] = runnertype_db

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            action_db = Action.add_or_update(ActionAPI.to_model(instance))
            cls.action_dbs[action_db.name] = action_db
Ejemplo n.º 32
0
    def put(self, name_or_id, runner_type_api):
        # Note: We only allow "enabled" attribute of the runner to be changed
        runner_type_db = self._get_by_name_or_id(name_or_id=name_or_id)
        old_runner_type_db = runner_type_db
        LOG.debug('PUT /runnertypes/ lookup with id=%s found object: %s', name_or_id,
                  runner_type_db)

        try:
            if runner_type_api.id and runner_type_api.id != name_or_id:
                LOG.warning('Discarding mismatched id=%s found in payload and using uri_id=%s.',
                            runner_type_api.id, name_or_id)

            runner_type_db.enabled = runner_type_api.enabled
            runner_type_db = RunnerType.add_or_update(runner_type_db)
        except (ValidationError, ValueError) as e:
            LOG.exception('Validation failed for runner type data=%s', runner_type_api)
            pecan.abort(http_client.BAD_REQUEST, str(e))
            return

        extra = {'old_runner_type_db': old_runner_type_db, 'new_runner_type_db': runner_type_db}
        LOG.audit('Runner Type updated. RunnerType.id=%s.' % (runner_type_db.id), extra=extra)
        runner_type_api = RunnerTypeAPI.from_model(runner_type_db)
        return runner_type_api
Ejemplo n.º 33
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name="python")
     created.description = ""
     created.enabled = True
     if not metadata:
         created.runner_parameters = {"r1": None, "r2": None}
     else:
         created.runner_parameters = {
             "r1": {
                 "type": "object",
                 "properties": {
                     "r1a": {
                         "type": "string"
                     }
                 }
             },
             "r2": {
                 "type": "string",
                 "required": True
             },
         }
     created.runner_module = "nomodule"
     return RunnerType.add_or_update(created)
Ejemplo n.º 34
0
 def setUpClass(cls):
     super(ActionParamsUtilsTest, cls).setUpClass()
     cls.runnertype = RunnerTypeAPI(**FIXTURES['runners']['testrunner1.yaml'])
     cls.runnertype_db = RunnerType.add_or_update(RunnerTypeAPI.to_model(cls.runnertype))
     cls.action = ActionAPI(**FIXTURES['actions']['action1.yaml'])
     cls.action_db = Action.add_or_update(ActionAPI.to_model(cls.action))