def __init__(self, **params): blocksize = params['blocksize'] blockpath = params['blockpath'] blockpath = realpath(blockpath) if not isdir(blockpath): if not exists(blockpath): makedirs(blockpath) else: raise ValueError("Variable blockpath '%s' is not a directory" % (blockpath, )) hashtype = params['hashtype'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype, )) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.blockpath = blockpath self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def __init__(self, **params): blocksize = params['blocksize'] blockpool = params['blockpool'] rados = Rados(conffile=CEPH_CONF_FILE) rados.connect() ioctx = rados.open_ioctx(blockpool) hashtype = params['hashtype'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype, )) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.blockpool = blockpool self.rados = rados self.ioctx = ioctx self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def __init__(self, **params): blocksize = params["blocksize"] blockpath = params["blockpath"] blockpath = realpath(blockpath) if not isdir(blockpath): if not exists(blockpath): makedirs(blockpath) else: raise ValueError("Variable blockpath '%s' is not a directory" % (blockpath,)) hashtype = params["hashtype"] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype,)) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.blockpath = blockpath self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def __init__(self, **params): blocksize = params['blocksize'] blockpool = params['blockpool'] rados = Rados(conffile=CEPH_CONF_FILE) rados.connect() ioctx = rados.open_ioctx(blockpool) hashtype = params['hashtype'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype,)) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.blockpool = blockpool self.rados = rados self.ioctx = ioctx self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def bootstrap_backend_storage(**params): umask = params['umask'] path = params['path'] storageType = params['backend_storage'] if umask is not None: os.umask(umask) if storageType.lower() == 'nfs': if path and not os.path.exists(path): os.makedirs(path) if not os.path.isdir(path): raise RuntimeError("Cannot open path '%s'" % (path,)) elif storageType.lower() == 'rados': import rados cluster = rados.Rados(conffile=params['rados_ceph_conf']) cluster.connect() if not cluster.pool_exists(params['blockpool']): try: cluster.create_pool(params['blockpool']) except Exception as err: err_msg = "Cannot create %s RADOS Pool" raise RuntimeError(err_msg % params['blockpool']) if not cluster.pool_exists(params['mappool']): try: cluster.create_pool(params['mappool']) except Exception as err: err_msg = "Cannot create %s RADOS Pool" raise RuntimeError(err_msg % params['mappool']) cluster.shutdown() else: raise RuntimeError("Wrong Pithos+ backend storage, '%s'" % storageType) hashtype = params['hash_algorithm'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype,)) hasher.update("") emptyhash = hasher.digest() pb = {'blocksize': params['block_size'], 'blockpath': os.path.join(path + '/blocks'), 'hashtype': params['hash_algorithm'], 'blockpool': params['blockpool'], 'backend_storage': params['backend_storage'], 'rados_ceph_conf': params['rados_ceph_conf']} pm = {'mappath': os.path.join(path + '/maps'), 'namelen': len(emptyhash), 'mappool': params['mappool'], 'backend_storage': params['backend_storage'], 'rados_ceph_conf': params['rados_ceph_conf']} return (pb, pm)
def __init__(self, **params): blocksize = params['blocksize'] blockpool = params['blockpool'] hashtype = params['hashtype'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype, )) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.blockpool = blockpool self.ioctx = RadosBlocker.get_rados_ctx(self.blockpool) self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def __init__(self, **params): cfg = ConfigParser.ConfigParser() cfg.readfp(open(params['archipelago_cfile'])) blocksize = params['blocksize'] hashtype = params['hashtype'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype,)) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.ioctx_pool = glue.WorkerGlue.ioctx_pool self.dst_port = int(cfg.getint('mapperd', 'blockerb_port')) self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def __init__(self, **params): cfg = ConfigParser.ConfigParser() cfg.readfp(open(params['archipelago_cfile'])) blocksize = params['blocksize'] hashtype = params['hashtype'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype, )) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.ioctx_pool = glue.WorkerGlue.ioctx_pool self.dst_port = int(cfg.getint('mapperd', 'blockerb_port')) self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def __init__(self, **params): blocksize = params['blocksize'] blockpool = params['blockpool'] hashtype = params['hashtype'] try: hasher = newhasher(hashtype) except ValueError: msg = "Variable hashtype '%s' is not available from hashlib" raise ValueError(msg % (hashtype,)) hasher.update("") emptyhash = hasher.digest() self.blocksize = blocksize self.blockpool = blockpool self.ioctx = RadosBlocker.get_rados_ctx(self.blockpool) self.hashtype = hashtype self.hashlen = len(emptyhash) self.emptyhash = emptyhash
def block_hash(self, data): """Hash a block of data""" hasher = newhasher(self.hashtype) hasher.update(data.rstrip('\x00')) return hasher.digest()