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 _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}