Chassis status output was missing some fields that crashed the parser, switched to check if the key is in the dict instead of checking for None. Also a fix to import statement that was crashing starlingx runs. Change-Id: I217a8f92ae43510b71c139b97c70c9c8e6966917
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
from framework.ssh.ssh_connection import SSHConnection
|
|
from keywords.base_keyword import BaseKeyword
|
|
from keywords.k8s.k8s_command_wrapper import export_k8s_config
|
|
|
|
|
|
class KubectlApplyPodsKeywords(BaseKeyword):
|
|
"""
|
|
Class for Kubectl apply pod keywords
|
|
|
|
"""
|
|
|
|
def __init__(self, ssh_connection: SSHConnection):
|
|
"""
|
|
Constructor
|
|
|
|
Args:
|
|
ssh_connection (SSHConnection): ssh connection
|
|
|
|
"""
|
|
self.ssh_connection = ssh_connection
|
|
|
|
def apply_from_yaml(self, yaml_file: str) -> None:
|
|
"""
|
|
Applies a pod yaml config
|
|
|
|
Args:
|
|
yaml_file (str): the yaml file
|
|
|
|
Returns: None
|
|
|
|
"""
|
|
self.ssh_connection.send(export_k8s_config(f"kubectl apply -f {yaml_file}"))
|
|
self.validate_success_return_code(self.ssh_connection)
|
|
|
|
def fail_apply_from_yaml(self, yaml_file: str) -> None:
|
|
"""
|
|
Checks if applying a pod yaml config fails
|
|
|
|
Args:
|
|
yaml_file (str): the yaml file
|
|
|
|
Returns:
|
|
None: This function does not return a value.
|
|
|
|
"""
|
|
self.ssh_connection.send(export_k8s_config(f"kubectl apply -f {yaml_file}"))
|
|
rc = self.ssh_connection.get_return_code()
|
|
if 1 != rc:
|
|
raise Exception(f"Expected deployment of {yaml_file} to fail, instead it passed, investigate")
|