Example #1
0
 def __init__(self, core):
     Logger.__init__(self, "UDPStreaming")
     self.core = core
     self.streams = {}  # identifier (int) => Stream
     self.address_to_streams = {}  # IP host => set of Stream identifiers
     self.next_id = 1  # generate unique stream identifiers
     events.connect("sessionDestroyed", self.sessionDestroyed)
Example #2
0
    def __init__(self, ethtool_exe, parent_logger):
        Logger.__init__(self, 'ethtool', parent = parent_logger)
        self.ethtool_exe = ethtool_exe

        self.show_ring = self.init_show_ring()
        self.statistics = self.init_statistics()
        self.nooptions = self.init_nooptions()
Example #3
0
 def __init__(self, logger, config):
     Logger.__init__(self, "ldap", parent=logger)
     self.basedn = config['basedn']
     try:
         uri = 'ldap://%s:%s' % (config['host'], config['port'])
         self.cursor = initialize(uri)
         self.cursor.simple_bind_s(config['username'], config['password'])
     except ldap_error, err:
         self.raiseError(err)
Example #4
0
    def __init__(self):
        Logger.__init__(self, "notify")

        # (event: str, sender: str) => list of Callback objects
        self.events = {}
        # event: str => list of Callback objects
        self.generic_events = {}

        # ConfigComponent (will be set later)
        self.config = None
Example #5
0
 def __init__(self, core, name, hostname, port, protocol):
     Logger.__init__(self, "request_firewall_job")
     self.core = core
     self.name = name
     self.hostname = hostname
     self.port = port
     self.protocol = protocol
     self.client = None
     self.mutex = Lock()
     self.firewall = None
Example #6
0
 def __init__(self, enable, ipv6, logger):
     if ipv6:
         name = 'ipv6_forward'
     else:
         name = 'ipv4_forward'
     Logger.__init__(self, name, parent=logger)
     self.enable = enable
     if ipv6:
         self.sysctl_key = u'net.ipv6.conf.all.forwarding'
     else:
         self.sysctl_key = u'net.ipv4.ip_forward'
Example #7
0
    def __init__(self, conf, logger, log_prefix="database"):
        """
            Build DataBase object.
        """
        Logger.__init__(self, log_prefix, parent=logger)

        self.dbpool = None
        self.conf = conf
        self.ip_type = 4
        adbapi.ConnectionPool.noisy = False
        adbapi.ConnectionPool.reconnect = True
Example #8
0
    def __init__(self, table, name, rules, ipv6, logger):
        Transaction.__init__(self)
        Logger.__init__(self, table, parent=logger)
        self.rules = rules
        self.ipv6 = ipv6
        self.name = name

        filename = '%s-localfw_%s.rules' % (table, self.name)
        if self.ipv6:
            self.filename = path_join(LOCAL_RULES_IPV6_DIR, filename)
        else:
            self.filename = path_join(LOCAL_RULES_IPV4_DIR, filename)
        self.old_filename = None
        self.new_filename = None
Example #9
0
    def __init__(self):
        self.name = self.NAME
        if not self.name:
            raise ValueError("Component name is not set")

        self._jinja_env = None
        self.TEMPLATE_PATH = None

        Logger.__init__(self, self.name, domain=self.LOGGER_DOMAIN)

        self.version = self.VERSION
        if not self.version:
            raise ValueError("Component version is not set")
        if not isinstance(self.version, str):
            raise ValueError("Component version is not a string")

        self.roles = self._createRoles()
        self.acls = self.getAcls()
        self.session = SessionStorage()
Example #10
0
    def __init__(self, context, core):
        Logger.__init__(self, "Exporter")

        self.core = core
        self.context = context
        self.cron = None
        self.locked = False
        self.period = 0
        self.rotation_period = 3600*24*30
        self.sync_start = 0
        self.server_proto = self.PROTO_VERSION

        self.config = VariablesStore()
        self.config_path = os.path.join(self.core.config.get('CORE', 'vardir'), self.CONFIG_FILE)

        try:
            self.config.load(self.config_path)
            self.lastsync = int(self.config.get('lastsync'))
        except (ValueError,ConfigError):
            self.lastsync = self.LASTSYNC_DEFAULT
Example #11
0
    def __init__(self, core):
        Logger.__init__(self, "ssl")
        SSLConfig.__init__(self)
        config = core.config

        # Options
        self.check = config.getboolean("ssl", "check_clients")
        self.fqdn_check = config.getboolean("ssl", "fqdn_check")
        self.max_depth = config.getint("ssl", "max_depth")
        self.protocol = config.get("ssl", "protocol")

        # Filenames
        self.ca = config.get("ssl", "ca")
        self.cert = config.get("ssl", "cert")
        self.key = config.get("ssl", "key")
        self.crl = config.get("ssl", "crl")
        self.key_passwd = config.get("ssl", "key_passwd")

        # TCP parameters
        self.address, self.port = core.getAddressPort("_ssl", 8443)
