Ensure unique containers names in docker-puppet
Use paunch as a library to not duplicate code around.
Related-Bug: #1799573
Change-Id: I4386b155a4bdba430dc350914db7a6b6fdf92ac0
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
(cherry picked from commit 6bec6c885f
)
This commit is contained in:
parent
6739889ae2
commit
5ccbdda93e
|
@ -28,7 +28,10 @@ import tempfile
|
||||||
import time
|
import time
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
from paunch import runner as containers_runner
|
||||||
|
|
||||||
logger = None
|
logger = None
|
||||||
|
RUNNER = containers_runner.DockerRunner('docker-puppet')
|
||||||
|
|
||||||
|
|
||||||
def get_logger():
|
def get_logger():
|
||||||
|
@ -309,12 +312,14 @@ def mp_puppet_config(*args):
|
||||||
man_file.write('include ::tripleo::packages\n')
|
man_file.write('include ::tripleo::packages\n')
|
||||||
man_file.write(manifest)
|
man_file.write(manifest)
|
||||||
|
|
||||||
rm_container('docker-puppet-%s' % config_volume)
|
uname = RUNNER.unique_container_name('docker-puppet-%s' %
|
||||||
|
config_volume)
|
||||||
|
rm_container(uname)
|
||||||
pull_image(config_image)
|
pull_image(config_image)
|
||||||
|
|
||||||
dcmd = ['/usr/bin/docker', 'run',
|
dcmd = ['/usr/bin/docker', 'run',
|
||||||
'--user', 'root',
|
'--user', 'root',
|
||||||
'--name', 'docker-puppet-%s' % config_volume,
|
'--name', uname,
|
||||||
'--env', 'PUPPET_TAGS=%s' % puppet_tags,
|
'--env', 'PUPPET_TAGS=%s' % puppet_tags,
|
||||||
'--env', 'NAME=%s' % config_volume,
|
'--env', 'NAME=%s' % config_volume,
|
||||||
'--env', 'HOSTNAME=%s' % short_hostname(),
|
'--env', 'HOSTNAME=%s' % short_hostname(),
|
||||||
|
@ -377,7 +382,7 @@ def mp_puppet_config(*args):
|
||||||
if cmd_stderr:
|
if cmd_stderr:
|
||||||
log.debug(cmd_stderr)
|
log.debug(cmd_stderr)
|
||||||
# only delete successful runs, for debugging
|
# only delete successful runs, for debugging
|
||||||
rm_container('docker-puppet-%s' % config_volume)
|
rm_container(uname)
|
||||||
|
|
||||||
log.info('Finished processing puppet configs for %s' % (config_volume))
|
log.info('Finished processing puppet configs for %s' % (config_volume))
|
||||||
return subproc.returncode
|
return subproc.returncode
|
||||||
|
|
|
@ -82,6 +82,7 @@ paramiko==2.0.0
|
||||||
passlib==1.7.0
|
passlib==1.7.0
|
||||||
Paste==2.0.2
|
Paste==2.0.2
|
||||||
PasteDeploy==1.5.0
|
PasteDeploy==1.5.0
|
||||||
|
paunch==3.2.0
|
||||||
pbr==2.0.0
|
pbr==2.0.0
|
||||||
pecan==1.0.0
|
pecan==1.0.0
|
||||||
pika-pool==0.1.3
|
pika-pool==0.1.3
|
||||||
|
|
|
@ -6,3 +6,4 @@ PyYAML>=3.12 # MIT
|
||||||
Jinja2>=2.10 # BSD License (3 clause)
|
Jinja2>=2.10 # BSD License (3 clause)
|
||||||
six>=1.10.0 # MIT
|
six>=1.10.0 # MIT
|
||||||
tripleo-common>=7.1.0 # Apache-2.0
|
tripleo-common>=7.1.0 # Apache-2.0
|
||||||
|
paunch>=3.2.0 # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue