feat: Add update firmware for LuxOS Miner
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
# limitations under the License. -
|
# limitations under the License. -
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
import logging
|
||||||
|
|
||||||
from pyasic.config import MinerConfig
|
from pyasic.config import MinerConfig
|
||||||
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
|
from pyasic.data import AlgoHashRate, Fan, HashBoard, HashUnit
|
||||||
@@ -146,6 +147,32 @@ class LUXMiner(LuxOSFirmware):
|
|||||||
async def get_config(self) -> MinerConfig:
|
async def get_config(self) -> MinerConfig:
|
||||||
return self.config
|
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}) ###
|
### DATA GATHERING FUNCTIONS (get_{some_data}) ###
|
||||||
##################################################
|
##################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user