def _get_classifier_db(self, context, fc_id, current_statuses, new_status): try: fc_db = (self._model_query( context, VnffgClassifier).filter(VnffgClassifier.id == fc_id).filter( VnffgClassifier.status.in_( current_statuses)).with_lockmode('update').one()) except orm_exc.NoResultFound: raise nfvo.ClassifierNotFoundException(fc_id=fc_id) if fc_db.status == constants.PENDING_UPDATE: raise nfvo.ClassifierInUse(fc_id=fc_id) fc_db.update({'status': new_status}) return fc_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