|
|
@ -168,9 +168,9 @@ class MikrotikTransmitter(BaseTransmitter, ApiRos, metaclass=type('_ABC_Lazy_mcs |
|
|
def __init__(self, login: str, password: str, ip: str, port: int, *args, **kwargs): |
|
|
def __init__(self, login: str, password: str, ip: str, port: int, *args, **kwargs): |
|
|
try: |
|
|
try: |
|
|
BaseTransmitter.__init__(self, |
|
|
BaseTransmitter.__init__(self, |
|
|
login=login, password=password, ip=ip, |
|
|
|
|
|
port=port, *args, **kwargs |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
login=login, password=password, ip=ip, |
|
|
|
|
|
port=port, *args, **kwargs |
|
|
|
|
|
) |
|
|
ApiRos.__init__(self, ip, port) |
|
|
ApiRos.__init__(self, ip, port) |
|
|
self.login(username=login, pwd=password) |
|
|
self.login(username=login, pwd=password) |
|
|
except ConnectionRefusedError: |
|
|
except ConnectionRefusedError: |
|
|
@ -199,7 +199,6 @@ class MikrotikTransmitter(BaseTransmitter, ApiRos, metaclass=type('_ABC_Lazy_mcs |
|
|
if v: |
|
|
if v: |
|
|
yield v |
|
|
yield v |
|
|
|
|
|
|
|
|
# Build object ShapeItem from information from mikrotik |
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def _build_shape_obj(info: Dict) -> AbonStruct: |
|
|
def _build_shape_obj(info: Dict) -> AbonStruct: |
|
|
# Переводим приставку скорости Mikrotik в Mbit/s |
|
|
# Переводим приставку скорости Mikrotik в Mbit/s |
|
|
@ -226,7 +225,7 @@ class MikrotikTransmitter(BaseTransmitter, ApiRos, metaclass=type('_ABC_Lazy_mcs |
|
|
if target is None: |
|
|
if target is None: |
|
|
target = info.get('=target-addresses') |
|
|
target = info.get('=target-addresses') |
|
|
name = info.get('=name') |
|
|
name = info.get('=name') |
|
|
disabled = info.get('=disabled') |
|
|
|
|
|
|
|
|
disabled = info.get('=disabled', False) |
|
|
if disabled is not None: |
|
|
if disabled is not None: |
|
|
disabled = True if disabled == 'true' else False |
|
|
disabled = True if disabled == 'true' else False |
|
|
if target is not None and name is not None: |
|
|
if target is not None and name is not None: |
|
|
@ -236,7 +235,7 @@ class MikrotikTransmitter(BaseTransmitter, ApiRos, metaclass=type('_ABC_Lazy_mcs |
|
|
uid=int(name[3:]), |
|
|
uid=int(name[3:]), |
|
|
ips=ips, |
|
|
ips=ips, |
|
|
tariff=t, |
|
|
tariff=t, |
|
|
is_access=disabled or False |
|
|
|
|
|
|
|
|
is_access=not disabled |
|
|
) |
|
|
) |
|
|
if len(a.ips) < 1: |
|
|
if len(a.ips) < 1: |
|
|
return |
|
|
return |
|
|
@ -473,7 +472,6 @@ class MikrotikTransmitter(BaseTransmitter, ApiRos, metaclass=type('_ABC_Lazy_mcs |
|
|
pass |
|
|
pass |
|
|
|
|
|
|
|
|
def read_users(self) -> VectorAbon: |
|
|
def read_users(self) -> VectorAbon: |
|
|
# shapes is ShapeItem |
|
|
|
|
|
all_ips = set(ip for ip, mkid in self.read_ips_iter(LIST_USERS_ALLOWED)) |
|
|
all_ips = set(ip for ip, mkid in self.read_ips_iter(LIST_USERS_ALLOWED)) |
|
|
queues = (q for q in self.read_queue_iter() if all_ips.issuperset(q.ips)) |
|
|
queues = (q for q in self.read_queue_iter() if all_ips.issuperset(q.ips)) |
|
|
return queues |
|
|
return queues |
|
|
|