aboutsummaryrefslogtreecommitdiffstats
path: root/cloudify/scripts/onap/configure_docker_secret_workaround.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudify/scripts/onap/configure_docker_secret_workaround.py')
-rw-r--r--cloudify/scripts/onap/configure_docker_secret_workaround.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/cloudify/scripts/onap/configure_docker_secret_workaround.py b/cloudify/scripts/onap/configure_docker_secret_workaround.py
new file mode 100644
index 0000000000..6e9deff059
--- /dev/null
+++ b/cloudify/scripts/onap/configure_docker_secret_workaround.py
@@ -0,0 +1,40 @@
+from fabric.api import run
+
+from cloudify import ctx
+from cloudify.exceptions import NonRecoverableError
+
+
+def _retrieve_namespace():
+ namespace = ctx.node.properties.get(
+ 'namespace',
+ ctx.node.properties
+ .get('options', {})
+ .get('namespace', None)
+ )
+
+ if not namespace:
+ raise NonRecoverableError(
+ 'Namespace is not defined (node={})'.format(ctx.node.name)
+ )
+
+ return namespace
+
+
+def configure_secret():
+ namespace = _retrieve_namespace()
+ ctx.logger.info(
+ 'Configuring docker secrets for namespace: {0}'.format(namespace)
+ )
+
+ command = 'kubectl create secret ' \
+ 'docker-registry onap-docker-registry-key ' \
+ '--docker-server=nexus3.onap.org:10001 ' \
+ '--docker-username=docker ' \
+ '--docker-password=docker ' \
+ '--docker-email=email@email.com ' \
+ '--namespace={0}'.format(namespace)
+
+ ctx.logger.info('Command "{0}" will be executed'.format(command))
+ run(command)
+
+ ctx.logger.info('Docker secrets configured successfully')