
Adding first system test TC (deploy, scale and remove deployments). Adding new object for k8s get deployments. Updating existing k8s objects to support "namespace" parameter. Change-Id: Ifafa33638ab2949cac9d985b56ed90bebe2495a8 --- Signed-off-by: Vitor Vidal <vitor.vidaldenegreiros@windriver.com> --- Change-Id: I6c0cd323826f0c38db2289fb420d49bf432e1930
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from keywords.base_keyword import BaseKeyword
|
|
from keywords.k8s.k8s_command_wrapper import export_k8s_config
|
|
|
|
class KubectlScaleDeploymentsKeywords(BaseKeyword):
|
|
"""
|
|
Keyword class for scaling deployments
|
|
"""
|
|
|
|
def __init__(self, ssh_connection):
|
|
"""
|
|
Constructor
|
|
Args:
|
|
ssh_connection:
|
|
"""
|
|
self.ssh_connection = ssh_connection
|
|
|
|
def scale_deployment(self, deployment_name: str, replicas: int, namespace: str = None) -> str:
|
|
"""
|
|
Scales the given deployment to the specified number of replicas.
|
|
Args:
|
|
deployment_name (str): the deployment name
|
|
replicas (int): number of replicas
|
|
namespace (str): the namespace
|
|
|
|
Returns: the output of the scale command
|
|
"""
|
|
cmd = f"kubectl scale deployment {deployment_name} --replicas={replicas}"
|
|
if namespace:
|
|
cmd = f"{cmd} -n {namespace}"
|
|
output = self.ssh_connection.send(export_k8s_config(cmd))
|
|
self.validate_success_return_code(self.ssh_connection)
|
|
return output |