feat: Add update firmware for LuxOS Miner

This commit is contained in:
1e9abhi1e10
2024-08-20 16:12:33 +05:30
parent e7ed39fe39
commit b957aa7fba

View File

@@ -14,6 +14,7 @@
# limitations under the License. -
# ------------------------------------------------------------------------------
from typing import List, Optional
import logging
from pyasic.config import MinerConfig
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
@@ -146,6 +147,32 @@ class LUXMiner(LuxOSFirmware):
async def get_config(self) -> MinerConfig:
return self.config
async def upgrade_firmware(self) -> dict:
"""
Upgrade the firmware on a LuxOS miner by calling the 'updaterun' API command.
Returns: Result of the upgrade process.
"""
command = "updaterun"
try:
response = await self.rpc.send_command(command=command)
if not response:
raise ValueError("No response received during the firmware upgrade process.")
if response.get("status") == "success":
logging.info(f"{self.ip}: Firmware upgrade initiated successfully.")
return "Firmware upgrade completed successfully."
else:
logging.error(f"{self.ip}: Firmware upgrade failed. Response: {response}")
raise ValueError(f"Firmware upgrade failed. Response: {response}")
except Exception as e:
logging.error(f"An error occurred during the firmware upgrade process: {e}", exc_info=True)
raise
##################################################
### DATA GATHERING FUNCTIONS (get_{some_data}) ###
##################################################