diff --git a/src/pathcomp/backend/Dockerfile b/src/pathcomp/backend/Dockerfile index c131f8b6426feaa256bb1a249b55ea5808104e6c..869e4b64938c828af600b1e478b15278ddbfc981 100644 --- a/src/pathcomp/backend/Dockerfile +++ b/src/pathcomp/backend/Dockerfile @@ -19,7 +19,7 @@ FROM ubuntu:20.04 AS builder ARG DEBIAN_FRONTEND=noninteractive # Install build software -RUN apt-get update -y && apt-get install build-essential gcovr libglib2.0-dev -y +RUN apt-get update -y && apt-get install build-essential curl gcovr libglib2.0-dev -y # mkdir RUN mkdir -p /var/teraflow diff --git a/src/pathcomp/frontend/Config.py b/src/pathcomp/frontend/Config.py index af7c277c553157a6d058815d7e6cb11cba5d169d..75f910e36f92ca008b318cfc61718ae81f94214c 100644 --- a/src/pathcomp/frontend/Config.py +++ b/src/pathcomp/frontend/Config.py @@ -12,6 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -BACKEND_URL = 'http://{:s}:{:d}/pathComp/api/v1/compRoute' -BACKEND_HOST = '172.28.0.2' -BACKEND_PORT = 8081 +import os + +DEFAULT_PATHCOMP_BACKEND_SCHEME = 'http' +DEFAULT_PATHCOMP_BACKEND_HOST = '127.0.0.1' +DEFAULT_PATHCOMP_BACKEND_PORT = 8081 +DEFAULT_PATHCOMP_BACKEND_BASEURL = '/pathComp/api/v1/compRoute' + +PATHCOMP_BACKEND_SCHEME = str(os.environ.get('PATHCOMP_BACKEND_SCHEME', DEFAULT_PATHCOMP_BACKEND_SCHEME )) +PATHCOMP_BACKEND_HOST = str(os.environ.get('PATHCOMP_BACKEND_HOST', DEFAULT_PATHCOMP_BACKEND_HOST )) +PATHCOMP_BACKEND_PORT = int(os.environ.get('PATHCOMP_BACKEND_PORT', DEFAULT_PATHCOMP_BACKEND_PORT )) +PATHCOMP_BACKEND_BASEURL = str(os.environ.get('PATHCOMP_BACKEND_BASEURL', DEFAULT_PATHCOMP_BACKEND_BASEURL)) + +BACKEND_URL = '{:s}://{:s}:{:d}{:s}'.format( + PATHCOMP_BACKEND_SCHEME, PATHCOMP_BACKEND_HOST, PATHCOMP_BACKEND_PORT, PATHCOMP_BACKEND_BASEURL) diff --git a/src/pathcomp/frontend/service/PathCompServiceServicerImpl.py b/src/pathcomp/frontend/service/PathCompServiceServicerImpl.py index 3cf1121915d834b28bdec00851975397a9d82df5..b1da515631320d7d77dee073e8985a8d63bd3c30 100644 --- a/src/pathcomp/frontend/service/PathCompServiceServicerImpl.py +++ b/src/pathcomp/frontend/service/PathCompServiceServicerImpl.py @@ -20,7 +20,7 @@ from common.proto.pathcomp_pb2_grpc import PathCompServiceServicer from common.rpc_method_wrapper.Decorator import create_metrics, safe_and_metered_rpc_method from common.tools.grpc.Tools import grpc_message_to_json_string from context.client.ContextClient import ContextClient -from pathcomp.frontend.Config import BACKEND_HOST, BACKEND_PORT, BACKEND_URL +from pathcomp.frontend.Config import BACKEND_URL from pathcomp.frontend.service.tools.ComposeRequest import compose_device, compose_link, compose_service #from pathcomp.frontend.service.tools.Constants import CapacityUnit @@ -37,9 +37,6 @@ class PathCompServiceServicerImpl(PathCompServiceServicer): @safe_and_metered_rpc_method(METRICS, LOGGER) def Compute(self, request : PathCompRequest, context : grpc.ServicerContext) -> PathCompReply: - import os - LOGGER.info('os.environ={:s}'.format(str(os.environ))) - LOGGER.info('[Compute] begin ; request = {:s}'.format(grpc_message_to_json_string(request))) algorithm = request.WhichOneof('algorithm') @@ -105,8 +102,7 @@ class PathCompServiceServicerImpl(PathCompServiceServicer): #with open('pc-req.json', 'w', encoding='UTF-8') as f: # f.write(json.dumps(request, sort_keys=True, indent=4)) - backend_url = BACKEND_URL.format(BACKEND_HOST, BACKEND_PORT) - reply = requests.post(backend_url, json=request) + reply = requests.post(BACKEND_URL, json=request) if reply.status_code not in {requests.codes.ok}: raise Exception('Backend error({:s}) for request({:s})'.format( str(reply.content.decode('UTF-8')), json.dumps(request, sort_keys=True)))