def on_get(self, request, response, nffg_id): try : user_data = UserAuthentication().authenticateUserFromRESTRequest(request) controller = UpperLayerOrchestratorController(user_data) response.body = controller.get(nffg_id) response.status = falcon.HTTP_200 except NoResultFound: logging.exception("EXCEPTION - NoResultFound") raise falcon.HTTPNotFound() except requests.HTTPError as err: logging.exception(err.response.text) if err.response.status_code == 401: raise falcon.HTTPInternalServerError('Unauthorized.',err.message) elif err.response.status_code == 403: raise falcon.HTTPInternalServerError('Forbidden.',err.message) elif err.response.status_code == 404: raise falcon.HTTPInternalServerError('Resource Not found.',err.message) raise err except jsonschema.ValidationError as err: logging.exception(err.message) raise falcon.HTTPBadRequest('Bad Request', err.message) except sessionNotFound as err: logging.exception(err.message) raise falcon.HTTPNotFound() except ingoingFlowruleMissing as err: logging.exception(err.message) raise falcon.HTTPInternalServerError('ingoingFlowruleMissing',err.message) except ManifestValidationError as err: logging.exception(err.message) raise falcon.HTTPInternalServerError('ManifestValidationError',err.message) except unauthorizedRequest as err: logging.debug("Unauthorized access attempt from user "+request.get_header("X-Auth-User")) raise falcon.HTTPUnauthorized("Unauthorized", err.message) except Exception as ex: logging.exception(ex) raise falcon.HTTPInternalServerError('Contact the admin. ',ex.message)
def get(self, nffg_id = None): """ Get a graph Returns an already deployed graph --- tags: - NF-FG produces: - application/json parameters: - name: nffg_id in: path description: Graph ID to be retrieved required: true type: string - name: X-Auth-User in: header description: Username required: true type: string - name: X-Auth-Pass in: header description: Password required: true type: string - name: X-Auth-Tenant in: header description: Tenant required: true type: string responses: 200: description: Graph retrieved 401: description: Unauthorized 404: description: Graph not found 500: description: Internal Error """ try: user_data = UserAuthentication().authenticateUserFromRESTRequest(request) controller = UpperLayerOrchestratorController(user_data) resp = Response(response=controller.get(nffg_id), status=200, mimetype="application/json") return resp except NoResultFound: logging.exception("EXCEPTION - NoResultFound") return ("EXCEPTION - NoResultFound", 404) except requests.HTTPError as err: logging.exception(err) return (str(err), 500) except requests.ConnectionError as err: logging.exception(err) return (str(err), 500) except sessionNotFound as err: logging.exception(err.message) return (err.message, 404) except (unauthorizedRequest, UserNotFound) as err: if request.headers.get("X-Auth-User") is not None: logging.debug("Unauthorized access attempt from user "+request.headers.get("X-Auth-User")) logging.debug(err.message) return ("Unauthorized", 401) except Exception as err: logging.exception(err) return ("Contact the admin: "+ str(err), 500)