diff options
author | 2017-09-05 10:26:20 +0200 | |
---|---|---|
committer | 2017-09-05 10:42:51 +0200 | |
commit | 06bdb6a3ec916137534e627a275141c8c587dff7 (patch) | |
tree | 1ca2d6c9f3b3faddcc1c6cf26742cc0872690a9c /cloudify/scripts/onap/configure_docker_secret_workaround.py | |
parent | 2ba543f3568fb58f53f4d0f646ff4a2c8519d7d4 (diff) |
Cloudify blueprint for provisioning ONAP
Change-Id: Ibe0f7e626ca2ebaa5d5e7eeb49a33b19cacbafa3
Issue-ID: OOM-106
Signed-off-by: Krzysztof Bijakowski <krzysztof.bijakowski@cloudify.co>
Diffstat (limited to 'cloudify/scripts/onap/configure_docker_secret_workaround.py')
-rw-r--r-- | cloudify/scripts/onap/configure_docker_secret_workaround.py | 40 |
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') |