added an old version of Bosminer for non plus miners to be able to update
This commit is contained in:
@@ -42,9 +42,9 @@ class BaseMiner:
|
||||
except Exception as e:
|
||||
# logging.warning(f"{self} raised an exception: {e}")
|
||||
raise e
|
||||
except OSError:
|
||||
except OSError as e:
|
||||
logging.warning(f"Connection refused: {self}")
|
||||
return None
|
||||
raise e
|
||||
except Exception as e:
|
||||
# logging.warning(f"{self} raised an exception: {e}")
|
||||
raise e
|
||||
|
||||
@@ -4,6 +4,7 @@ import toml
|
||||
from config.bos import bos_config_convert, general_config_convert_bos
|
||||
import logging
|
||||
from settings import MINER_FACTORY_GET_VERSION_RETRIES as DATA_RETRIES
|
||||
import asyncssh
|
||||
|
||||
|
||||
class BOSMiner(BaseMiner):
|
||||
@@ -368,3 +369,46 @@ class BOSMiner(BaseMiner):
|
||||
data["Nominal"] = True
|
||||
|
||||
return data
|
||||
|
||||
|
||||
class BOSMinerOld(BaseMiner):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.api = BOSMinerAPI(ip)
|
||||
self.api_type = "BOSMiner"
|
||||
self.uname = "root"
|
||||
self.pwd = "admin"
|
||||
|
||||
|
||||
async def send_ssh_command(self, cmd: str) -> str or None:
|
||||
"""Send a command to the miner over ssh.
|
||||
|
||||
:return: Result of the command or None.
|
||||
"""
|
||||
result = None
|
||||
|
||||
# open an ssh connection
|
||||
async with await asyncssh.connect("192.168.1.11", username="root") as conn:
|
||||
# 3 retries
|
||||
for i in range(3):
|
||||
try:
|
||||
# run the command and get the result
|
||||
result = await conn.run(cmd)
|
||||
result = result.stdout
|
||||
except Exception as e:
|
||||
# if the command fails, log it
|
||||
logging.warning(f"{self} command {cmd} error: {e}")
|
||||
|
||||
# on the 3rd retry, return None
|
||||
if i == 3:
|
||||
return
|
||||
continue
|
||||
# return the result, either command output or None
|
||||
return str(result)
|
||||
|
||||
|
||||
async def update_to_plus(self):
|
||||
result = await self.send_ssh_command("opkg update && opkg install bos_plus")
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from miners.avalonminer import *
|
||||
from miners._backends.cgminer import CGMiner
|
||||
from miners._backends.bmminer import BMMiner
|
||||
from miners._backends.bosminer import BOSMiner
|
||||
from miners._backends.bosminer import BOSMinerOld
|
||||
|
||||
from miners.unknown import UnknownMiner
|
||||
|
||||
@@ -23,73 +24,74 @@ from settings import (
|
||||
MINER_CLASSES = {
|
||||
"Antminer S9": {
|
||||
"Default": BOSMinerS9,
|
||||
"BOSMiner": BOSMinerS9,
|
||||
"BOSMiner": BOSMinerOld,
|
||||
"BOSMiner+": BOSMinerS9,
|
||||
"BMMiner": BMMinerS9,
|
||||
"CGMiner": CGMinerS9,
|
||||
},
|
||||
"Antminer S17": {
|
||||
"Default": BMMinerS17,
|
||||
"BOSMiner": BOSMinerS17,
|
||||
"BOSMiner+": BOSMinerS17,
|
||||
"BMMiner": BMMinerS17,
|
||||
"CGMiner": CGMinerS17,
|
||||
},
|
||||
"Antminer S17+": {
|
||||
"Default": BMMinerS17Plus,
|
||||
"BOSMiner": BOSMinerS17Plus,
|
||||
"BOSMiner+": BOSMinerS17Plus,
|
||||
"BMMiner": BMMinerS17Plus,
|
||||
"CGMiner": CGMinerS17Plus,
|
||||
},
|
||||
"Antminer S17 Pro": {
|
||||
"Default": BMMinerS17Pro,
|
||||
"BOSMiner": BOSMinerS17Pro,
|
||||
"BOSMiner+": BOSMinerS17Pro,
|
||||
"BMMiner": BMMinerS17Pro,
|
||||
"CGMiner": CGMinerS17Pro,
|
||||
},
|
||||
"Antminer S17e": {
|
||||
"Default": BMMinerS17e,
|
||||
"BOSMiner": BOSMinerS17e,
|
||||
"BOSMiner+": BOSMinerS17e,
|
||||
"BMMiner": BMMinerS17e,
|
||||
"CGMiner": CGMinerS17e,
|
||||
},
|
||||
"Antminer T17": {
|
||||
"Default": BMMinerT17,
|
||||
"BOSMiner": BOSMinerT17,
|
||||
"BOSMiner+": BOSMinerT17,
|
||||
"BMMiner": BMMinerT17,
|
||||
"CGMiner": CGMinerT17,
|
||||
},
|
||||
"Antminer T17+": {
|
||||
"Default": BMMinerT17Plus,
|
||||
"BOSMiner": BOSMinerT17Plus,
|
||||
"BOSMiner+": BOSMinerT17Plus,
|
||||
"BMMiner": BMMinerT17Plus,
|
||||
"CGMiner": CGMinerT17Plus,
|
||||
},
|
||||
"Antminer T17e": {
|
||||
"Default": BMMinerT17e,
|
||||
"BOSMiner": BOSMinerT17e,
|
||||
"BOSMiner+": BOSMinerT17e,
|
||||
"BMMiner": BMMinerT17e,
|
||||
"CGMiner": CGMinerT17e,
|
||||
},
|
||||
"Antminer S19": {
|
||||
"Default": BMMinerS19,
|
||||
"BOSMiner": BOSMinerS19,
|
||||
"BOSMiner+": BOSMinerS19,
|
||||
"BMMiner": BMMinerS19,
|
||||
"CGMiner": CGMinerS19,
|
||||
},
|
||||
"Antminer S19 Pro": {
|
||||
"Default": BMMinerS19Pro,
|
||||
"BOSMiner": BOSMinerS19Pro,
|
||||
"BOSMiner+": BOSMinerS19Pro,
|
||||
"BMMiner": BMMinerS19Pro,
|
||||
"CGMiner": CGMinerS19Pro,
|
||||
},
|
||||
"Antminer S19j": {
|
||||
"Default": BMMinerS19j,
|
||||
"BOSMiner": BOSMinerS19j,
|
||||
"BOSMiner+": BOSMinerS19j,
|
||||
"BMMiner": BMMinerS19j,
|
||||
"CGMiner": CGMinerS19j,
|
||||
},
|
||||
"Antminer S19j Pro": {
|
||||
"Default": BMMinerS19jPro,
|
||||
"BOSMiner": BOSMinerS19jPro,
|
||||
"BOSMiner+": BOSMinerS19jPro,
|
||||
"BMMiner": BMMinerS19jPro,
|
||||
"CGMiner": CGMinerS19jPro,
|
||||
},
|
||||
@@ -99,7 +101,7 @@ MINER_CLASSES = {
|
||||
},
|
||||
"Antminer T19": {
|
||||
"Default": BMMinerT19,
|
||||
"BOSMiner": BOSMinerT19,
|
||||
"BOSMiner+": BOSMinerT19,
|
||||
"BMMiner": BMMinerT19,
|
||||
"CGMiner": CGMinerT19,
|
||||
},
|
||||
@@ -241,8 +243,10 @@ class MinerFactory(metaclass=Singleton):
|
||||
|
||||
# return the miner base class with some API if we found it
|
||||
if api:
|
||||
if "BOSMiner" in api:
|
||||
if "BOSMiner+" in api:
|
||||
miner = BOSMiner(str(ip))
|
||||
if "BOSMiner" in api:
|
||||
miner = BOSMinerOld(str(ip))
|
||||
elif "CGMiner" in api:
|
||||
miner = CGMiner(str(ip))
|
||||
elif "BMMiner" in api:
|
||||
@@ -320,10 +324,12 @@ class MinerFactory(metaclass=Singleton):
|
||||
# check if there are any BOSMiner strings in any of the dict keys
|
||||
elif any("BOSminer" in string for string in version["VERSION"][0].keys()):
|
||||
api = "BOSMiner"
|
||||
if "plus" in version["VERSION"][0]["BOSminer"]:
|
||||
api = "BOSMiner+"
|
||||
|
||||
# if all that fails, check the Description to see if it is a whatsminer
|
||||
if version.get("Description") and "whatsminer" in version.get("Description"):
|
||||
api = "BTMiner"
|
||||
if version.get("Description") and "whatsminer" in version.get("Description"):
|
||||
api = "BTMiner"
|
||||
if version and not model:
|
||||
if (
|
||||
"VERSION" in version.keys()
|
||||
@@ -335,6 +341,8 @@ class MinerFactory(metaclass=Singleton):
|
||||
if model:
|
||||
if "V" in model:
|
||||
model = model.split("V")[0]
|
||||
if "Bitmain " in model:
|
||||
model = model.replace("Bitmain ", "")
|
||||
|
||||
return model, api
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import datetime
|
||||
from network import ping_miner
|
||||
from miners.miner_factory import MinerFactory
|
||||
from miners.antminer import BOSMinerS9
|
||||
from miners._backends.bosminer import BOSMinerOld
|
||||
from miners.unknown import UnknownMiner
|
||||
from tools.web_testbench.connections import ConnectionManager
|
||||
from tools.web_testbench.feeds import get_local_versions
|
||||
@@ -87,6 +88,16 @@ class TestbenchMiner:
|
||||
await self.remove_from_cache()
|
||||
miner = await MinerFactory().get_miner(self.host)
|
||||
await self.add_to_output("Found miner: " + str(miner))
|
||||
if isinstance(miner, BOSMinerOld):
|
||||
await self.add_to_output(
|
||||
f"Miner is running non-plus Braiins OS, attempting upgrade."
|
||||
)
|
||||
result = await miner.update_to_plus()
|
||||
if result:
|
||||
await self.remove_from_cache()
|
||||
self.state = START
|
||||
return
|
||||
|
||||
if isinstance(miner, BOSMinerS9):
|
||||
try:
|
||||
if await self.get_bos_version() == self.latest_version:
|
||||
|
||||
Reference in New Issue
Block a user