Skip to content

Commit

Permalink
[fwutil]: Fix component table layout.
Browse files Browse the repository at this point in the history
Signed-off-by: Nazarii Hnydyn <[email protected]>
  • Loading branch information
nazariig committed Mar 23, 2020
1 parent d0f8091 commit 455b731
Showing 1 changed file with 55 additions and 78 deletions.
133 changes: 55 additions & 78 deletions fwutil/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ def get_status(self, force):

append_chassis_name = self.is_chassis_has_components()
append_module_na = not self.is_modular_chassis()
module_name = NA

for chassis_name, chassis_component_map in self.chassis_component_map.items():
for chassis_component_name, chassis_component in chassis_component_map.items():
Expand All @@ -538,17 +539,6 @@ def get_status(self, force):
status = self.FW_STATUS_UP_TO_DATE
info = NA

if append_chassis_name:
append_chassis_name = False
else:
chassis_name = EMPTY

if append_module_na:
module_name = NA
append_module_na = False
else:
module_name = EMPTY

if component:
firmware_path = component[self.__pcp.FIRMWARE_KEY]
firmware_version_available = component[self.__pcp.VERSION_KEY]
Expand All @@ -563,8 +553,8 @@ def get_status(self, force):

status_table.append(
[
chassis_name,
module_name,
chassis_name if append_chassis_name else EMPTY,
module_name if append_module_na else EMPTY,
chassis_component_name,
firmware_path,
firmware_version,
Expand All @@ -573,11 +563,19 @@ def get_status(self, force):
]
)

if append_chassis_name:
append_chassis_name = False

if append_module_na:
append_module_na = False

append_chassis_name = not self.is_chassis_has_components()
chassis_name = self.chassis.get_name()

if self.is_modular_chassis():
for module_name, module_component_map in self.module_component_map.items():
append_module_name = True

for module_component_name, module_component in module_component_map.items():
component = self.__pcp.module_component_map[module_name][module_component_name]

Expand All @@ -589,17 +587,6 @@ def get_status(self, force):
status = self.FW_STATUS_UP_TO_DATE
info = NA

if append_chassis_name:
chassis_name = self.chassis.get_name()
append_chassis_name = False
else:
chassis_name = EMPTY

if append_module_name:
append_module_name = False
else:
module_name = EMPTY

if component:
firmware_path = component[self.__pcp.FIRMWARE_KEY]
firmware_version_available = component[self.__pcp.VERSION_KEY]
Expand All @@ -614,8 +601,8 @@ def get_status(self, force):

status_table.append(
[
chassis_name,
module_name,
chassis_name if append_chassis_name else EMPTY,
module_name if append_module_name else EMPTY,
module_component_name,
firmware_path,
firmware_version,
Expand All @@ -624,13 +611,20 @@ def get_status(self, force):
]
)

if append_chassis_name:
append_chassis_name = False

if append_module_name:
append_module_name = False

return tabulate(status_table, self.STATUS_HEADER, tablefmt=self.FORMAT)

def update_firmware(self, force):
status_table = [ ]

append_chassis_name = self.is_chassis_has_components()
append_module_na = not self.is_modular_chassis()
module_name = NA

for chassis_name, chassis_component_map in self.chassis_component_map.items():
for chassis_component_name, chassis_component in chassis_component_map.items():
Expand All @@ -645,17 +639,6 @@ def update_firmware(self, force):

status = self.FW_STATUS_UP_TO_DATE

if append_chassis_name:
append_chassis_name = False
else:
chassis_name = EMPTY

if append_module_na:
module_name = NA
append_module_na = False
else:
module_name = EMPTY

if component:
firmware_path = component[self.__pcp.FIRMWARE_KEY]
firmware_version_available = component[self.__pcp.VERSION_KEY]
Expand Down Expand Up @@ -685,14 +668,21 @@ def update_firmware(self, force):

status_table.append(
[
chassis_name,
module_name,
chassis_name if append_chassis_name else EMPTY,
module_name if append_module_na else EMPTY,
chassis_component_name,
status,
]
)

if append_chassis_name:
append_chassis_name = False

if append_module_na:
append_module_na = False

append_chassis_name = not self.is_chassis_has_components()
chassis_name = self.chassis.get_name()

if self.is_modular_chassis():
for module_name, module_component_map in self.module_component_map.items():
Expand All @@ -711,17 +701,6 @@ def update_firmware(self, force):

status = self.FW_STATUS_UP_TO_DATE

if append_chassis_name:
chassis_name = self.chassis.get_name()
append_chassis_name = False
else:
chassis_name = EMPTY

if append_module_name:
append_module_name = False
else:
module_name = EMPTY

if component:
firmware_path = component[self.__pcp.FIRMWARE_KEY]
firmware_version_available = component[self.__pcp.VERSION_KEY]
Expand Down Expand Up @@ -751,13 +730,19 @@ def update_firmware(self, force):

status_table.append(
[
chassis_name,
module_name,
chassis_name if append_chassis_name else EMPTY,
module_name if append_module_name else EMPTY,
module_component_name,
status,
]
)

if append_chassis_name:
append_chassis_name = False

if append_module_name:
append_module_name = False

return tabulate(status_table, self.RESULT_HEADER, tablefmt=self.FORMAT)


Expand All @@ -776,34 +761,31 @@ def get_status(self):

append_chassis_name = self.is_chassis_has_components()
append_module_na = not self.is_modular_chassis()
module_name = NA

for chassis_name, chassis_component_map in self.chassis_component_map.items():
for chassis_component_name, chassis_component in chassis_component_map.items():
firmware_version = chassis_component.get_firmware_version()
description = chassis_component.get_description()

if append_chassis_name:
append_chassis_name = False
else:
chassis_name = EMPTY

if append_module_na:
module_name = NA
append_module_na = False
else:
module_name = EMPTY

status_table.append(
[
chassis_name,
module_name,
chassis_name if append_chassis_name else EMPTY,
module_name if append_module_na else EMPTY,
chassis_component_name,
firmware_version,
description
]
)

if append_chassis_name:
append_chassis_name = False

if append_module_na:
append_module_na = False

append_chassis_name = not self.is_chassis_has_components()
chassis_name = self.chassis.get_name()

if self.is_modular_chassis():
for module_name, module_component_map in self.module_component_map.items():
Expand All @@ -813,25 +795,20 @@ def get_status(self):
firmware_version = module_component.get_firmware_version()
description = module_component.get_description()

if append_chassis_name:
chassis_name = self.chassis.get_name()
append_chassis_name = False
else:
chassis_name = EMPTY

if append_module_name:
append_module_name = False
else:
module_name = EMPTY

status_table.append(
[
chassis_name,
module_name,
chassis_name if append_chassis_name else EMPTY,
module_name if append_module_name else EMPTY,
module_component_name,
firmware_version,
description
]
)

if append_chassis_name:
append_chassis_name = False

if append_module_name:
append_module_name = False

return tabulate(status_table, self.HEADER, tablefmt=self.FORMAT)

0 comments on commit 455b731

Please sign in to comment.