diff --git a/keywords/linux/tar/tar_keywords.py b/keywords/linux/tar/tar_keywords.py index f5fbdcea..f9bc2399 100644 --- a/keywords/linux/tar/tar_keywords.py +++ b/keywords/linux/tar/tar_keywords.py @@ -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) diff --git a/testcases/cloud_platform/sanity/test_sanity.py b/testcases/cloud_platform/sanity/test_sanity.py index d4b6ca6a..5035cd6a 100644 --- a/testcases/cloud_platform/sanity/test_sanity.py +++ b/testcases/cloud_platform/sanity/test_sanity.py @@ -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)