def nbd(self, version_uid, bind_address, bind_port, read_only): from backy2.enterprise.nbdserver import Server as NbdServer from backy2.enterprise.nbd import BackyStore backy = self.backy() config_NBD = self.Config(section='NBD') config_DEFAULTS = self.Config(section='DEFAULTS') hash_function = getattr(hashlib, config_DEFAULTS.get('hash_function', 'sha512')) store = BackyStore( backy, cachedir=config_NBD.get('cachedir'), hash_function=hash_function, ) addr = (bind_address, bind_port) server = NbdServer(addr, store, read_only) logger.info("Starting to serve nbd on %s:%s" % (addr[0], addr[1])) logger.info("You may now start") logger.info(" nbd-client -l %s -p %s" % (addr[0], addr[1])) logger.info("and then get the backup via") logger.info(" modprobe nbd") logger.info(" nbd-client -N <version> %s -p %s /dev/nbd0" % (addr[0], addr[1])) server.serve_forever()
def nbd(self, version_uid, bind_address, bind_port, read_only): try: from backy2.enterprise.nbdserver import Server as NbdServer from backy2.enterprise.nbd import BackyStore except ImportError: logger.error('NBD is available in the Enterprise Version only.') sys.exit(21) backy = self.backy() config_NBD = self.Config(section='NBD') config_DEFAULTS = self.Config(section='DEFAULTS') hash_function = getattr(hashlib, config_DEFAULTS.get('hash_function', 'sha512')) store = BackyStore( backy, cachedir=config_NBD.get('cachedir'), hash_function=hash_function, ) addr = (bind_address, bind_port) server = NbdServer(addr, store, read_only) logger.info("Starting to serve nbd on %s:%s" % (addr[0], addr[1])) logger.info("You may now start") logger.info(" nbd-client -l %s -p %s" % (addr[0], addr[1])) logger.info("and then get the backup via") logger.info(" modprobe nbd") logger.info(" nbd-client -N <version> %s -p %s /dev/nbd0" % (addr[0], addr[1])) server.serve_forever()