Beispiel #1
0
 def __init__(self, logger, config):
     self.sock = []
     self.log = logger
     self.config = config
     self.uuidpool = {} # key MAC address value, value UUID value
     self.ippool = {} # key MAC address string, value assigned IP string
     self.filepool = {} # key IP string, value pathname
     self.states = {} # key MAC address string, value client state
     name_ = PRODUCT_NAME.split('-')
     name_[0] = 'bootp'
     self.bootp_section = '_'.join(name_)
     self.pool_start = self.config.get(self.bootp_section, 'pool_start')
     if not self.pool_start:
         raise BootpError('Missing pool_start definition')
     self.pool_count = int(self.config.get(self.bootp_section,
                           'pool_count', '10'))
     self.netconfig = get_iface_config(self.pool_start)
     if not self.netconfig:
         raise BootpError('Unable to detect network configuration')
     keys = sorted(self.netconfig.keys())
     self.log.info('Using %s' % ', '.join(map(':'.join,
                             zip(keys, [self.netconfig[k] for k in keys]))))
     nlist = self.config.get(self.bootp_section, 'notify')
     self.notify = []
     if nlist:
         try:
             nlist = nlist.split(';')
             for n in nlist:
                 n = n.strip().split(':')
                 self.notify.append((n[0], int(n[1])))
         except Exception, e:
             raise BootpError('Invalid notification URL: %s' % str(e))
Beispiel #2
0
 def __init__(self, logger, config):
     self.sock = []
     self.log = logger
     self.config = config
     self.uuidpool = {} # key MAC address value, value UUID value
     self.ippool = {} # key MAC address string, value assigned IP string
     self.filepool = {} # key IP string, value pathname
     self.states = {} # key MAC address string, value client state
     name_ = PRODUCT_NAME.split('-')
     name_[0] = 'bootp'
     self.netconfig = get_iface_config(self.config.get_bootp_bind_interface())
     if not self.netconfig:
         raise BootpError('Unable to detect network configuration')
     keys = sorted(self.netconfig.keys())
     self.log.info('Using %s' % ', '.join(map(':'.join,
                             zip(keys, [self.netconfig[k] for k in keys]))))
     access = self.config.get_bootp_acl_type()
     if not access:
         self.acl = None
     else:
         access = access.lower()
         if access not in self.ACCESS_LOCAL + self.ACCESS_REMOTE:
             raise BootpError('Invalid access mode: %s' % access)
         if not self.config.has_section(access):
             raise BootpError("Missing access section '%s'" % access)
         self.acl = {}
         if access in self.ACCESS_LOCAL:
             for entry in self.config.options(access):
                 self.acl[entry.upper()] = \
                     to_bool(self.config.get(access, entry))
     self.access = access
Beispiel #3
0
 def __init__(self, logger, config):
     self.sock = []
     self.log = logger
     self.config = config
     self.uuidpool = {}  # key MAC address value, value UUID value
     self.ippool = {}  # key MAC address string, value assigned IP string
     self.filepool = {}  # key IP string, value pathname
     self.states = {}  # key MAC address string, value client state
     name_ = PRODUCT_NAME.split('-')
     name_[0] = 'bootp'
     self.bootp_section = '_'.join(name_)
     self.pool_start = self.config.get(self.bootp_section, 'pool_start')
     if not self.pool_start:
         raise BootpError('Missing pool_start definition')
     self.pool_count = int(
         self.config.get(self.bootp_section, 'pool_count', '10'))
     self.netconfig = get_iface_config(self.pool_start)
     if not self.netconfig:
         raise BootpError('Unable to detect network configuration')
     keys = sorted(self.netconfig.keys())
     self.log.info('Using %s' % ', '.join(
         map(':'.join, zip(keys, [self.netconfig[k] for k in keys]))))
     nlist = self.config.get(self.bootp_section, 'notify')
     self.notify = []
     if nlist:
         try:
             nlist = nlist.split(';')
             for n in nlist:
                 n = n.strip().split(':')
                 self.notify.append((n[0], int(n[1])))
         except Exception, e:
             raise BootpError('Invalid notification URL: %s' % str(e))
Beispiel #4
0
 def __init__(self, logger, config):
     self.sock = []
     self.log = logger
     self.config = config
     self.uuidpool = {}  # key MAC address value, value UUID value
     self.ippool = {}  # key MAC address string, value assigned IP string
     self.filepool = {}  # key IP string, value pathname
     self.states = {}  # key MAC address string, value client state
     name_ = PRODUCT_NAME.split('-')
     name_[0] = 'bootp'
     self.netconfig = get_iface_config(
         self.config.get_bootp_bind_interface())
     if not self.netconfig:
         raise BootpError('Unable to detect network configuration')
     keys = sorted(self.netconfig.keys())
     self.log.info('Using %s' % ', '.join(
         map(':'.join, zip(keys, [self.netconfig[k] for k in keys]))))
     access = self.config.get_bootp_acl_type()
     if not access:
         self.acl = None
     else:
         access = access.lower()
         if access not in self.ACCESS_LOCAL + self.ACCESS_REMOTE:
             raise BootpError('Invalid access mode: %s' % access)
         if not self.config.has_section(access):
             raise BootpError("Missing access section '%s'" % access)
         self.acl = {}
         if access in self.ACCESS_LOCAL:
             for entry in self.config.options(access):
                 self.acl[entry.upper()] = \
                     to_bool(self.config.get(access, entry))
     self.access = access