diff --git a/promenade/control/join_scripts.py b/promenade/control/join_scripts.py index 83bf241e..87c3cb19 100644 --- a/promenade/control/join_scripts.py +++ b/promenade/control/join_scripts.py @@ -25,6 +25,8 @@ from promenade import policy LOG = logging.getLogger(__name__) +SENTINEL = object() + class JoinScriptsResource(BaseResource): """ @@ -48,6 +50,10 @@ class JoinScriptsResource(BaseResource): except exceptions.DeckhandException as e: raise falcon.HTTPInternalServerError(description=str(e)) + if config.get_path('KubernetesNode:.', SENTINEL) != SENTINEL: + raise exceptions.ExistingKubernetesNodeDocumentError( + 'Existing KubernetesNode documents found') + node_document = { 'schema': 'promenade/KubernetesNode/v1', 'metadata': { diff --git a/promenade/exceptions.py b/promenade/exceptions.py index e1373948..37a17bb4 100644 --- a/promenade/exceptions.py +++ b/promenade/exceptions.py @@ -243,6 +243,22 @@ class ApiError(PromenadeException): status = falcon.HTTP_400 +class ExistingKubernetesNodeDocumentError(ApiError): + """ + An exception to represent the unexpected discovery of + `promenade/KubernetesNode/v1` documents in the given site design when + calling the `join-scripts` api. + + **Message:** *Existing KubernetesNode documents found* + + **Troubleshoot:** *KubernetesNode documents should not be in the site + design when using the join-scripts API for join script generation.* + """ + + title = 'Unexpected KubernetesNode document found' + status = falcon.HTTP_400 + + class InvalidFormatError(PromenadeException): """ An exception to cover invalid input formatting.