Example #12
0
    def __init__(self, core, filename = "acl.db"):
        Logger.__init__(self, "acl_sqlite:" + filename)

        vardir = core.config.get("CORE","vardir")
        self._acl_db = path.join(vardir, filename)
        self._version = ''
        self._format = ''

        if not path.exists(self._acl_db):
            raise AclError(ACL_DB_ERROR,
                tr("ACL database file (%s) does not exist!"), self._acl_db)

        # this will create the sqlite database if needed
        try:
            self.db = sqlite.connect(database=self._acl_db, timeout=10.0)
            self._check_version()
        except sqlite.OperationalError, err:
            raise AclError(ACL_DB_ERROR,
                tr("Unable to open the ACL database (%s): %s"),
                self._acl_db, unicode(err))
Example #13
0
    def __init__(self, root_path, address, port, interface, key_file = None, cert_file = None, cacert_file = None, netmask=None):
        Logger.__init__(self, 'openvpn')

        self.root_path = root_path
        self.key_file = key_file
        self.cert_file = cert_file
        self.cacert_file = cacert_file

        self.DH1024_FILE = os.path.join(self.root_path, 'dh1024.pem')
        self.PID_FILE = os.path.join(self.root_path, 'openvpn.pid')
        self.CONFIG_FILE = os.path.join(self.root_path, 'openvpn.conf')

        if key_file is None:
            self.key_file = os.path.join(self.root_path, 'key.pem')
        if cert_file is None:
            self.cert_file = os.path.join(self.root_path, 'cert.pem')
        if cacert_file is None:
            self.cacert_file = os.path.join(self.root_path, 'cacert.pem')

        self.address = address
        self.port = port
        self.interface = interface

        if netmask:
            assert isinstance(netmask, IP)
            assert netmask.version() == 4
            assert netmask.prefixlen() < 32
            self.network = str(netmask.net())
            self.netmask = str(netmask.netmask())
        else:
            self.network = ''
            self.netmask = ''

        try:
            mkdirNew(self.root_path)
        except OSError:
            raise RpcdError('Unable to create directory: %s', self.root_path)
Example #14
0
 def __init__(self, ssl_config):
     Logger.__init__(self, "ssl")
     self.ssl_config = ssl_config
     self.info("Use protocol %s" % ssl_config.protocol)
Example #15
0
    def __init__(self, parent=None, ethernets=None, vlans=None, bondings=None):
        Logger.__init__(self, 'netcfg', parent=parent)
        NetCfg.__init__(self, ethernets, vlans, bondings)

        self.discovering = False

        interface_number_regex = r"(\A[0-9]+: )"

        #bond0:  mtu 1500 qdisc noqueue
        self.loopback_regex = re.compile(interface_number_regex + r"(lo):*")
        #51: ew4master0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
        self.pointtopoint_regex = re.compile(interface_number_regex + r"(.+): <.*POINTOPOINT.*>(.*)")
        self.ethernet_regex, \
        self.bonding_regex, \
        self.vlan_regex, \
        self.wlan, \
        self.ew4master, \
        self.tap, \
        self.tun, \
        self.bridge = (
            re.compile(
                interface_number_regex + r'(%s[0-9]+): <(.*)>(.*)' % iftype
                )
            for iftype in 'eth bond vlan wlan ew4master tap tun br'.split()
        )
        self.other_interfaces = re.compile(
                interface_number_regex + r'(\w+): <(.*)>(.*)'
                )

        hexa = r'[0-9a-fA-F]'
        column_addr = r'(?:%s{2}:)+%s{2}' % (hexa, hexa)
        self.iface_hw_regex = re.compile(r'.*(link/)(.+)')

        protocols = r'inet(?:6){0,1}'
        mask = r'[0-9]{1,3}'

        peer = r"""
        (?:
            \s peer \s       # keyword
            (?:.+)           # peer address
        )
        """

        addr_begin = r"""
        (%s) \s            # protocol: inet|inet6 (retained)
        (.+)               # ip address
        """ % (protocols)

        addr_mid = r"""
        /                  # mask separation char
        (%s)               # mask
        \s
        (?:brd (.+) \s )   # broadcast addr...
        {0,1}              #... is optional
        scope \s (\w+)     # scope: retained
        \s{0,1}(\w*)       # optional end (retained)
        """ % (mask)

        self.pppip_addr_def_regex = re.compile(
        r"""
        %s                 # addr_begin
        %s                 # peer option regex
        %s                 # addr_mid
        """ % (addr_begin, peer, addr_mid),
        re.VERBOSE
        )

        self.ip_addr_def_regex = re.compile(
        r"""
        %s
        %s
        """ % (addr_begin, addr_mid),
        re.VERBOSE
        )

        #Be careful to match secondnet before net
        self.secondip_addr_def_regex = re.compile(
        r"""
        %s
        /(%s) \s (?:brd (.+) \s ){0,1}scope \s (\w+) \s secondary\s{0,1}(\w*)
        """ % (addr_begin, mask),
        re.VERBOSE
        )

        self.ipv6_props = re.compile(r'valid_lft')
Example #16
0
 def __init__(self, core):
     Logger.__init__(self, "service", parent=core)
     self.core = core
Example #17
0
 def __init__(self, core):
     Logger.__init__(self, "module_loader", parent=core)
     self.core = core
Example #18
0
 def __init__(self, log_name="auth"):
     Logger.__init__(self, log_name)
     self.users = {}
     self.groups = {}