Merge "Allow host of docker daemon to be configurable"

This commit is contained in:
Jenkins
2017-04-17 06:21:48 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 2 deletions

View File

@@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import socket
from oslo_config import cfg from oslo_config import cfg
docker_group = cfg.OptGroup(name='docker', docker_group = cfg.OptGroup(name='docker',
@@ -40,9 +42,13 @@ docker_opts = [
cfg.StrOpt('key_file', cfg.StrOpt('key_file',
help='Location of TLS private key file for ' help='Location of TLS private key file for '
'securing docker api requests (tlskey).'), 'securing docker api requests (tlskey).'),
cfg.StrOpt('docker_remote_api_host',
default=socket.gethostname(),
sample_default='localhost',
help='Defines the remote api host for the docker daemon.'),
cfg.StrOpt('docker_remote_api_port', cfg.StrOpt('docker_remote_api_port',
default='2375', default='2375',
help='Defines the remote api port for the container.'), help='Defines the remote api port for the docker daemon.'),
] ]
ALL_OPTS = (docker_opts) ALL_OPTS = (docker_opts)

View File

@@ -421,8 +421,9 @@ class DockerDriver(driver.ContainerDriver):
@check_container_id @check_container_id
def get_websocket_url(self, container): def get_websocket_url(self, container):
version = CONF.docker.docker_remote_api_version version = CONF.docker.docker_remote_api_version
remote_api_host = CONF.docker.docker_remote_api_host
remote_api_port = CONF.docker.docker_remote_api_port remote_api_port = CONF.docker.docker_remote_api_port
url = "ws://" + container.host + ":" + remote_api_port + \ url = "ws://" + remote_api_host + ":" + remote_api_port + \
"/v" + version + "/containers/" + container.container_id \ "/v" + version + "/containers/" + container.container_id \
+ ATTACH_FLAG + ATTACH_FLAG
return url return url