summaryrefslogtreecommitdiffstats
path: root/ms/py-executor/server.py
diff options
context:
space:
mode:
authorMarek Szwalkiewicz <marek.szwalkiewicz@external.t-mobile.pl>2020-01-30 13:49:18 +0000
committerMarek Szwalkiewicz <marek.szwalkiewicz@external.t-mobile.pl>2020-01-30 13:52:07 +0000
commitbe4c46420944531765ecc8bae7305086d71a36d0 (patch)
treebe9309a134a50e964b1257395d74c41c2da512ef /ms/py-executor/server.py
parentda25e1649c9a10f998c8dde068641d7601a3f00a (diff)
Add Artifact Manager service.
Adds a micro service that offers gRPC interface for CBA artifacts manipulation. By default the service is attached to py-executor but can be ran as a separate service if needed in the future. Issue-ID: CCSDK-1988 Change-Id: I40e20f085ae1c1e81a48f76dbea181af28d9bd0d Signed-off-by: Marek Szwalkiewicz <marek.szwalkiewicz@external.t-mobile.pl>
Diffstat (limited to 'ms/py-executor/server.py')
-rw-r--r--ms/py-executor/server.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/ms/py-executor/server.py b/ms/py-executor/server.py
index f506e9446..7f6537011 100644
--- a/ms/py-executor/server.py
+++ b/ms/py-executor/server.py
@@ -15,16 +15,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from builtins import KeyboardInterrupt
-from concurrent import futures
import logging
+import os
import time
-import grpc
+from builtins import KeyboardInterrupt
+from concurrent import futures
from pathlib import Path, PurePath
-from blueprints_grpc import BluePrintProcessing_pb2_grpc
-from blueprints_grpc.request_header_validator_interceptor import RequestHeaderValidatorInterceptor
+
+import grpc
+from manager.servicer import ArtifactManagerServicer
+from proto.BluePrintManagement_pb2_grpc import add_BluePrintManagementServiceServicer_to_server
+
+from blueprints_grpc import BluePrintProcessing_pb2_grpc, ScriptExecutorConfiguration
from blueprints_grpc.blueprint_processing_server import BluePrintProcessingServer
-from blueprints_grpc import ScriptExecutorConfiguration
+from blueprints_grpc.request_header_validator_interceptor import RequestHeaderValidatorInterceptor
logger = logging.getLogger("Server")
@@ -53,7 +57,9 @@ def serve(configuration: ScriptExecutorConfiguration):
# create server
server = grpc.server(futures.ThreadPoolExecutor(max_workers=int(maxWorkers)))
BluePrintProcessing_pb2_grpc.add_BluePrintProcessingServiceServicer_to_server(
- BluePrintProcessingServer(configuration), server)
+ BluePrintProcessingServer(configuration), server
+ )
+ add_BluePrintManagementServiceServicer_to_server(ArtifactManagerServicer(), server)
# add secure port using credentials
server.add_secure_port('[::]:' + port, server_credentials)
@@ -68,7 +74,9 @@ def serve(configuration: ScriptExecutorConfiguration):
server = grpc.server(futures.ThreadPoolExecutor(max_workers=int(maxWorkers)),
interceptors=(header_validator,))
BluePrintProcessing_pb2_grpc.add_BluePrintProcessingServiceServicer_to_server(
- BluePrintProcessingServer(configuration), server)
+ BluePrintProcessingServer(configuration), server
+ )
+ add_BluePrintManagementServiceServicer_to_server(ArtifactManagerServicer(), server)
server.add_insecure_port('[::]:' + port)
server.start()
@@ -83,7 +91,10 @@ def serve(configuration: ScriptExecutorConfiguration):
if __name__ == '__main__':
- config_file = str(PurePath(Path().absolute())) + '/configuration.ini'
+ default_configuration_file = str(PurePath(Path().absolute(), "../../configuration.ini"))
+ supplied_configuration_file = os.environ.get("CONFIGURATION")
+ config_file = str(os.path.expanduser(Path(supplied_configuration_file or default_configuration_file)))
+
configuration = ScriptExecutorConfiguration(config_file)
logging_formater = '%(asctime)s - %(name)s - %(threadName)s - %(levelname)s - %(message)s'
logging.basicConfig(filename=configuration.script_executor_property('logFile'),