system host-pv-show keyword
Change-Id: I862ab7fea71aebc45f469382a607369809689388
This commit is contained in:
parent
b026aa8784
commit
df77b97ff1
@ -16,6 +16,12 @@ class SystemHostPvObject:
|
||||
self.pv_type: str = None
|
||||
self.lvm_vg_name: str = None
|
||||
self.ihost_uuid : str = None
|
||||
self.lvm_pv_uuid: str = None
|
||||
self.lvm_pv_size_gib: float = -1.0
|
||||
self.lvm_pe_total: int = -1
|
||||
self.lvm_pe_alloced: int = -1
|
||||
self.created_at: str = None
|
||||
self.updated_at: str = None
|
||||
|
||||
|
||||
def set_uuid(self, uuid):
|
||||
@ -124,4 +130,76 @@ class SystemHostPvObject:
|
||||
"""
|
||||
Getter for host-lvg ihost_uuid
|
||||
"""
|
||||
return self.ihost_uuid
|
||||
return self.ihost_uuid
|
||||
|
||||
def set_lvm_pv_uuid(self, lvm_pv_uuid):
|
||||
"""
|
||||
Setter for the lvm_pv_uuid
|
||||
"""
|
||||
self.lvm_pv_uuid = lvm_pv_uuid
|
||||
|
||||
def get_lvm_pv_uuid(self) -> str:
|
||||
"""
|
||||
Getter for the lvm_pv_uuid
|
||||
"""
|
||||
return self.lvm_pv_uuid
|
||||
|
||||
def set_lvm_pv_size_gib(self, lvm_pv_size_gib):
|
||||
"""
|
||||
Setter for the lvm_pv_size_gib
|
||||
"""
|
||||
self.lvm_pv_size_gib = lvm_pv_size_gib
|
||||
|
||||
def get_lvm_pv_size_gib(self) -> float:
|
||||
"""
|
||||
Getter for the lvm_pv_size_gib
|
||||
"""
|
||||
return self.lvm_pv_size_gib
|
||||
|
||||
def set_lvm_pe_total(self, lvm_pe_total):
|
||||
"""
|
||||
Setter for the lvm_pe_total
|
||||
"""
|
||||
self.lvm_pe_total = lvm_pe_total
|
||||
|
||||
def get_lvm_pe_total(self) -> int:
|
||||
"""
|
||||
Getter for the lvm_pe_total
|
||||
"""
|
||||
return self.lvm_pe_total
|
||||
|
||||
def set_lvm_pe_alloced(self, lvm_pe_alloced):
|
||||
"""
|
||||
Setter for the lvm_pe_alloced
|
||||
"""
|
||||
self.lvm_pe_alloced = lvm_pe_alloced
|
||||
|
||||
def get_lvm_pe_alloced(self) -> int:
|
||||
"""
|
||||
Getter for the lvm_pe_total
|
||||
"""
|
||||
return self.lvm_pe_alloced
|
||||
|
||||
def set_created_at(self, created_at):
|
||||
"""
|
||||
Setter for host-lvg created_at
|
||||
"""
|
||||
self.created_at = created_at
|
||||
|
||||
def get_created_at(self) -> str:
|
||||
"""
|
||||
Getter for host-lvg created_at
|
||||
"""
|
||||
return self.created_at
|
||||
|
||||
def set_updated_at(self, updated_at):
|
||||
"""
|
||||
Setter for host-lvg updated_at
|
||||
"""
|
||||
self.updated_at = updated_at
|
||||
|
||||
def get_updated_at(self) -> str:
|
||||
"""
|
||||
Getter for host-lvg updated_at
|
||||
"""
|
||||
return self.updated_at
|
@ -0,0 +1,76 @@
|
||||
from framework.exceptions.keyword_exception import KeywordException
|
||||
from framework.logging.automation_logger import get_logger
|
||||
from keywords.cloud_platform.system.host.objects.system_host_pv_object import SystemHostPvObject
|
||||
from keywords.cloud_platform.system.system_vertical_table_parser import SystemVerticalTableParser
|
||||
|
||||
class SystemHostPvShowOutput:
|
||||
"""
|
||||
This class parses the output of 'system host-pv-show' command into an object of type SystemHostPvObject.
|
||||
"""
|
||||
|
||||
def __init__(self, system_output):
|
||||
"""
|
||||
Constructor
|
||||
|
||||
Args:
|
||||
system_output (str): Output of the 'system host-pv-show' command.
|
||||
|
||||
Raises:
|
||||
KeywordException: If the output is not valid.
|
||||
"""
|
||||
|
||||
system_vertical_table_parser = SystemVerticalTableParser(system_output)
|
||||
output_values = system_vertical_table_parser.get_output_values_dict()
|
||||
|
||||
if self.is_valid_output(output_values):
|
||||
self.system_host_pv = SystemHostPvObject()
|
||||
self.system_host_pv.set_uuid(output_values['uuid'])
|
||||
self.system_host_pv.set_pv_state(output_values['pv_state'])
|
||||
self.system_host_pv.set_pv_type(output_values['pv_type'])
|
||||
self.system_host_pv.set_disk_or_part_uuid(output_values['disk_or_part_uuid'])
|
||||
self.system_host_pv.set_disk_or_part_device_node(output_values['disk_or_part_device_node'])
|
||||
self.system_host_pv.set_disk_or_part_device_path(output_values['disk_or_part_device_path'])
|
||||
self.system_host_pv.set_lvm_pv_name(output_values['lvm_pv_name'])
|
||||
self.system_host_pv.set_lvm_vg_name(output_values['lvm_vg_name'])
|
||||
self.system_host_pv.set_lvm_pv_uuid(output_values['lvm_pv_uuid'])
|
||||
self.system_host_pv.set_lvm_pv_size_gib(output_values['lvm_pv_size_gib'])
|
||||
self.system_host_pv.set_lvm_pe_total(output_values['lvm_pe_total'])
|
||||
self.system_host_pv.set_lvm_pe_alloced(output_values['lvm_pe_alloced'])
|
||||
self.system_host_pv.set_ihost_uuid(output_values['ihost_uuid'])
|
||||
self.system_host_pv.set_created_at(output_values['created_at'])
|
||||
self.system_host_pv.set_updated_at(output_values['updated_at'])
|
||||
else:
|
||||
raise KeywordException(f"The output line {output_values} was not valid")
|
||||
|
||||
def get_system_host_pv_show(self):
|
||||
"""
|
||||
Returns the parsed system host-pv object.
|
||||
|
||||
Returns:
|
||||
SystemHostAddrObject: The parsed system host-pv object.
|
||||
"""
|
||||
|
||||
return self.system_host_pv
|
||||
|
||||
@staticmethod
|
||||
def is_valid_output(value):
|
||||
"""
|
||||
Checks if the output contains all the expected fields.
|
||||
|
||||
Args:
|
||||
value (dict): The dictionary of output values.
|
||||
|
||||
Returns:
|
||||
bool: True if the output contains all required fields, False otherwise.
|
||||
"""
|
||||
|
||||
required_fields = ["uuid", "pv_state", "pv_type", "disk_or_part_uuid", "disk_or_part_device_node", "disk_or_part_device_path",
|
||||
"lvm_pv_name", "lvm_vg_name", "lvm_pv_uuid", "lvm_pv_size_gib", "lvm_pe_total",
|
||||
"lvm_pe_alloced", "ihost_uuid", "created_at", "updated_at"]
|
||||
valid = True
|
||||
for field in required_fields:
|
||||
if field not in value:
|
||||
get_logger().log_error(f'{field} is not in the output value')
|
||||
valid = False
|
||||
break
|
||||
return valid
|
@ -1,6 +1,7 @@
|
||||
from keywords.base_keyword import BaseKeyword
|
||||
from keywords.cloud_platform.command_wrappers import source_openrc
|
||||
from keywords.cloud_platform.system.host.objects.system_host_pv_output import SystemHostPvOutput
|
||||
from keywords.cloud_platform.system.host.objects.system_host_pv_show_output import SystemHostPvShowOutput
|
||||
|
||||
|
||||
class SystemHostPvKeywords(BaseKeyword):
|
||||
@ -30,4 +31,21 @@ class SystemHostPvKeywords(BaseKeyword):
|
||||
output = self.ssh_connection.send(command)
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
system_host_lvg_output = SystemHostPvOutput(output)
|
||||
return system_host_lvg_output
|
||||
return system_host_lvg_output
|
||||
|
||||
def get_system_host_pv_show(self, host_id, uuid) -> SystemHostPvShowOutput:
|
||||
"""
|
||||
Gets the system host-pv-show
|
||||
|
||||
Args:
|
||||
host_id: name or id of the host
|
||||
uuid: uuid of pv
|
||||
Returns:
|
||||
SystemHostPvShowOutput object.
|
||||
|
||||
"""
|
||||
command = source_openrc(f'system host-pv-show {host_id} {uuid}')
|
||||
output = self.ssh_connection.send(command)
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
system_host_pv_output = SystemHostPvShowOutput(output)
|
||||
return system_host_pv_output
|
Loading…
Reference in New Issue
Block a user