# ============LICENSE_START=======================================================
# org.onap.dcae
# ================================================================================
-# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
from dcae_cli.util.logger import get_logger
from dcae_cli.util.exc import DcaeException
-
dlog = get_logger('Docker')
_reg_img = 'gliderlabs/registrator:latest'
except:
raise DockerError('Could not connect to the Docker daemon. Is it running?')
-def _get_docker_client(client_funcs=(docker.Client, docker.from_env)):
- '''Returns a docker client object'''
- for func in client_funcs:
- try:
- client = func(version='auto')
- client.ping()
- return client
- except:
- continue
- raise DockerError('Could not connect to the Docker daemon. Is it running?')
-
def image_exists(image):
'''Returns True if the image exists locally'''
- client = _get_docker_client()
+ client = docker.from_env(version="auto")
return True if client.images(image) else False
client = get_docker_client(profile, logins=logins)
config = doc.create_container_config(client, image, envs, hcp)
+
return _run_container(client, config, name=instance_name, wait=should_wait)
except Exception as e:
dlog.error("Error while undeploying Docker container/image: {0}".format(e))
return False
+
+def reconfigure(client, instance_name, command):
+ """ Execute the Reconfig script in the Docker container """
+
+ # 'command' has 3 parts in a list (1 Command and 2 ARGs)
+ exec_Id = client.exec_create(container=instance_name, cmd=command)
+
+ exec_start_resp = client.exec_start(exec_Id, stream=True)
+
+ # Using a 'single' generator response to solve issue of 'start_exec' returning control after 6 minutes
+ for response in exec_start_resp:
+ dlog.info("Reconfig Script execution response: {:}".format(response))
+ exec_start_resp.close()
+ break