def _get_sfc_db(self, context, sfc_id, current_statuses, new_status): try: sfc_db = (self._model_query( context, VnffgChain).filter(VnffgChain.id == sfc_id).filter( VnffgChain.status.in_(current_statuses)).with_lockmode( 'update').one()) except orm_exc.NoResultFound: raise nfvo.SfcNotFoundException(sfc_id=sfc_id) if sfc_db.status == constants.PENDING_UPDATE: raise nfvo.SfcInUse(sfc_id=sfc_id) sfc_db.update({'status': new_status}) return sfc_db
def _get_resource(self, context, model, res_id): try: return self._get_by_id(context, model, res_id) except orm_exc.NoResultFound: if issubclass(model, Vnffg): raise nfvo.VnffgNotFoundException(vnffg_id=res_id) elif issubclass(model, VnffgClassifier): raise nfvo.ClassifierNotFoundException(classifier_id=res_id) if issubclass(model, VnffgTemplate): raise nfvo.VnffgdNotFoundException(vnffgd_id=res_id) if issubclass(model, VnffgChain): raise nfvo.SfcNotFoundException(sfc_id=res_id) else: raise