summaryrefslogtreecommitdiffstats
path: root/ms/artifact-manager
diff options
context:
space:
mode:
authorKAPIL SINGAL <ks220y@att.com>2021-01-22 11:49:51 -0500
committerSingal, Kapil (ks220y) <ks220y@att.com>2021-01-22 12:08:19 -0500
commitadcd4f2bc695840e9ecbc05003bc52c675f22fec (patch)
tree5db58ce9b6b3e86977ca3c697ce3e8998523eb61 /ms/artifact-manager
parentdc8252f3cfa1ddd0c1c8c70513c16c738d840822 (diff)
Renaming Files having BluePrint to have Blueprint
Replacing BluePrint with Blueprint throughout Issue-ID: CCSDK-3098 Signed-off-by: KAPIL SINGAL <ks220y@att.com> Change-Id: Ibee8bad07ae7d9287073db2d4f2f2cd730fa8b96
Diffstat (limited to 'ms/artifact-manager')
-rw-r--r--ms/artifact-manager/README38
-rw-r--r--ms/artifact-manager/manager/servicer.py60
-rw-r--r--ms/artifact-manager/server.py4
-rw-r--r--ms/artifact-manager/tests/servicer_test.py64
4 files changed, 83 insertions, 83 deletions
diff --git a/ms/artifact-manager/README b/ms/artifact-manager/README
index 290dadfde..d77762842 100644
--- a/ms/artifact-manager/README
+++ b/ms/artifact-manager/README
@@ -38,9 +38,9 @@ Upload `CBA.zip` file for storage in artifact manager. File needs to be sent as
#### Example
```
-stub: BluePrintManagementServiceStub = BluePrintManagementServiceStub(channel)
+stub: BlueprintManagementServiceStub = BlueprintManagementServiceStub(channel)
with open(file_path, "rb") as cba_file:
- msg: BluePrintUploadInput = BluePrintUploadInput()
+ msg: BlueprintUploadInput = BlueprintUploadInput()
msg.actionIdentifiers.blueprintName = "Test"
msg.actionIdentifiers.blueprintVersion = "0.0.1"
msg.fileChunk.chunk = cba_file.read()
@@ -54,8 +54,8 @@ Download existing `CBA.zip` file.
#### Example
```
-stub: BluePrintManagementServiceStub = BluePrintManagementServiceStub(channel)
-msg: BluePrintDownloadInput = BluePrintDownloadInput()
+stub: BlueprintManagementServiceStub = BlueprintManagementServiceStub(channel)
+msg: BlueprintDownloadInput = BlueprintDownloadInput()
msg.actionIdentifiers.blueprintName = "Test"
msg.actionIdentifiers.blueprintVersion = "0.0.1"
return stub.downloadBlueprint(msg)
@@ -67,8 +67,8 @@ Delete existing `CBA.zip` file.
#### Example
```
-stub: BluePrintManagementServiceStub = BluePrintManagementServiceStub(channel)
-msg: BluePrintRemoveInput = BluePrintRemoveInput()
+stub: BlueprintManagementServiceStub = BlueprintManagementServiceStub(channel)
+msg: BlueprintRemoveInput = BlueprintRemoveInput()
msg.actionIdentifiers.blueprintName = "Test"
msg.actionIdentifiers.blueprintVersion = "0.0.1"
return stub.removeBlueprint(msg)
@@ -88,13 +88,13 @@ import zipfile
from grpc import Channel, ChannelCredentials, insecure_channel, secure_channel, ssl_channel_credentials
-from proto.BluePrintManagement_pb2 import (
- BluePrintDownloadInput,
- BluePrintRemoveInput,
- BluePrintUploadInput,
- BluePrintManagementOutput,
+from proto.BlueprintManagement_pb2 import (
+ BlueprintDownloadInput,
+ BlueprintRemoveInput,
+ BlueprintUploadInput,
+ BlueprintManagementOutput,
)
-from proto.BluePrintManagement_pb2_grpc import BluePrintManagementServiceStub
+from proto.BlueprintManagement_pb2_grpc import BlueprintManagementServiceStub
logging.basicConfig(level=logging.DEBUG)
@@ -139,31 +139,31 @@ class Client:
:param config: ConfigParser object with "client" section
"""
self.channel: Channel = channel
- self.stub: BluePrintManagementServiceStub = BluePrintManagementServiceStub(self.channel)
+ self.stub: BlueprintManagementServiceStub = BlueprintManagementServiceStub(self.channel)
self.config = config
- def upload(self) -> BluePrintManagementOutput:
+ def upload(self) -> BlueprintManagementOutput:
"""Prepare upload message and send it to server."""
logging.info("Call upload client method")
with open(self.config.get("client", "cba_file"), "rb") as cba_file:
- msg: BluePrintUploadInput = BluePrintUploadInput()
+ msg: BlueprintUploadInput = BlueprintUploadInput()
msg.actionIdentifiers.blueprintName = "Test"
msg.actionIdentifiers.blueprintVersion = "0.0.1"
msg.fileChunk.chunk = cba_file.read()
return self.stub.uploadBlueprint(msg)
- def download(self) -> BluePrintManagementOutput:
+ def download(self) -> BlueprintManagementOutput:
"""Prepare download message and send it to server."""
logging.info("Call download client method")
- msg: BluePrintDownloadInput = BluePrintDownloadInput()
+ msg: BlueprintDownloadInput = BlueprintDownloadInput()
msg.actionIdentifiers.blueprintName = "Test"
msg.actionIdentifiers.blueprintVersion = "0.0.1"
return self.stub.downloadBlueprint(msg)
- def remove(self) -> BluePrintManagementOutput:
+ def remove(self) -> BlueprintManagementOutput:
"""Prepare remove message and send it to server."""
logging.info("Call remove client method")
- msg: BluePrintRemoveInput = BluePrintRemoveInput()
+ msg: BlueprintRemoveInput = BlueprintRemoveInput()
msg.actionIdentifiers.blueprintName = "Test"
msg.actionIdentifiers.blueprintVersion = "0.0.1"
return self.stub.removeBlueprint(msg)
diff --git a/ms/artifact-manager/manager/servicer.py b/ms/artifact-manager/manager/servicer.py
index be740b0e3..fd05fe0cc 100644
--- a/ms/artifact-manager/manager/servicer.py
+++ b/ms/artifact-manager/manager/servicer.py
@@ -23,13 +23,13 @@ from manager.configuration import get_logger
from manager.errors import ArtifactManagerError, InvalidRequestError
from manager.utils import Repository, RepositoryStrategy
from onaplogging.mdcContext import MDC
-from proto.BluePrintManagement_pb2 import (
- BluePrintDownloadInput,
- BluePrintManagementOutput,
- BluePrintRemoveInput,
- BluePrintUploadInput,
+from proto.BlueprintManagement_pb2 import (
+ BlueprintDownloadInput,
+ BlueprintManagementOutput,
+ BlueprintRemoveInput,
+ BlueprintUploadInput,
)
-from proto.BluePrintManagement_pb2_grpc import BluePrintManagementServiceServicer
+from proto.BlueprintManagement_pb2_grpc import BlueprintManagementServiceServicer
MDC_DATETIME_FORMAT = r"%Y-%m-%dT%H:%M:%S.%f%z"
COMMON_HEADER_DATETIME_FORMAT = r"%Y-%m-%dT%H:%M:%S.%fZ"
@@ -47,13 +47,13 @@ def fill_common_header(func):
@wraps(func)
def _decorator(
servicer: "ArtifactManagerServicer",
- request: Union[BluePrintDownloadInput, BluePrintRemoveInput, BluePrintUploadInput],
+ request: Union[BlueprintDownloadInput, BlueprintRemoveInput, BlueprintUploadInput],
context: ServicerContext,
- ) -> BluePrintManagementOutput:
+ ) -> BlueprintManagementOutput:
if not all([request.actionIdentifiers.blueprintName, request.actionIdentifiers.blueprintVersion]):
- raise InvalidRequestError("Request has to have set both BluePrint name and version")
- output: BluePrintManagementOutput = func(servicer, request, context)
+ raise InvalidRequestError("Request has to have set both Blueprint name and version")
+ output: BlueprintManagementOutput = func(servicer, request, context)
# Set same values for every handler
output.commonHeader.CopyFrom(request.commonHeader)
output.commonHeader.timestamp = datetime.utcnow().strftime(COMMON_HEADER_DATETIME_FORMAT)
@@ -72,11 +72,11 @@ def translate_exception_to_response(func):
@wraps(func)
def _handler(
servicer: "ArtifactManagerServicer",
- request: Union[BluePrintDownloadInput, BluePrintRemoveInput, BluePrintUploadInput],
+ request: Union[BlueprintDownloadInput, BlueprintRemoveInput, BlueprintUploadInput],
context: ServicerContext,
- ) -> BluePrintManagementOutput:
+ ) -> BlueprintManagementOutput:
try:
- output: BluePrintManagementOutput = func(servicer, request, context)
+ output: BlueprintManagementOutput = func(servicer, request, context)
output.status.code = 200
output.status.message = "success"
except ArtifactManagerError as error:
@@ -84,7 +84,7 @@ def translate_exception_to_response(func):
# Every ArtifactManagerError based exception has status_code paramenter
# which has to be set in output. Use also exception's message to
# set errorMessage of the output.
- output: BluePrintManagementOutput = BluePrintManagementOutput()
+ output: BlueprintManagementOutput = BlueprintManagementOutput()
output.status.code = error.status_code
output.status.message = "failure"
output.status.errorMessage = str(error.message)
@@ -112,9 +112,9 @@ def prepare_logging_context(func):
@wraps(func)
def _decorator(
servicer: "ArtifactManagerServicer",
- request: Union[BluePrintDownloadInput, BluePrintRemoveInput, BluePrintUploadInput],
+ request: Union[BlueprintDownloadInput, BlueprintRemoveInput, BlueprintUploadInput],
context: ServicerContext,
- ) -> BluePrintManagementOutput:
+ ) -> BlueprintManagementOutput:
MDC.put("RequestID", request.commonHeader.requestId)
MDC.put("InvocationID", request.commonHeader.subRequestId)
MDC.put("ServiceName", servicer.__class__.__name__)
@@ -129,14 +129,14 @@ def prepare_logging_context(func):
MDC.put("TargetServiceName", func.__name__)
MDC.put("Server", socket.getfqdn())
- output: BluePrintManagementOutput = func(servicer, request, context)
+ output: BlueprintManagementOutput = func(servicer, request, context)
MDC.clear()
return output
return _decorator
-class ArtifactManagerServicer(BluePrintManagementServiceServicer):
+class ArtifactManagerServicer(BlueprintManagementServiceServicer):
"""ArtifactManagerServer class.
Implements methods defined in proto files to manage artifacts repository.
@@ -169,15 +169,15 @@ class ArtifactManagerServicer(BluePrintManagementServiceServicer):
@prepare_logging_context
@translate_exception_to_response
@fill_common_header
- def downloadBlueprint(self, request: BluePrintDownloadInput, context: ServicerContext) -> BluePrintManagementOutput:
+ def downloadBlueprint(self, request: BlueprintDownloadInput, context: ServicerContext) -> BlueprintManagementOutput:
"""Download blueprint file request method.
Currently it only logs when is called and all base class method.
- :param request: BluePrintDownloadInput
+ :param request: BlueprintDownloadInput
:param context: ServicerContext
- :return: BluePrintManagementOutput
+ :return: BlueprintManagementOutput
"""
- output: BluePrintManagementOutput = BluePrintManagementOutput()
+ output: BlueprintManagementOutput = BlueprintManagementOutput()
output.fileChunk.chunk = self.repository.download_blueprint(
request.actionIdentifiers.blueprintName, request.actionIdentifiers.blueprintVersion
)
@@ -193,13 +193,13 @@ class ArtifactManagerServicer(BluePrintManagementServiceServicer):
@prepare_logging_context
@translate_exception_to_response
@fill_common_header
- def uploadBlueprint(self, request: BluePrintUploadInput, context: ServicerContext) -> BluePrintManagementOutput:
+ def uploadBlueprint(self, request: BlueprintUploadInput, context: ServicerContext) -> BlueprintManagementOutput:
"""Upload blueprint file request method.
Currently it only logs when is called and all base class method.
- :param request: BluePrintUploadInput
+ :param request: BlueprintUploadInput
:param context: ServicerContext
- :return: BluePrintManagementOutput
+ :return: BlueprintManagementOutput
"""
self.repository.upload_blueprint(
request.fileChunk.chunk, request.actionIdentifiers.blueprintName, request.actionIdentifiers.blueprintVersion
@@ -211,18 +211,18 @@ class ArtifactManagerServicer(BluePrintManagementServiceServicer):
),
extra={"mdc": MDC.result()},
)
- return BluePrintManagementOutput()
+ return BlueprintManagementOutput()
@prepare_logging_context
@translate_exception_to_response
@fill_common_header
- def removeBlueprint(self, request: BluePrintRemoveInput, context: ServicerContext) -> BluePrintManagementOutput:
+ def removeBlueprint(self, request: BlueprintRemoveInput, context: ServicerContext) -> BlueprintManagementOutput:
"""Remove blueprint file request method.
Currently it only logs when is called and all base class method.
- :param request: BluePrintRemoveInput
+ :param request: BlueprintRemoveInput
:param context: ServicerContext
- :return: BluePrintManagementOutput
+ :return: BlueprintManagementOutput
"""
self.repository.remove_blueprint(
request.actionIdentifiers.blueprintName, request.actionIdentifiers.blueprintVersion
@@ -234,4 +234,4 @@ class ArtifactManagerServicer(BluePrintManagementServiceServicer):
),
extra={"mdc": MDC.result()},
)
- return BluePrintManagementOutput()
+ return BlueprintManagementOutput()
diff --git a/ms/artifact-manager/server.py b/ms/artifact-manager/server.py
index fe70c8855..10034fe58 100644
--- a/ms/artifact-manager/server.py
+++ b/ms/artifact-manager/server.py
@@ -19,7 +19,7 @@ import click
from grpc import server as grpc_server
from manager.configuration import config
from manager.servicer import ArtifactManagerServicer
-from proto.BluePrintManagement_pb2_grpc import add_BluePrintManagementServiceServicer_to_server
+from proto.BlueprintManagement_pb2_grpc import add_BlueprintManagementServiceServicer_to_server
@click.command()
@@ -34,7 +34,7 @@ def run_server():
max_workers: int = int(config["artifactManagerServer"]["maxWorkers"])
server: grpc_server = grpc_server(ThreadPoolExecutor(max_workers=max_workers))
- add_BluePrintManagementServiceServicer_to_server(ArtifactManagerServicer(), server)
+ add_BlueprintManagementServiceServicer_to_server(ArtifactManagerServicer(), server)
port_number: int = int(config["artifactManagerServer"]["port"])
server.add_insecure_port(f"[::]:{port_number}")
diff --git a/ms/artifact-manager/tests/servicer_test.py b/ms/artifact-manager/tests/servicer_test.py
index 131e6fb2c..702e1046a 100644
--- a/ms/artifact-manager/tests/servicer_test.py
+++ b/ms/artifact-manager/tests/servicer_test.py
@@ -19,17 +19,17 @@ from unittest.mock import patch
import manager.utils
from manager.servicer import ArtifactManagerServicer
-from proto.BluePrintCommon_pb2 import ActionIdentifiers, CommonHeader
-from proto.BluePrintManagement_pb2 import (
- BluePrintDownloadInput,
- BluePrintManagementOutput,
- BluePrintRemoveInput,
- BluePrintUploadInput,
+from proto.BlueprintCommon_pb2 import ActionIdentifiers, CommonHeader
+from proto.BlueprintManagement_pb2 import (
+ BlueprintDownloadInput,
+ BlueprintManagementOutput,
+ BlueprintRemoveInput,
+ BlueprintUploadInput,
FileChunk,
)
-from proto.BluePrintManagement_pb2_grpc import (
- BluePrintManagementServiceStub,
- add_BluePrintManagementServiceServicer_to_server,
+from proto.BlueprintManagement_pb2_grpc import (
+ BlueprintManagementServiceStub,
+ add_BlueprintManagementServiceServicer_to_server,
)
from pytest import fixture
@@ -50,7 +50,7 @@ class MockZipFile(zipfile.ZipFile):
@fixture(scope="module")
def grpc_add_to_server():
"""pytest-grpcio required function."""
- return add_BluePrintManagementServiceServicer_to_server
+ return add_BlueprintManagementServiceServicer_to_server
@fixture(scope="module")
@@ -62,34 +62,34 @@ def grpc_servicer():
@fixture(scope="module") # noqa
def grpc_stub_cls(grpc_channel):
"""pytest-grpcio required function."""
- return BluePrintManagementServiceStub
+ return BlueprintManagementServiceStub
def test_servicer_upload_handler_header_failure(grpc_stub):
"""Test servicer upload handler."""
- request: BluePrintUploadInput = BluePrintUploadInput()
- output: BluePrintManagementOutput = grpc_stub.uploadBlueprint(request)
+ request: BlueprintUploadInput = BlueprintUploadInput()
+ output: BlueprintManagementOutput = grpc_stub.uploadBlueprint(request)
assert output.status.code == 500
assert output.status.message == "failure"
- assert output.status.errorMessage == "Request has to have set both BluePrint name and version"
+ assert output.status.errorMessage == "Request has to have set both Blueprint name and version"
def test_servicer_download_handler_header_failure(grpc_stub):
"""Test servicer download handler."""
- request: BluePrintDownloadInput = BluePrintDownloadInput()
- output: BluePrintManagementOutput = grpc_stub.downloadBlueprint(request)
+ request: BlueprintDownloadInput = BlueprintDownloadInput()
+ output: BlueprintManagementOutput = grpc_stub.downloadBlueprint(request)
assert output.status.code == 500
assert output.status.message == "failure"
- assert output.status.errorMessage == "Request has to have set both BluePrint name and version"
+ assert output.status.errorMessage == "Request has to have set both Blueprint name and version"
def test_servicer_remove_handler_header_failure(grpc_stub):
"""Test servicer remove handler."""
- request: BluePrintRemoveInput = BluePrintRemoveInput()
- output: BluePrintManagementOutput = grpc_stub.removeBlueprint(request)
+ request: BlueprintRemoveInput = BlueprintRemoveInput()
+ output: BlueprintManagementOutput = grpc_stub.removeBlueprint(request)
assert output.status.code == 500
assert output.status.message == "failure"
- assert output.status.errorMessage == "Request has to have set both BluePrint name and version"
+ assert output.status.errorMessage == "Request has to have set both Blueprint name and version"
def test_servicer_upload_handler_failure(grpc_stub):
@@ -97,8 +97,8 @@ def test_servicer_upload_handler_failure(grpc_stub):
action_identifiers: ActionIdentifiers = ActionIdentifiers()
action_identifiers.blueprintName = "sample-cba"
action_identifiers.blueprintVersion = "1.0.0"
- request: BluePrintUploadInput = BluePrintUploadInput(actionIdentifiers=action_identifiers)
- output: BluePrintManagementOutput = grpc_stub.uploadBlueprint(request)
+ request: BlueprintUploadInput = BlueprintUploadInput(actionIdentifiers=action_identifiers)
+ output: BlueprintManagementOutput = grpc_stub.uploadBlueprint(request)
assert output.status.code == 500
assert output.status.message == "failure"
assert output.status.errorMessage == "Invalid request"
@@ -109,8 +109,8 @@ def test_servicer_download_handler_failure(grpc_stub):
action_identifiers: ActionIdentifiers = ActionIdentifiers()
action_identifiers.blueprintName = "sample-cba"
action_identifiers.blueprintVersion = "2.0.0"
- request: BluePrintDownloadInput = BluePrintDownloadInput(actionIdentifiers=action_identifiers)
- output: BluePrintManagementOutput = grpc_stub.downloadBlueprint(request)
+ request: BlueprintDownloadInput = BlueprintDownloadInput(actionIdentifiers=action_identifiers)
+ output: BlueprintManagementOutput = grpc_stub.downloadBlueprint(request)
assert output.status.code == 500
assert output.status.message == "failure"
assert output.status.errorMessage == "Artifact not found"
@@ -121,8 +121,8 @@ def test_servicer_remove_handler_failure(grpc_stub):
action_identifiers: ActionIdentifiers = ActionIdentifiers()
action_identifiers.blueprintName = "sample-cba"
action_identifiers.blueprintVersion = "1.0.0"
- request: BluePrintRemoveInput = BluePrintRemoveInput(actionIdentifiers=action_identifiers)
- output: BluePrintManagementOutput = grpc_stub.removeBlueprint(request)
+ request: BlueprintRemoveInput = BlueprintRemoveInput(actionIdentifiers=action_identifiers)
+ output: BlueprintManagementOutput = grpc_stub.removeBlueprint(request)
assert output.status.code == 500
assert output.status.message == "failure"
assert output.status.errorMessage == "Artifact not found"
@@ -146,10 +146,10 @@ def test_servicer_upload_handler_success(grpc_stub):
# fmt: off
with patch.object(os, "makedirs", return_value=None), \
patch.object(manager.utils, 'ZipFile', return_value=MockZipFile()):
- request: BluePrintUploadInput = BluePrintUploadInput(
+ request: BlueprintUploadInput = BlueprintUploadInput(
commonHeader=header, fileChunk=file_chunk, actionIdentifiers=action_identifiers
)
- output: BluePrintManagementOutput = grpc_stub.uploadBlueprint(request)
+ output: BlueprintManagementOutput = grpc_stub.uploadBlueprint(request)
# fmt: on
assert output.status.code == 200
assert output.status.message == "success"
@@ -168,10 +168,10 @@ def test_servicer_download_handler_success(grpc_stub):
action_identifiers.actionName = "SampleScript"
with patch.object(os.path, "exists", return_value=True):
- request: BluePrintDownloadInput = BluePrintDownloadInput(
+ request: BlueprintDownloadInput = BlueprintDownloadInput(
commonHeader=header, actionIdentifiers=action_identifiers
)
- output: BluePrintManagementOutput = grpc_stub.downloadBlueprint(request)
+ output: BlueprintManagementOutput = grpc_stub.downloadBlueprint(request)
assert output.status.code == 200
assert output.status.message == "success"
assert output.fileChunk.chunk == ZIP_FILE_BINARY
@@ -190,7 +190,7 @@ def test_servicer_remove_handler_success(grpc_stub):
action_identifiers.actionName = "SampleScript"
with patch.object(shutil, "rmtree", return_value=None) as mock_rmtree:
- request: BluePrintRemoveInput = BluePrintRemoveInput(commonHeader=header, actionIdentifiers=action_identifiers)
- output: BluePrintManagementOutput = grpc_stub.removeBlueprint(request)
+ request: BlueprintRemoveInput = BlueprintRemoveInput(commonHeader=header, actionIdentifiers=action_identifiers)
+ output: BlueprintManagementOutput = grpc_stub.removeBlueprint(request)
assert output.status.code == 200
assert output.status.message == "success"