def fake_deleted_instance_recover(self, req, tenant_id): LOG.debug(_("req : '%s'\n\n") % req) LOG.debug(_("fake_deleted_instance_recover for tenant_id '%s'") % tenant_id) context = req.environ[wsgi.CONTEXT_KEY] context.is_admin = True search_ops = {} search_ops.update(req.GET) instance_id = search_ops.get("instance_id", None) if instance_id is None: raise exception.BadRequest("fake_deleted_instance_recover instance_id is required.") LOG.debug("fake_deleted_instance_recover instance_id: %s" % instance_id) instance_vip = KSC_Instance.get_instance_vip(instance_id) if instance_vip is None: raise exception.NotFound("fake_deleted_instance_recover instance not found, %s" % instance_id) instance_id = instance_vip.instance_id if KSC_Instance.check_instance_fake_deleted(context, instance_id) is not True: raise exception.NotFound("fake_deleted_instance_recover instance not found, %s" % instance_id) KSC_Instance.fake_deleted_instance_recover(context, instance_id) return wsgi.Result(202)
def create_backup(self, context, backup_id, instance_id): instance_tasks = models.BuiltInstanceTasks.load(context, instance_id) flavorid = instance_tasks.flavor_id flavor = KSC_Instance._check_flavor(context, flavorid)._info disk = max(flavor.get("disk", 1), 1) ram = max(flavor.get("ram", 1), 1) LOG.info("create backup for backupid:%s,flavor info disk:%s,ram:%s" % (backup_id,disk,ram)) timeout = disk * backup_timeout_pergb set_blkiotune(context,instance_tasks.id) instance_tasks.create_backup(backup_id,type=instance_tasks.type) try: KSC_Backup.wait_backup(context, backup_id, timeout) except Exception as e: LOG.error("wait_backup error!backup_id:%s.exception:%s" % (backup_id,e)) pass finally: set_blkiotune(context,instance_tasks.id,disk=disk,ram=ram)