Skip to content

Commit 0483bcb

Browse files
committed
Add image pull
1 parent 67d85da commit 0483bcb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

galaxy_importer/ansible_test/runners/local_image.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,37 @@ def run(self):
4949
shutil.copy(self.filepath, archive_path)
5050
volume = f"{archive_path}:/archive/archive.tar.gz"
5151

52+
self.log.info("Pulling image...")
53+
self._pull_image(container_engine=container_engine)
54+
5255
self.log.info("Running image...")
5356
self._run_image(container_engine=container_engine, volume=volume)
5457

58+
def _pull_image(self, container_engine):
59+
# TODO: use a separate image repo, repo or org is private
60+
cmd = [
61+
container_engine,
62+
"pull",
63+
"quay.io/cloudservices/automation-hub-ansible-test",
64+
]
65+
self.log.debug(f"cmd={cmd}")
66+
67+
proc = Popen(
68+
cmd,
69+
stdout=PIPE,
70+
stderr=STDOUT,
71+
encoding="utf-8",
72+
)
73+
74+
for line in proc.stdout:
75+
self.log.info(line.strip())
76+
77+
return_code = proc.wait()
78+
if return_code != 0:
79+
raise exceptions.AnsibleTestError(
80+
"An exception occurred in {}, returncode={}".format(" ".join(cmd), return_code)
81+
)
82+
5583
def _run_image(self, container_engine, volume):
5684
cmd = [
5785
container_engine, "run",

0 commit comments

Comments
 (0)