Skip to content

Commit

Permalink
Merge pull request #498 from linl-rh/master
Browse files Browse the repository at this point in the history
Replace invalid strings as AMI name and minor fix no_upload_image
  • Loading branch information
linl-rh authored Dec 26, 2024
2 parents 0fa9136 + ce30e31 commit bacec35
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions os_tests/tests/test_image_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUp(self):
self.bootc_image_builder = None
self.inspect_json_name = None
self.manifest_file = None
self.no_upload_image = None
self.no_upload_image = self.params.get('no_upload_image')

def _podman_login(self,io_user, io_pw, io_name):
cmd = "sudo podman login -u='{}' -p='{}' {}".format(io_user, io_pw, io_name)
Expand Down Expand Up @@ -94,16 +94,26 @@ def test_create_bootc_disk_image(self):
containerfile = self.params.get('containerfile')
current_time = datetime.now().strftime("%y%m%d%S")
if containerfile and containerfile.startswith("http"):
container_url = urlparse(containerfile)
image_mode_dir = "image_mode_" + os.path.basename(container_url.path) + "_{}_{}".format(disk_image_format, current_time)
containerfile_url = urlparse(containerfile)
containerfile_basename = os.path.basename(container_url.path)
if ':' in containerfile_basename:
containerfile_basename = containerfile_basename.replace(':', '_')
if '.' in containerfile_basename:
containerfile_basename = containerfile_basename.replace('.', 'u')
image_mode_dir = "image_mode_" + containerfile_basename + "_{}_{}".format(disk_image_format, current_time)
cmd = "sudo rm {} -rf && sudo mkdir {}".format(image_mode_dir, image_mode_dir)
utils_lib.run_cmd(self, cmd, expect_ret=0, msg="create image_mode_dir")
utils_lib.is_pkg_installed(self, pkg_name='curl', is_install=True, cancel_case=True)
cmd = "sudo curl -o {}/Containerfile {}".format(image_mode_dir, containerfile)
utils_lib.run_cmd(self, cmd, expect_ret=0, msg="download {}".format(containerfile))
else:
if containerfile and containerfile.startswith("/"):
image_mode_dir = "image_mode_" + os.path.basename(containerfile) + "_{}_{}".format(disk_image_format, current_time)
containerfile_basename = os.path.basename(containerfile)
if ':' in containerfile_basename:
containerfile_basename = containerfile_basename.replace(':', '_')
if '.' in containerfile_basename:
containerfile_basename = containerfile_basename.replace('.', 'u')
image_mode_dir = "image_mode_" + containerfile_basename + "_{}_{}".format(disk_image_format, current_time)
cmd = "sudo rm {} -rf && sudo mkdir {}".format(image_mode_dir, image_mode_dir)
utils_lib.run_cmd(self, cmd, expect_ret=0, msg="create image_mode_dir")
utils_lib.copy_file(self, local_file=containerfile, target_file_dir=image_mode_dir, target_file_name='Containerfile')
Expand Down Expand Up @@ -304,7 +314,7 @@ def test_create_bootc_disk_image(self):
#Note the key will display in the disk convert log if you specify it.
utils_lib.run_cmd(self, """
sudo cat << EOF | sudo tee {}/config.toml
[[customizations.user]]
[[blueprint.customizations.user]]
name = "{}"
password = "{}"
key = "{}"
Expand Down Expand Up @@ -361,9 +371,7 @@ def test_create_bootc_disk_image(self):
#Save the created bootable bootc image/disk to attachments in log and delete the image_mode_dir.
#Or if you'd like to copy the disk file to your test environment by manual,
#please specify --no_upload_image in command or set "no_upload_image: True" in yaml.
no_upload_image = self.params.get('no_upload_image')
self.no_upload_image = no_upload_image
if no_upload_image:
if self.no_upload_image:
self.log.info("Please copy Disk image {}/{}.{} based on bootc image {} \
compose-id:{} Digest:{} to your test environment.".format(image_mode_dir,
disk_image_name,
Expand Down

0 comments on commit bacec35

Please sign in to comment.