Skip to content

Commit

Permalink
localapi: use new update_data functions
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
  • Loading branch information
Noltari committed Jul 23, 2024
1 parent 3d5619c commit 523f126
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions aioqsw/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ def update_data(self, data: dict[str, Any], lacp_start: int | None) -> None:
port.set_id(port_id)
self.lacp_ports[port_id] = port

self.calc()

def calc(self) -> None:
"""Calculate Ports Status data."""
link = 0
Expand Down
17 changes: 12 additions & 5 deletions aioqsw/localapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ async def validate(self) -> SystemBoard:
async def update_firmware_condition(self) -> None:
"""Update firmware/condition."""
firmware_condition = await self.get_firmware_condition()
self.firmware_condition = FirmwareCondition(firmware_condition)
if self.firmware_condition is None:
self.firmware_condition = FirmwareCondition(firmware_condition)
else:
self.firmware_condition.update_data(firmware_condition)

async def update_firmware_info(self) -> None:
"""Update firmware/info."""
Expand All @@ -380,9 +383,10 @@ async def update_ports_statistics(self, lacp_start: int | None) -> None:
async def update_ports_status(self, lacp_start: int | None) -> None:
"""Update ports/status."""
ports_status_data = await self.get_ports_status()
ports_status = PortsStatus(ports_status_data, lacp_start)
ports_status.calc()
self.ports_status = ports_status
if self.ports_status is None:
self.ports_status = PortsStatus(ports_status_data, lacp_start)
else:
self.ports_status.update_data(ports_status_data, lacp_start)

async def update_system_board(self) -> None:
"""Update system/board."""
Expand All @@ -394,7 +398,10 @@ async def update_system_sensor(self) -> None:
"""Update system/sensor."""
try:
system_sensor = await self.get_system_sensor()
self.system_sensor = SystemSensor(system_sensor)
if self.system_sensor is None:
self.system_sensor = SystemSensor(system_sensor)
else:
self.system_sensor.update_data(system_sensor)
except InternalServerError as err:
if self._first_update:
raise err
Expand Down

0 comments on commit 523f126

Please sign in to comment.