예제 #1
0
    def set_zone_config_dict(self, obj, conf):
        x = copy.copy(obj)
        if obj.builtin:
            x.path = config.ETC_FIREWALLD_ZONES
            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({"zones": [x]})
        self.add_zone(x)
        zone_writer(x)
        return x
예제 #2
0
 def set_zone_config(self, obj, config):
     if obj.default:
         x = copy.copy(obj)
         x.fw_config = self
         x.import_config(config)
         x.path = ETC_FIREWALLD_ZONES
         x.default = False
         self.add_zone(x)
         zone_writer(x)
         return x
     else:
         obj.fw_config = self
         obj.import_config(config)
         zone_writer(obj)
         return obj
예제 #3
0
파일: fw_config.py 프로젝트: a4lg/firewalld
 def set_zone_config(self, obj, config):
     if obj.default:
         x = copy.copy(obj)
         x.fw_config = self
         x.import_config(config)
         x.path = ETC_FIREWALLD_ZONES
         x.default = False
         self.add_zone(x)
         zone_writer(x)
         return x
     else:
         obj.fw_config = self
         obj.import_config(config)
         zone_writer(obj)
         return obj
예제 #4
0
 def set_zone_config(self, obj, conf):
     if obj.builtin:
         x = copy.copy(obj)
         x.fw_config = self
         x.import_config(conf)
         x.path = config.ETC_FIREWALLD_ZONES
         x.builtin = False
         if obj.path != x.path:
             x.default = False
         self.add_zone(x)
         zone_writer(x)
         return x
     else:
         obj.fw_config = self
         obj.import_config(conf)
         zone_writer(obj)
         return obj
예제 #5
0
 def set_zone_config(self, obj, conf):
     if obj.builtin:
         x = copy.copy(obj)
         x.fw_config = self
         x.import_config(conf)
         x.path = config.ETC_FIREWALLD_ZONES
         x.builtin = False
         if obj.path != x.path:
             x.default = False
         self.add_zone(x)
         zone_writer(x)
         return x
     else:
         obj.fw_config = self
         obj.import_config(conf)
         zone_writer(obj)
         return obj
예제 #6
0
    def new_zone(self, name, conf):
        if name in self._zones or name in self._builtin_zones:
            raise FirewallError(errors.NAME_CONFLICT, "new_zone(): '%s'" % name)

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

        zone_writer(x)
        self.add_zone(x)
        return x
예제 #7
0
    def new_zone(self, name, conf):
        if name in self._zones or name in self._builtin_zones:
            raise FirewallError(errors.NAME_CONFLICT, "new_zone(): '%s'" % name)

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

        zone_writer(x)
        self.add_zone(x)
        return x
예제 #8
0
    def new_zone_dict(self, name, conf):
        if name in self._zones or name in self._builtin_zones:
            raise FirewallError(errors.NAME_CONFLICT,
                                "new_zone(): '%s'" % name)

        x = Zone()
        x.check_name(name)
        x.name = name
        x.filename = "%s.xml" % name
        x.path = config.ETC_FIREWALLD_ZONES
        # It is not possible to add a new one with a name of a buitin
        x.builtin = False
        x.default = True

        x.import_config_dict(conf, self.get_all_io_objects_dict())
        self.full_check_config({"zones": [x]})
        self.add_zone(x)
        zone_writer(x)
        return x
예제 #9
0
    def new_zone(self, name, config):
        try:
            self.get_zone(name)
        except:
            pass
        else:
            raise FirewallError(NAME_CONFLICT, name)

        x = Zone()
        x.check_name(name)
        x.fw_config = self
        x.import_config(config)
        x.name = name
        x.filename = "%s.xml" % name
        x.path = ETC_FIREWALLD_ZONES
        x.default = False

        zone_writer(x)
        self.add_zone(x)
        return x
예제 #10
0
파일: fw_config.py 프로젝트: a4lg/firewalld
    def new_zone(self, name, config):
        try:
            self.get_zone(name)
        except:
            pass
        else:
            raise FirewallError(NAME_CONFLICT, "new_zone(): '%s'" % name)

        x = Zone()
        x.check_name(name)
        x.fw_config = self
        x.import_config(config)
        x.name = name
        x.filename = "%s.xml" % name
        x.path = ETC_FIREWALLD_ZONES
        x.default = False

        zone_writer(x)
        self.add_zone(x)
        return x
예제 #11
0
    def set_zone_config(self, obj, conf):
        conf_dict = {}
        for i, value in enumerate(conf):
            conf_dict[obj.IMPORT_EXPORT_STRUCTURE[i][0]] = value

        if obj.builtin:
            x = copy.copy(obj)
            x.fw_config = self
            x.import_config_dict(conf_dict)
            x.path = config.ETC_FIREWALLD_ZONES
            x.builtin = False
            if obj.path != x.path:
                x.default = False
            self.add_zone(x)
            zone_writer(x)
            return x
        else:
            obj.fw_config = self
            obj.import_config_dict(conf_dict)
            zone_writer(obj)
            return obj
예제 #12
0
    def new_zone(self, name, config):
        try:
            self.get_zone(name)
        except:
            pass
        else:
            raise FirewallError(NAME_CONFLICT, "new_zone(): '%s'" % name)

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

        zone_writer(x)
        self.add_zone(x)
        return x
예제 #13
0
    def new_zone(self, name, conf):
        if name in self._zones or name in self._builtin_zones:
            raise FirewallError(errors.NAME_CONFLICT,
                                "new_zone(): '%s'" % name)

        conf_dict = {}
        for i, value in enumerate(conf):
            conf_dict[Zone.IMPORT_EXPORT_STRUCTURE[i][0]] = value

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

        zone_writer(x)
        self.add_zone(x)
        return x