コード例 #1
0
    def delete(self):
        # Check if main object exists
        config = NitroResourceConfig(
            module=self.module,
            resource=self.main_nitro_class,
            attribute_values_dict=self.module.params,
            attributes_list=self.attibute_config[
                self.main_nitro_class]['attributes_list'],
            transforms=self.attibute_config[self.main_nitro_class]
            ['transforms'],
        )

        try:
            appfw_policy_exists = config.exists(
                get_id_attributes=self.attibute_config[
                    self.main_nitro_class]['get_id_attributes'])
        except NitroException as e:
            # This is the no such policy exists exception
            if e.errorcode in [258, 2054]:
                appfw_policy_exists = False
            else:
                raise
        if appfw_policy_exists:
            self.module_result['changed'] = True
            if not self.module.check_mode:
                config.delete(delete_id_attributes=self.attibute_config[
                    self.main_nitro_class]['delete_id_attributes'])
コード例 #2
0
    def update_or_create(self):
        # Check if main object exists
        config = NitroResourceConfig(
            module=self.module,
            resource=self.main_nitro_class,
            attribute_values_dict=self.module.params,
            attributes_list=self.attibute_config[
                self.main_nitro_class]['attributes_list'],
            transforms=self.attibute_config[self.main_nitro_class]
            ['transforms'],
        )

        # Create or update main object
        try:
            appfw_policy_exists = config.exists(
                get_id_attributes=self.attibute_config[
                    self.main_nitro_class]['get_id_attributes'])
        except NitroException as e:
            # This is the no such policy exists exception
            if e.errorcode in [258, 2054]:
                appfw_policy_exists = False
            else:
                raise

        if not appfw_policy_exists:
            self.module_result['changed'] = True
            if not self.module.check_mode:
                config.create()
        else:
            if not config.values_subgroup_of_actual():
                self.module_result['changed'] = True
                if not self.module.check_mode:
                    config.update(id_attribute='name')
コード例 #3
0
    def update(self):
        log('ModuleExecutor.update()')
        # Check if main object exists
        config = NitroResourceConfig(
            module=self.module,
            resource=self.main_nitro_class,
            attribute_values_dict=self.module.params,
            attributes_list=self.attribute_config[self.main_nitro_class]['attributes_list'],
            transforms=self.attribute_config[self.main_nitro_class]['transforms'],
        )

        self.module_result['changed'] = True
        if not self.module.check_mode:
            config.update()
    def get_main_config(self):
        manipulated_values_dict = copy.deepcopy(self.module.params)

        # We do not want the state module param to be interpreted as the appfwfieldtype parameter value
        if 'state' in manipulated_values_dict:
            del manipulated_values_dict['state']

        # Instead the disabled argument defines what the actual 'state' attribute should be
        disabled_value = manipulated_values_dict.get('disabled')
        if disabled_value is not None:
            if disabled_value:
                manipulated_values_dict['state'] = 'DISABLED'
            else:
                manipulated_values_dict['state'] = 'ENABLED'

        config = NitroResourceConfig(
            module=self.module,
            resource=self.main_nitro_class,
            attribute_values_dict=manipulated_values_dict,
            attributes_list=self.attibute_config[
                self.main_nitro_class]['attributes_list'],
            transforms=self.attibute_config[self.main_nitro_class]
            ['transforms'],
        )

        return config
コード例 #5
0
    def get_main_config(self):
        manipulated_values_dict = copy.deepcopy(self.module.params)

        config = NitroResourceConfig(
            module=self.module,
            resource=self.main_nitro_class,
            attribute_values_dict=manipulated_values_dict,
            attributes_list=self.attibute_config[self.main_nitro_class]['attributes_list'],
            transforms=self.attibute_config[self.main_nitro_class]['transforms'],
        )

        return config
コード例 #6
0
    def get_main_config(self):
        manipulated_values_dict = copy.deepcopy(self.module.params)

        # We do not want the state module param to be interpreted as the appfwsignatures parameter value
        if 'state' in manipulated_values_dict:
            del manipulated_values_dict['state']

        config = NitroResourceConfig(
            module=self.module,
            resource=self.main_nitro_class,
            attribute_values_dict=manipulated_values_dict,
            attributes_list=self.attibute_config[
                self.main_nitro_class]['attributes_list'],
            transforms=self.attibute_config[self.main_nitro_class]
            ['transforms'],
        )

        return config
    def sync_binding_with_data(self, data):

        binding_key = data['binding_key']
        binding_object = data['binding_object']

        if self.module.params.get(binding_key) is None:
            return

        log('ModuleExecutor syncing binding %s' % binding_key)

        mode = self.module.params[binding_key]['mode']

        # Make a list of config objects for configured bindings
        configured_bindings = []
        for bind_values in self.module.params[binding_key]['attributes']:
            all_bind_values = copy.deepcopy(bind_values)
            configured_binding = NitroResourceConfig(
                module=self.module,
                resource=binding_object,
                attribute_values_dict=all_bind_values,
                attributes_list=self.attribute_config[binding_key]
                ['attributes_list'],
                transforms=self.attribute_config[binding_key]['transforms'],
            )

            configured_bindings.append(configured_binding)

        if mode == 'bind':
            for configured_binding in configured_bindings:
                self.module_result['changed'] = True
                try:
                    configured_binding.create()
                except NitroException as e:
                    if e.errorcode != 273:
                        raise

        elif mode == 'unbind':
            for configured_binding in configured_bindings:
                self.module_result['changed'] = True
                try:
                    configured_binding.delete(
                        delete_id_attributes=self.attribute_config[binding_key]
                        ['delete_id_attributes'])
                except NitroException as e:
                    # Handle exceptions when trying to unbind objects that are not bound
                    # Every binding has its own errorcode
                    if binding_object == 'appfwglobal_appfwpolicy_binding':
                        if e.errorcode == 3093:
                            log('Ignoring nitro_errocode 3093 for appfwglobal_appfwpolicy_binding'
                                )
                        else:
                            raise