Ejemplo n.º 1
0
 def index(self, req, tenant_id):
     """
     Return all backups information for a tenant ID.
     """
     LOG.debug("Listing Backups for tenant '%s'" % tenant_id)
     context = req.environ[wsgi.CONTEXT_KEY]
     ## add customise conditions when list instance
     search_ops = {}
     search_ops.update(req.GET)
     search_ops = self._validate_search_ops(search_ops)
     op_chain = search_ops.get('chain', None)
     if op_chain:
         backups = KSC_Backup.get_chain_whole(context, op_chain)
     else:
         backups = Backup.list(context, conditions=search_ops)
     LOG.debug("index.backups: '%s'", backups)
     bks = []
     for backup in backups:
         try:
             #service = inst_models.ServiceImage.find_by(id=backup.service_image_id)
             #backup.db_type = service['service_name']
             ds,ds_version = ds_patch_models.find_datastore_by_image_id(backup['service_image_id'])
             backup.db_type = ds.name
         except Exception as ex:
             backup['db_type'] = ""
             LOG.warn("Failed get db type information of backup %s, %s"%(backup['id'], ex))
         bks.append(backup)
     backups = bks
     return wsgi.Result(views.BackupViews(backups).data(), 200)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 def get_chain_before_backup(self, context, backup_id):
     try:
         backup = bkp_models.DBBackup.find_by(id=backup_id)
     except Exception as e:
         LOG.error("backup get occur error! backup_id:%s, exception:%s" % (backup_id, e))
         return None
     if not backup:
         LOG.error("backup get occur error! backup_id:%s, exception:%s" % (backup_id, e))
         return None
     backup_chain = KSC_Backup.get_chain_before_backup(context, backup.id)
     LOG.info("id %s, backup_chain: %s" % (backup.id, backup_chain))
     return backup_chain
Ejemplo n.º 4
0
 def _get_chain_ids(self, context, backup_id):
     backup_chain_whole = KSC_Backup.get_chain_whole(context, backup_id)
     chain_ids = []
     for backup in backup_chain_whole:
         chain_ids += (backup['id'],)
     return {'chain': chain_ids}