Esempio n. 1
0
 def __init__(self, db_name, *args, **kwargs):
     '''
     Set database connetors on current instance.
     Run binary replication.
     '''
     (self.username, self.password) = \
         local_config.get_db_credentials(db_name)
     (self.db, self.server) = dbutils.get_db_and_server(db_name)
     self.db_name = db_name
     self.replicate_file_changes()
Esempio n. 2
0
    def __init__(self, device_name, mountpoint, uri=None, *args, **kwargs):
        '''
        Configure file system, device and store remote Cozy informations.
        '''
        logger.info('Configuring CouchDB Fuse...')

        # Configure fuse
        fuse.Fuse.__init__(self, *args, **kwargs)
        self.fuse_args.mountpoint = mountpoint
        self.fuse_args.add('allow_other')
        self.currentFile = None
        logger.info('- Fuse configured')

        # Configure device
        self.device = device_name
        (self.db, self.server) = dbutils.get_db_and_server(device_name)
        logger.info('- Database configured')

        # Configure Cozy
        device = dbutils.get_device(device_name)
        self.urlCozy = device.get('url', '')
        self.passwordCozy = device.get('password', '')
        self.loginCozy = device_name
        logger.info('- Cozy configured')

        # Configure replication urls.
        (self.db_username, self.db_password) = \
            local_config.get_db_credentials(device_name)
        self.rep_source = 'http://%s:%s@localhost:5984/%s' % (
            self.db_username,
            self.db_password,
            self.device
        )
        self.rep_target = "https://%s:%s@%s/cozy" % (
            self.loginCozy,
            self.passwordCozy,
            self.urlCozy.split('/')[2]
        )
        logger.info('- Replication configured')

        # Configure cache and create required folders
        device_path = os.path.join(CONFIG_FOLDER, device_name)
        self.binary_cache = binarycache.BinaryCache(
            device_name, device_path, self.rep_source, mountpoint)
        self.file_size_cache = cache.Cache()
        self.attr_cache = cache.Cache()
        self.name_cache = cache.Cache()
        self.fd_cache = cache.Cache()

        logger.info('- Cache configured')
Esempio n. 3
0
    def __init__(self, database, mountpoint, uri=None, *args, **kwargs):
        '''
        Configure file system, database and store remote Cozy informations.
        '''
        logger.info('Mounting folder...')

        # Configure fuse
        fuse.Fuse.__init__(self, *args, **kwargs)
        self.fuse_args.mountpoint = mountpoint
        self.fuse_args.add('allow_other')
        self.currentFile = None

        # Configure database
        self.database = database
        (self.db, self.server) = dbutils.get_db_and_server(database)

        ## Configure Cozy
        device = dbutils.get_device(database)
        self.urlCozy = device['url']
        self.passwordCozy = device['password']
        self.loginCozy = device['login']

        # Configure replication urls.
        (self.db_username, self.db_password) = \
            local_config.get_db_credentials(database)
        string_data = (
            self.db_username,
            self.db_password,
            self.database
        )
        self.rep_source = 'http://%s:%s@localhost:5984/%s' % string_data
        string_data = (
            self.loginCozy,
            self.passwordCozy,
            self.urlCozy.split('/')[2]
        )
        self.rep_target = "https://%s:%s@%s/cozy" % string_data

        # init cache
        self.dirs = {}
        self.descriptors = {}
        self.writeBuffers = {}