Add method for extracting .tar.gz to .tar
- Add decompress_tar_gz in TarKeywords to convert .tar.gz to .tar without extracting contents. - Update deploy_images_to_local_registry in test_sanity.py to use decompress_tar_gz for node-hello-alpine.tar.gz. - Ensure .tar.gz is properly decompressed before loading into the local registry. - Previously, extract_tar_file was used, which fully extracted the tar contents instead of just converting to .tar. - Fix minor linting issues in tar_keywords. Change-Id: I88beb819c80360c7162921bb2e64c7080531be36 Signed-off-by: Andrew Vaillancourt <andrew.vaillancourt@windriver.com>
This commit is contained in:
@@ -10,14 +10,28 @@ class TarKeywords(BaseKeyword):
|
||||
def __init__(self, ssh_connection: SSHConnection):
|
||||
self.ssh_connection = ssh_connection
|
||||
|
||||
def extract_tar_file(self, file_name: str):
|
||||
def extract_tar_file(self, file_name: str) -> None:
|
||||
"""
|
||||
Extracts the given tar file
|
||||
Extracts the given tar file.
|
||||
|
||||
Args:
|
||||
file_name (): the name of the file
|
||||
|
||||
Returns:
|
||||
|
||||
file_name (str): the name of the file.
|
||||
"""
|
||||
self.ssh_connection.send(f'tar -xzvf {file_name}')
|
||||
self.ssh_connection.send(f"tar -xzvf {file_name}")
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
|
||||
def decompress_tar_gz(self, file_name: str) -> None:
|
||||
"""
|
||||
Decompresses a .tar.gz file into a .tar file without extracting contents.
|
||||
|
||||
Args:
|
||||
file_name (str): The path to the .tar.gz file.
|
||||
|
||||
Raises:
|
||||
ValueError: If the file does not have a .tar.gz extension.
|
||||
"""
|
||||
if not file_name.endswith(".tar.gz"):
|
||||
raise ValueError("File must be a .tar.gz archive.")
|
||||
|
||||
self.ssh_connection.send(f"gunzip -f {file_name}")
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
|
@@ -1447,7 +1447,7 @@ def deploy_images_to_local_registry(ssh_connection: SSHConnection):
|
||||
docker_load_image_keywords.push_docker_image_to_registry("pv-test", local_registry)
|
||||
|
||||
file_keywords.upload_file(get_stx_resource_path("resources/cloud_platform/images/node-hello-alpine/node-hello-alpine.tar.gz"), "/home/sysadmin/node-hello-alpine.tar.gz", overwrite=False)
|
||||
TarKeywords(ssh_connection).extract_tar_file("/home/sysadmin/node-hello-alpine.tar.gz")
|
||||
TarKeywords(ssh_connection).decompress_tar_gz("/home/sysadmin/node-hello-alpine.tar.gz")
|
||||
docker_load_image_keywords.load_docker_image_to_host("node-hello-alpine.tar")
|
||||
docker_load_image_keywords.tag_docker_image_for_registry("registry.local:9001/node-hello:alpine", "node-hello", local_registry)
|
||||
docker_load_image_keywords.push_docker_image_to_registry("node-hello", local_registry)
|
||||
|
Reference in New Issue
Block a user