예제 #1
0
    def set_policy_object_config_dict(self, obj, conf):
        x = copy.copy(obj)
        if obj.builtin:
            x.path = config.ETC_FIREWALLD_POLICIES
            x.builtin = False
            if obj.path != x.path:
                x.default = False

        x.import_config_dict(conf, self.get_all_io_objects_dict())
        self.full_check_config({"policies": [x]})
        self.add_policy_object(x)
        policy_writer(x)
        return x
예제 #2
0
 def set_policy_object_config_dict(self, obj, conf):
     if obj.builtin:
         x = copy.copy(obj)
         x.fw_config = self
         x.import_config_dict(conf)
         x.path = config.ETC_FIREWALLD_POLICIES
         x.builtin = False
         if obj.path != x.path:
             x.default = False
         self.add_policy_object(x)
         policy_writer(x)
         return x
     else:
         obj.fw_config = self
         obj.import_config_dict(conf)
         policy_writer(obj)
         return obj
예제 #3
0
    def new_policy_object_dict(self, name, conf):
        if name in self._policy_objects or name in self._builtin_policy_objects:
            raise FirewallError(errors.NAME_CONFLICT,
                                "new_policy_object(): '%s'" % name)

        x = Policy()
        x.fw_config = self
        x.check_name(name)
        x.import_config_dict(conf)
        x.name = name
        x.filename = "%s.xml" % name
        x.path = config.ETC_FIREWALLD_POLICIES
        # It is not possible to add a new one with a name of a buitin
        x.builtin = False
        x.default = True

        policy_writer(x)
        self.add_policy_object(x)
        return x