feature: add basic iceriver framework.
This commit is contained in:
@@ -339,6 +339,13 @@ class BitAxeModels(str, Enum):
|
|||||||
return self.value
|
return self.value
|
||||||
|
|
||||||
|
|
||||||
|
class IceRiverModels(str, Enum):
|
||||||
|
KS2 = "KS2"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.value
|
||||||
|
|
||||||
|
|
||||||
class MinerModel:
|
class MinerModel:
|
||||||
ANTMINER = AntminerModels
|
ANTMINER = AntminerModels
|
||||||
WHATSMINER = WhatsminerModels
|
WHATSMINER = WhatsminerModels
|
||||||
@@ -348,3 +355,4 @@ class MinerModel:
|
|||||||
AURADINE = AuradineModels
|
AURADINE = AuradineModels
|
||||||
EPIC = ePICModels
|
EPIC = ePICModels
|
||||||
BITAXE = BitAxeModels
|
BITAXE = BitAxeModels
|
||||||
|
ICERIVER = IceRiverModels
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ from .cgminer import CGMiner
|
|||||||
from .epic import ePIC
|
from .epic import ePIC
|
||||||
from .goldshell import GoldshellMiner
|
from .goldshell import GoldshellMiner
|
||||||
from .hiveon import Hiveon
|
from .hiveon import Hiveon
|
||||||
|
from .iceriver import IceRiver
|
||||||
from .innosilicon import Innosilicon
|
from .innosilicon import Innosilicon
|
||||||
from .luxminer import LUXMiner
|
from .luxminer import LUXMiner
|
||||||
from .marathon import MaraMiner
|
from .marathon import MaraMiner
|
||||||
|
|||||||
14
pyasic/miners/backends/iceriver.py
Normal file
14
pyasic/miners/backends/iceriver.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from pyasic.miners.data import DataLocations
|
||||||
|
from pyasic.miners.device.firmware import StockFirmware
|
||||||
|
from pyasic.web.iceriver import IceRiverWebAPI
|
||||||
|
|
||||||
|
ICERIVER_DATA_LOC = DataLocations()
|
||||||
|
|
||||||
|
|
||||||
|
class IceRiver(StockFirmware):
|
||||||
|
"""Handler for IceRiver miners"""
|
||||||
|
|
||||||
|
_web_cls = IceRiverWebAPI
|
||||||
|
web: IceRiverWebAPI
|
||||||
|
|
||||||
|
data_locations = ICERIVER_DATA_LOC
|
||||||
@@ -48,3 +48,7 @@ class ePICMake(BaseMiner):
|
|||||||
|
|
||||||
class BitAxeMake(BaseMiner):
|
class BitAxeMake(BaseMiner):
|
||||||
make = MinerMake.BITAXE
|
make = MinerMake.BITAXE
|
||||||
|
|
||||||
|
|
||||||
|
class IceRiverMake(BaseMiner):
|
||||||
|
make = MinerMake.BITAXE
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ from .auradine import *
|
|||||||
from .avalonminer import *
|
from .avalonminer import *
|
||||||
from .epic import *
|
from .epic import *
|
||||||
from .goldshell import *
|
from .goldshell import *
|
||||||
|
from .iceriver import *
|
||||||
from .innosilicon import *
|
from .innosilicon import *
|
||||||
from .whatsminer import *
|
from .whatsminer import *
|
||||||
|
|||||||
23
pyasic/miners/device/models/iceriver/KSX/KS2.py
Normal file
23
pyasic/miners/device/models/iceriver/KSX/KS2.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright 2024 Upstream Data Inc -
|
||||||
|
# -
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||||
|
# you may not use this file except in compliance with the License. -
|
||||||
|
# You may obtain a copy of the License at -
|
||||||
|
# -
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||||
|
# -
|
||||||
|
# Unless required by applicable law or agreed to in writing, software -
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||||
|
# See the License for the specific language governing permissions and -
|
||||||
|
# limitations under the License. -
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
from pyasic.device.models import MinerModel
|
||||||
|
from pyasic.miners.device.makes import IceRiverMake
|
||||||
|
|
||||||
|
|
||||||
|
class KS2(IceRiverMake):
|
||||||
|
raw_model = MinerModel.ICERIVER.KS2
|
||||||
|
|
||||||
|
expected_fans = 4
|
||||||
1
pyasic/miners/device/models/iceriver/KSX/__init__.py
Normal file
1
pyasic/miners/device/models/iceriver/KSX/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .KS2 import KS2
|
||||||
1
pyasic/miners/device/models/iceriver/__init__.py
Normal file
1
pyasic/miners/device/models/iceriver/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .KSX import *
|
||||||
@@ -38,6 +38,7 @@ from pyasic.miners.bitaxe import *
|
|||||||
from pyasic.miners.blockminer import *
|
from pyasic.miners.blockminer import *
|
||||||
from pyasic.miners.device.makes import *
|
from pyasic.miners.device.makes import *
|
||||||
from pyasic.miners.goldshell import *
|
from pyasic.miners.goldshell import *
|
||||||
|
from pyasic.miners.iceriver import *
|
||||||
from pyasic.miners.innosilicon import *
|
from pyasic.miners.innosilicon import *
|
||||||
from pyasic.miners.whatsminer import *
|
from pyasic.miners.whatsminer import *
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ class MinerTypes(enum.Enum):
|
|||||||
AURADINE = 10
|
AURADINE = 10
|
||||||
MARATHON = 11
|
MARATHON = 11
|
||||||
BITAXE = 12
|
BITAXE = 12
|
||||||
|
ICERIVER = 13
|
||||||
|
|
||||||
|
|
||||||
MINER_CLASSES = {
|
MINER_CLASSES = {
|
||||||
@@ -451,6 +453,10 @@ MINER_CLASSES = {
|
|||||||
"BM1366": BitAxeUltra,
|
"BM1366": BitAxeUltra,
|
||||||
"BM1397": BitAxeMax,
|
"BM1397": BitAxeMax,
|
||||||
},
|
},
|
||||||
|
MinerTypes.ICERIVER: {
|
||||||
|
None: type("IceRiverUnknown", (IceRiver, IceRiverMake), {}),
|
||||||
|
"KS2": IceRiverKS2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -623,6 +629,8 @@ class MinerFactory:
|
|||||||
return MinerTypes.INNOSILICON
|
return MinerTypes.INNOSILICON
|
||||||
if "Miner UI" in web_text:
|
if "Miner UI" in web_text:
|
||||||
return MinerTypes.AURADINE
|
return MinerTypes.AURADINE
|
||||||
|
if "<TITLE>用户界面</TITLE>" in web_text:
|
||||||
|
return MinerTypes.ICERIVER
|
||||||
|
|
||||||
async def _get_miner_socket(self, ip: str) -> MinerTypes | None:
|
async def _get_miner_socket(self, ip: str) -> MinerTypes | None:
|
||||||
commands = ["version", "devdetails"]
|
commands = ["version", "devdetails"]
|
||||||
|
|||||||
1
pyasic/miners/iceriver/__init__.py
Normal file
1
pyasic/miners/iceriver/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .iceminer import *
|
||||||
6
pyasic/miners/iceriver/iceminer/KSX/KS2.py
Normal file
6
pyasic/miners/iceriver/iceminer/KSX/KS2.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from pyasic.miners.backends.iceriver import IceRiver
|
||||||
|
from pyasic.miners.device.models import KS2
|
||||||
|
|
||||||
|
|
||||||
|
class IceRiverKS2(IceRiver, KS2):
|
||||||
|
pass
|
||||||
1
pyasic/miners/iceriver/iceminer/KSX/__init__.py
Normal file
1
pyasic/miners/iceriver/iceminer/KSX/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .KS2 import IceRiverKS2
|
||||||
1
pyasic/miners/iceriver/iceminer/__init__.py
Normal file
1
pyasic/miners/iceriver/iceminer/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .KSX import *
|
||||||
@@ -39,6 +39,7 @@ _settings = { # defaults
|
|||||||
"default_auradine_web_password": "admin",
|
"default_auradine_web_password": "admin",
|
||||||
"default_epic_web_password": "letmein",
|
"default_epic_web_password": "letmein",
|
||||||
"default_hive_web_password": "admin",
|
"default_hive_web_password": "admin",
|
||||||
|
"default_iceriver_web_password": "12345678",
|
||||||
"default_antminer_ssh_password": "miner",
|
"default_antminer_ssh_password": "miner",
|
||||||
"default_bosminer_ssh_password": "root",
|
"default_bosminer_ssh_password": "root",
|
||||||
"socket_linger_time": 1000,
|
"socket_linger_time": 1000,
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ from .base import BaseWebAPI
|
|||||||
from .braiins_os import BOSerWebAPI, BOSMinerWebAPI
|
from .braiins_os import BOSerWebAPI, BOSMinerWebAPI
|
||||||
from .epic import ePICWebAPI
|
from .epic import ePICWebAPI
|
||||||
from .goldshell import GoldshellWebAPI
|
from .goldshell import GoldshellWebAPI
|
||||||
|
from .iceriver import IceRiverWebAPI
|
||||||
from .innosilicon import InnosiliconWebAPI
|
from .innosilicon import InnosiliconWebAPI
|
||||||
from .vnish import VNishWebAPI
|
from .vnish import VNishWebAPI
|
||||||
|
|||||||
73
pyasic/web/iceriver.py
Normal file
73
pyasic/web/iceriver.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright 2024 Upstream Data Inc -
|
||||||
|
# -
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||||
|
# you may not use this file except in compliance with the License. -
|
||||||
|
# You may obtain a copy of the License at -
|
||||||
|
# -
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||||
|
# -
|
||||||
|
# Unless required by applicable law or agreed to in writing, software -
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||||
|
# See the License for the specific language governing permissions and -
|
||||||
|
# limitations under the License. -
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import warnings
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
from pyasic import settings
|
||||||
|
from pyasic.errors import APIError
|
||||||
|
from pyasic.web.base import BaseWebAPI
|
||||||
|
|
||||||
|
|
||||||
|
class IceRiverWebAPI(BaseWebAPI):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.username = "admin"
|
||||||
|
self.pwd = settings.get("default_iceriver_web_password", "12345678")
|
||||||
|
|
||||||
|
async def multicommand(
|
||||||
|
self, *commands: str, ignore_errors: bool = False, allow_warning: bool = True
|
||||||
|
) -> dict:
|
||||||
|
tasks = {c: asyncio.create_task(getattr(self, c)()) for c in commands}
|
||||||
|
await asyncio.gather(*[t for t in tasks.values()])
|
||||||
|
return {t: tasks[t].result() for t in tasks}
|
||||||
|
|
||||||
|
async def send_command(
|
||||||
|
self,
|
||||||
|
command: str | bytes,
|
||||||
|
ignore_errors: bool = False,
|
||||||
|
allow_warning: bool = True,
|
||||||
|
privileged: bool = False,
|
||||||
|
**parameters: Any,
|
||||||
|
) -> dict:
|
||||||
|
async with httpx.AsyncClient(transport=settings.transport()) as client:
|
||||||
|
try:
|
||||||
|
# auth
|
||||||
|
await client.post(
|
||||||
|
f"http://{self.ip}:{self.port}/user/loginpost",
|
||||||
|
params={"post": "6", "user": self.username, "pwd": self.pwd},
|
||||||
|
)
|
||||||
|
except httpx.HTTPError:
|
||||||
|
warnings.warn(f"Could not authenticate with miner web: {self}")
|
||||||
|
try:
|
||||||
|
resp = await client.post(
|
||||||
|
f"http://{self.ip}:{self.port}/user/{command}", params=parameters
|
||||||
|
)
|
||||||
|
return resp.json()
|
||||||
|
except httpx.HTTPError:
|
||||||
|
raise APIError(f"Command failed: {command}")
|
||||||
|
|
||||||
|
async def locate(self, enable: bool):
|
||||||
|
return await self.send_command(
|
||||||
|
"userpanel", post="5", locate="1" if enable else "0"
|
||||||
|
)
|
||||||
|
|
||||||
|
async def userpanel(self):
|
||||||
|
return await self.send_command("userpanel", post="4")
|
||||||
Reference in New Issue
Block a user