Exemple #1
0
def getStorage():
    global STORAGE_INSTANCE
    if STORAGE_INSTANCE is None:
        msg = "storage is not inizialized"
        getLogger().error(msg)
        raise ValueError, msg
    return STORAGE_INSTANCE
Exemple #2
0
 def __init_config__(self):
     jobdir  = getConfig().get('global', 'jobdir')
     jobfile = os.path.join(jobdir, self.name+".conf")
     getLogger().info("loading job configuration: " + self.name)
     self.read(jobfile)
     if not self.has_section('job'):
         msg = "invalid job configuration"
         getLogger().error(msg)
         raise ValueError, msg
Exemple #3
0
 def __init_config__(self):
     clientdir  = getConfig().get('global', 'clientdir')
     clientfile = os.path.join(clientdir, self.name+".conf")
     getLogger().info("loading client configuration: " + self.name)
     self.read(clientfile)
     if not (self.has_section('client') and self.has_option('client', 'address')):
         msg = "invalid job configuration"
         getLogger().error(msg)
         raise ValueError, msg
Exemple #4
0
def createStorage(config, section):
    assert isinstance(config, ConfigParser)
    package, classname = config.get(section, 'class').rsplit('.', 1)
    module             = __import__(package, fromlist=[classname])
    storageClass       = getattr(module, classname)
    if not IStorage.implementedBy(storageClass):
        msg = "'{0}.{1}' does not implement IStorage interface".format(package, classname)
        getLogger('storage').error(msg)
        raise ValueError, msg
    return storageClass(section)
Exemple #5
0
def getJobConfig(name):
    global JOB_CONFIGS
    if JOB_CONFIGS is None:
        msg = "job configurations are not inizialized"
        getLogger().error(msg)
        raise ValueError, msg
    config = JOB_CONFIGS[name]
    if config == name:
        config            = JobConfig(name)
        JOB_CONFIGS[name] = config
    return config
Exemple #6
0
def getClientConfig(name):
    global CLIENT_CONFIGS
    if CLIENT_CONFIGS is None:
        msg = "client configurations are not inizialized"
        getLogger().error(msg)
        raise ValueError, msg
    config = CLIENT_CONFIGS[name]
    if config == name:
        config               = ClientConfig(name)
        CLIENT_CONFIGS[name] = config
    return config
Exemple #7
0
 def __init__(self, name):
     global JOB_CONFIGS
     if JOB_CONFIGS is None:
         msg = "job configurations are not inizialized"
         getLogger().error(msg)
         raise ValueError, msg
     ConfigParser.__init__(self)
     if name in JOB_CONFIGS and isinstance(JOB_CONFIGS[name], JobConfig):
         msg = "duplicate job configuration: "+name
         getLogger().error(msg)
         raise ValueError, msg
     self.name = name
     self.__init_config__()
Exemple #8
0
 def __init__(self, name):
     global CLIENT_CONFIGS
     if CLIENT_CONFIGS is None:
         msg = "client configurations are not inizialized"
         getLogger().error(msg)
         raise ValueError, msg
     ConfigParser.__init__(self)
     if name in CLIENT_CONFIGS and isinstance(CLIENT_CONFIGS[name], ClientConfig):
         msg = "duplicate client configuration: "+name
         getLogger().error(msg)
         raise ValueError, msg
     self.name = name
     self.__init_config__()
Exemple #9
0
 def __init__(self, section):
     self.config  = getConfig()
     self.section = section
     self.log     = getLogger('storage')
     self.joblist = list()
     if not self.config.has_section(self.section):
         msg = "unknown section: "+section
         self.log.error(msg)
         raise ValueError, msg
Exemple #10
0
def main():
    try:
        initOptions()
        initConfig("server", OPTIONS.config)
        initLogger(OPTIONS.verbose, OPTIONS.debug)
        log = getLogger()
    except Exception, e:
        print "Error:", e
        return 1
Exemple #11
0
def initJobConfigs():
    global JOB_CONFIGS
    if JOB_CONFIGS is None:
        log         = getLogger()
        cfg         = getConfig()
        log.info("initializing job configurations")
        jobdir      = getConfig().get('global', 'jobdir')
        JOB_CONFIGS = dict()
        if os.path.isdir(jobdir):
            for entry in os.listdir(jobdir):
                name, ext = os.path.splitext(entry)
                filename  = os.path.join(jobdir, entry)
                if os.path.isfile(filename) and ext == '.conf':
                    JOB_CONFIGS[name] = name
        else:
            log.error("job directory doesn't exist: {0}".format(jobdir))
Exemple #12
0
def initClientConfigs():
    global CLIENT_CONFIGS
    if CLIENT_CONFIGS is None:
        log            = getLogger()
        cfg            = getConfig()
        log.info("initializing client configurations")
        clientdir      = getConfig().get('global', 'clientdir')
        CLIENT_CONFIGS = dict()
        if os.path.isdir(clientdir):
            for entry in os.listdir(clientdir):
                name, ext = os.path.splitext(entry)
                filename  = os.path.join(clientdir, entry)
                if os.path.isfile(filename) and ext == '.conf':
                    CLIENT_CONFIGS[name] = name
        else:
            log.error("client directory doesn't exist: {0}".format(clientdir))
Exemple #13
0
def initStorage():
    global STORAGE_INSTANCE
    if STORAGE_INSTANCE is None:
        getLogger().info("initializing storage")
        STORAGE_INSTANCE = createStorage(getConfig(), SECTION)
Exemple #14
0
 def startFactory(self):
     BaseServerProtocolFactory.startFactory(self)
     # Bootstrap
     self.config = getConfig()
     self.log = getLogger()
     self.log.info("version {0}".format(rpync.__version__))
Exemple #15
0
 def __init__(self, catalog):
     assert isinstance(catalog, BaseCatalog)
     self.catalog = catalog
     self.jid     = self.catalog.newJobId()
     self.log     = getLogger('catalog', str(self.jid))
Exemple #16
0
 def __init__(self):
     self.log = getLogger('catalog')
Exemple #17
0
 def createLogger(self, *args):
     return getLogger(*args)
Exemple #18
0
 def __init__(self, storage):
     assert isinstance(storage, BaseStorage)
     self.storage = storage
     self.jid     = self.storage.newJobId()
     self.log     = getLogger('storage', str(self.jid))