def save(self, snapshot, backup_id, cinder): job_stats_path = self._stats_file(snapshot['origin']) logger.rename('lunr.storage.helper.backup.save') setproctitle("lunr-save: " + backup_id) size = snapshot['size'] / 1024 / 1024 / 1024 try: op_start = time() worker = Worker(snapshot['origin'], conf=self.conf, stats_path=job_stats_path) except exc.ClientException, e: if e.http_status != 404: raise op_start = time() conn = get_conn(self.conf) conn.put_container(snapshot['origin']) logger.warning("failed to retrieve manifest;" " first time backup for this volume?") # TODO: write the block_size on the manifest at create? block_count, remainder = divmod(snapshot['size'], BLOCK_SIZE) if remainder: block_count += 1 # initial backup is the only time the we need to worry about # creating a new manifest for the worker worker = Worker(snapshot['origin'], conf=self.conf, manifest=Manifest.blank(block_count), stats_path=job_stats_path)
def status(self): conn = get_conn(self.conf) status = {'client': conn.__module__.rsplit('.', 1)[-1]} try: status.update(conn.head_account()) except conn.ClientException, e: raise ServiceUnavailable(e)
def status(self): conn = get_conn(self.conf) status = {'client': conn.__module__.rsplit('.', 1)[-1]} try: status.update(conn.head_account()) except conn.ClientException, e: raise ServiceUnavailable(e)
def save(self, snapshot, backup_id, cinder): job_stats_path = self._stats_file(snapshot['origin']) logger.rename('lunr.storage.helper.backup.save') setproctitle("lunr-save: " + backup_id) size = snapshot['size'] / 1024 / 1024 / 1024 try: op_start = time() worker = Worker(snapshot['origin'], conf=self.conf, stats_path=job_stats_path) except exc.ClientException, e: if e.http_status != 404: raise op_start = time() conn = get_conn(self.conf) conn.put_container(snapshot['origin']) logger.warning("failed to retrieve manifest;" " first time backup for this volume?") # TODO: write the block_size on the manifest at create? block_count, remainder = divmod(snapshot['size'], BLOCK_SIZE) if remainder: block_count += 1 # initial backup is the only time the we need to worry about # creating a new manifest for the worker worker = Worker(snapshot['origin'], conf=self.conf, manifest=Manifest.blank(block_count), stats_path=job_stats_path)
def remove_container(self, volume): for attempt in range(0, 2): try: logger.info("Removing container '%s'" % volume['id']) conn = get_conn(self.conf) return conn.delete_container(volume['id']) except exc.ClientException, e: if e.http_status == 404: return # Audit the backups, and try again self.audit(volume)
def remove_container(self, volume): for attempt in range(0, 2): try: logger.info("Removing container '%s'" % volume['id']) conn = get_conn(self.conf) return conn.delete_container(volume['id']) except exc.ClientException, e: if e.http_status == 404: return # Audit the backups, and try again self.audit(volume)
def audit(self, volume): logger.rename("lunr.storage.helper.backup.audit") setproctitle("lunr-audit: " + volume["id"]) try: op_start = time() worker = Worker(volume["id"], self.conf) except exc.ClientException, e: if e.http_status != 404: raise op_start = time() conn = get_conn(self.conf) conn.put_container(volume["id"]) logger.warning("failed to retrieve manifest;" " auditing volume with no backups") # creating a blank manifest for the worker worker = Worker(volume["id"], conf=self.conf, manifest=Manifest.blank(0))
def setUp(self): self.block_queue = multiprocessing.JoinableQueue() self.result_queue = multiprocessing.Queue() self.stat_queue = multiprocessing.Queue() self.volume_id = 'volume_id' self.scratch = mkdtemp() backup_path = os.path.join(self.scratch, 'backups') self.conf = LunrConfig({ 'backup': {'client': 'disk'}, 'disk': {'path': backup_path}, }) self.conn = get_conn(self.conf) self.conn.put_container(self.volume_id) self.process = SaveProcess(self.conf, self.volume_id, self.block_queue, self.result_queue, self.stat_queue) self.process.start()
def audit(self, volume): logger.rename('lunr.storage.helper.backup.audit') setproctitle("lunr-audit: " + volume['id']) try: op_start = time() worker = Worker(volume['id'], self.conf) except exc.ClientException, e: if e.http_status != 404: raise op_start = time() conn = get_conn(self.conf) conn.put_container(volume['id']) logger.warning("failed to retrieve manifest;" " auditing volume with no backups") # creating a blank manifest for the worker worker = Worker(volume['id'], conf=self.conf, manifest=Manifest.blank(0))
def setUp(self): self.block_queue = multiprocessing.JoinableQueue() self.result_queue = multiprocessing.Queue() self.stat_queue = multiprocessing.Queue() self.volume_id = 'volume_id' self.scratch = mkdtemp() backup_path = os.path.join(self.scratch, 'backups') self.conf = LunrConfig({ 'backup': { 'client': 'disk' }, 'disk': { 'path': backup_path }, }) self.conn = get_conn(self.conf) self.conn.put_container(self.volume_id) self.process = SaveProcess(self.conf, self.volume_id, self.block_queue, self.result_queue, self.stat_queue) self.process.start()