Add dcmanager subcloud deploy show keyword
Implements keywords for 'dcmanager subcloud deploy show' Test Plan: PASS: Unit tests for output parser with real command samples PASS: Unit tests for empty output handling PASS: Unit tests for various field value scenarios Change-Id: Ifd9943004732ec980c9b0a5130347401e72c136d Signed-off-by: Abhishek jaiswal <abhishek.jaiswal@windriver.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from framework.ssh.ssh_connection import SSHConnection
|
||||
from keywords.base_keyword import BaseKeyword
|
||||
from keywords.cloud_platform.command_wrappers import source_openrc
|
||||
from keywords.cloud_platform.dcmanager.objects.dcmanager_subcloud_deploy_show_output import DcManagerSubcloudDeployShowOutput
|
||||
|
||||
|
||||
class DcManagerSubcloudDeployShowKeywords(BaseKeyword):
|
||||
"""This class contains all the keywords related to the 'dcmanager subcloud deploy show' commands."""
|
||||
|
||||
def __init__(self, ssh_connection: SSHConnection):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
ssh_connection (SSHConnection): The SSH connection object used for executing commands.
|
||||
"""
|
||||
self.ssh_connection = ssh_connection
|
||||
|
||||
def get_dcmanager_subcloud_deploy_show(self) -> DcManagerSubcloudDeployShowOutput:
|
||||
"""Gets the 'dcmanager subcloud deploy show' output.
|
||||
|
||||
Returns:
|
||||
DcManagerSubcloudDeployShowOutput: A DcManagerSubcloudDeployShowOutput object representing the
|
||||
output of the command 'dcmanager subcloud deploy show'.
|
||||
"""
|
||||
output = self.ssh_connection.send(source_openrc("dcmanager subcloud deploy show"))
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
return DcManagerSubcloudDeployShowOutput(output)
|
||||
@@ -0,0 +1,104 @@
|
||||
class DcManagerSubcloudDeployShowObject:
|
||||
"""This class represents a subcloud deploy configuration as object.
|
||||
|
||||
This is typically the output of the 'dcmanager subcloud deploy show' command output table as shown below.
|
||||
|
||||
+------------------+-------+
|
||||
| Field | Value |
|
||||
+------------------+-------+
|
||||
| deploy_playbook | None |
|
||||
| deploy_overrides | None |
|
||||
| deploy_chart | None |
|
||||
| prestage_images | None |
|
||||
| software_version | 25.09 |
|
||||
+------------------+-------+
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""Constructor for the DcManagerSubcloudDeployShowObject class."""
|
||||
self.deploy_playbook: str
|
||||
self.deploy_overrides: str
|
||||
self.deploy_chart: str
|
||||
self.prestage_images: str
|
||||
self.software_version: str
|
||||
|
||||
def get_deploy_playbook(self) -> str:
|
||||
"""Getter for the Deploy Playbook.
|
||||
|
||||
Returns:
|
||||
str: The deploy playbook value.
|
||||
"""
|
||||
return self.deploy_playbook
|
||||
|
||||
def set_deploy_playbook(self, deploy_playbook: str):
|
||||
"""Setter for the Deploy Playbook.
|
||||
|
||||
Args:
|
||||
deploy_playbook (str): The deploy playbook value.
|
||||
"""
|
||||
self.deploy_playbook = deploy_playbook
|
||||
|
||||
def get_deploy_overrides(self) -> str:
|
||||
"""Getter for the Deploy Overrides.
|
||||
|
||||
Returns:
|
||||
str: The deploy overrides value.
|
||||
"""
|
||||
return self.deploy_overrides
|
||||
|
||||
def set_deploy_overrides(self, deploy_overrides: str):
|
||||
"""Setter for the Deploy Overrides.
|
||||
|
||||
Args:
|
||||
deploy_overrides (str): The deploy overrides value.
|
||||
"""
|
||||
self.deploy_overrides = deploy_overrides
|
||||
|
||||
def get_deploy_chart(self) -> str:
|
||||
"""Getter for the Deploy Chart.
|
||||
|
||||
Returns:
|
||||
str: The deploy chart value.
|
||||
"""
|
||||
return self.deploy_chart
|
||||
|
||||
def set_deploy_chart(self, deploy_chart: str):
|
||||
"""Setter for the Deploy Chart.
|
||||
|
||||
Args:
|
||||
deploy_chart (str): The deploy chart value.
|
||||
"""
|
||||
self.deploy_chart = deploy_chart
|
||||
|
||||
def get_prestage_images(self) -> str:
|
||||
"""Getter for the Prestage Images.
|
||||
|
||||
Returns:
|
||||
str: The prestage images value.
|
||||
"""
|
||||
return self.prestage_images
|
||||
|
||||
def set_prestage_images(self, prestage_images: str):
|
||||
"""Setter for the Prestage Images.
|
||||
|
||||
Args:
|
||||
prestage_images (str): The prestage images value.
|
||||
"""
|
||||
self.prestage_images = prestage_images
|
||||
|
||||
def get_software_version(self) -> str:
|
||||
"""Getter for the Software Version.
|
||||
|
||||
Returns:
|
||||
str: The software version value.
|
||||
"""
|
||||
return self.software_version
|
||||
|
||||
def set_software_version(self, software_version: str):
|
||||
"""Setter for the Software Version.
|
||||
|
||||
Args:
|
||||
software_version (str): The software version value.
|
||||
"""
|
||||
self.software_version = software_version
|
||||
@@ -0,0 +1,35 @@
|
||||
from keywords.cloud_platform.dcmanager.dcmanager_vertical_table_parser import DcManagerVerticalTableParser
|
||||
from keywords.cloud_platform.dcmanager.objects.dcmanager_subcloud_deploy_show_object import DcManagerSubcloudDeployShowObject
|
||||
|
||||
|
||||
class DcManagerSubcloudDeployShowOutput:
|
||||
"""Represents the output of 'dcmanager subcloud deploy show' command as DcManagerSubcloudDeployShowObject object."""
|
||||
|
||||
def __init__(self, dcmanager_subcloud_deploy_show_output: list[str]) -> None:
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
dcmanager_subcloud_deploy_show_output (list[str]): The output of 'dcmanager subcloud deploy show' command.
|
||||
"""
|
||||
self.dcmanager_subcloud_deploy_show_object: DcManagerSubcloudDeployShowObject
|
||||
dcmanager_vertical_table_parser = DcManagerVerticalTableParser(dcmanager_subcloud_deploy_show_output)
|
||||
output_values = dcmanager_vertical_table_parser.get_output_values_dict()
|
||||
|
||||
dcmanager_subcloud_deploy_show_object = DcManagerSubcloudDeployShowObject()
|
||||
|
||||
dcmanager_subcloud_deploy_show_object.set_deploy_playbook(output_values.get("deploy_playbook"))
|
||||
dcmanager_subcloud_deploy_show_object.set_deploy_overrides(output_values.get("deploy_overrides"))
|
||||
dcmanager_subcloud_deploy_show_object.set_deploy_chart(output_values.get("deploy_chart"))
|
||||
dcmanager_subcloud_deploy_show_object.set_prestage_images(output_values.get("prestage_images"))
|
||||
dcmanager_subcloud_deploy_show_object.set_software_version(output_values.get("software_version"))
|
||||
|
||||
self.dcmanager_subcloud_deploy_show_object = dcmanager_subcloud_deploy_show_object
|
||||
|
||||
def get_dcmanager_subcloud_deploy_show_object(self) -> DcManagerSubcloudDeployShowObject:
|
||||
"""Get the DcManagerSubcloudDeployShowObject.
|
||||
|
||||
Returns:
|
||||
DcManagerSubcloudDeployShowObject: The DcManagerSubcloudDeployShowObject object representing the
|
||||
output of the command 'dcmanager subcloud deploy show'.
|
||||
"""
|
||||
return self.dcmanager_subcloud_deploy_show_object
|
||||
@@ -0,0 +1,78 @@
|
||||
"""Unit tests for DcManagerSubcloudDeployShowOutput parser."""
|
||||
|
||||
import unittest
|
||||
|
||||
from keywords.cloud_platform.dcmanager.objects.dcmanager_subcloud_deploy_show_output import DcManagerSubcloudDeployShowOutput
|
||||
|
||||
|
||||
class TestDcManagerSubcloudDeployShowOutput(unittest.TestCase):
|
||||
"""Test cases for DcManagerSubcloudDeployShowOutput parser."""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up test data with real command output."""
|
||||
self.sample_output = [
|
||||
"+------------------+-------+",
|
||||
"| Field | Value |",
|
||||
"+------------------+-------+",
|
||||
"| deploy_playbook | None |",
|
||||
"| deploy_overrides | None |",
|
||||
"| deploy_chart | None |",
|
||||
"| prestage_images | None |",
|
||||
"| software_version | 25.09 |",
|
||||
"+------------------+-------+"
|
||||
]
|
||||
|
||||
def test_parse_deploy_show_output(self):
|
||||
"""Test parsing of deploy show output."""
|
||||
output = DcManagerSubcloudDeployShowOutput(self.sample_output)
|
||||
deploy_obj = output.get_dcmanager_subcloud_deploy_show_object()
|
||||
|
||||
self.assertEqual(deploy_obj.get_deploy_playbook(), "None")
|
||||
self.assertEqual(deploy_obj.get_deploy_overrides(), "None")
|
||||
self.assertEqual(deploy_obj.get_deploy_chart(), "None")
|
||||
self.assertEqual(deploy_obj.get_prestage_images(), "None")
|
||||
self.assertEqual(deploy_obj.get_software_version(), "25.09")
|
||||
|
||||
def test_parse_deploy_show_with_values(self):
|
||||
"""Test parsing of deploy show output with actual values."""
|
||||
sample_output_with_values = [
|
||||
"+------------------+------------------------+",
|
||||
"| Field | Value |",
|
||||
"+------------------+------------------------+",
|
||||
"| deploy_playbook | /opt/platform/playbook |",
|
||||
"| deploy_overrides | /opt/platform/override |",
|
||||
"| deploy_chart | /opt/platform/chart |",
|
||||
"| prestage_images | /opt/platform/images |",
|
||||
"| software_version | 25.09 |",
|
||||
"+------------------+------------------------+"
|
||||
]
|
||||
|
||||
output = DcManagerSubcloudDeployShowOutput(sample_output_with_values)
|
||||
deploy_obj = output.get_dcmanager_subcloud_deploy_show_object()
|
||||
|
||||
self.assertEqual(deploy_obj.get_deploy_playbook(), "/opt/platform/playbook")
|
||||
self.assertEqual(deploy_obj.get_deploy_overrides(), "/opt/platform/override")
|
||||
self.assertEqual(deploy_obj.get_deploy_chart(), "/opt/platform/chart")
|
||||
self.assertEqual(deploy_obj.get_prestage_images(), "/opt/platform/images")
|
||||
self.assertEqual(deploy_obj.get_software_version(), "25.09")
|
||||
|
||||
def test_empty_output(self):
|
||||
"""Test parsing empty output."""
|
||||
empty_output = [
|
||||
"+------------------+-------+",
|
||||
"| Field | Value |",
|
||||
"+------------------+-------+",
|
||||
"+------------------+-------+"
|
||||
]
|
||||
output = DcManagerSubcloudDeployShowOutput(empty_output)
|
||||
deploy_obj = output.get_dcmanager_subcloud_deploy_show_object()
|
||||
|
||||
self.assertIsNone(deploy_obj.get_deploy_playbook())
|
||||
self.assertIsNone(deploy_obj.get_deploy_overrides())
|
||||
self.assertIsNone(deploy_obj.get_deploy_chart())
|
||||
self.assertIsNone(deploy_obj.get_prestage_images())
|
||||
self.assertIsNone(deploy_obj.get_software_version())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user