Fix scan bug not finding vm/pc installations

This commit is contained in:
sepehr 2024-08-09 15:43:44 +03:30
parent 43b894bd23
commit 4b52bcc0c3
2 changed files with 43 additions and 28 deletions

View file

@ -301,14 +301,17 @@ def scan_with_ip(*args, **kwargs):
) )
results = tuple(call) results = tuple(call)
result: Dict[str, str] = results[0] result: Dict[str, str] = results[0]
try:
call = router.api.path( call = router.api.path(
"/system/routerboard" "/system/routerboard"
) )
routerboard = tuple(call) routerboard = tuple(call)
routerboard: Dict[str, str] = routerboard[0] routerboard: Dict[str, str] = routerboard[0]
result.update(routerboard) result.update(routerboard)
except Exception as e:
if 'no such command' not in str(e):
log.error(e)
pass
call = router.api.path( call = router.api.path(
"/system/identity" "/system/identity"
) )
@ -346,7 +349,12 @@ def scan_with_ip(*args, **kwargs):
device['current_firmware']=current device['current_firmware']=current
device['mac']=result['interface']['mac-address'] if "mac-address" in result['interface'] else 'tunnel' device['mac']=result['interface']['mac-address'] if "mac-address" in result['interface'] else 'tunnel'
device['name']=result['name'] device['name']=result['name']
device['details']=result['board-name'] + " " + result['model'] if result['model']!=result['board-name'] else result['model'] if 'board-name' in result and 'mdoel' in result:
device['details']=result['board-name'] + " " + result['model'] if result['model']!=result['board-name'] else result['model']
elif 'board-name' in result:
device['details']=result['board-name']
else:
device['details']='x86/64'
device['uptime']=result['uptime'] device['uptime']=result['uptime']
device['license']="" device['license']=""
device['interface']=result['interface']['name'] device['interface']=result['interface']['name']

View file

@ -233,13 +233,17 @@ def grab_device_data(dev, q):
) )
results = tuple(call) results = tuple(call)
result: Dict[str, str] = results[0] result: Dict[str, str] = results[0]
call = router.api.path( try:
"/system/routerboard" call = router.api.path(
) "/system/routerboard"
routerboard = tuple(call) )
routerboard: Dict[str, str] = routerboard[0] routerboard = tuple(call)
result.update(routerboard) routerboard: Dict[str, str] = routerboard[0]
result.update(routerboard)
except Exception as e:
if 'no such command' not in str(e):
log.error(e)
pass
call = router.api.path( call = router.api.path(
"/system/health" "/system/health"
) )
@ -282,7 +286,7 @@ def grab_device_data(dev, q):
keys=["free-memory","cpu-load","free-hdd-space"] keys=["free-memory","cpu-load","free-hdd-space"]
if len(health): if len(health):
#since routeros v7 they changed health res from api #since routeros v7 they changed health res from api
excluded_keys=['cpu-overtemp-check','active-fan','fan-mode','heater-control','psu2-state','cpu-overtemp-startup-delay','fan-on-threshold','heater-threshold','use-fan','cpu-overtemp-threshold','fan-switch','psu1-state'] excluded_keys=['cpu-overtemp-check','active-fan','fan-mode','heater-control','psu2-state','cpu-overtemp-startup-delay','fan-on-threshold','heater-threshold','use-fan','cpu-overtemp-threshold','fan-switch','psu1-state','state','state-after-reboot']
if 'type' in health[0]: if 'type' in health[0]:
health_vals={} health_vals={}
for d in health: for d in health:
@ -311,7 +315,7 @@ def grab_device_data(dev, q):
# keys.remove('fan-on-threshold') # keys.remove('fan-on-threshold')
try: try:
# arch=result['architecture-name'] # arch=result['architecture-name']
if result["current-firmware"]==result["upgrade-firmware"]: if result['board-name']!='x86' and result["current-firmware"]==result["upgrade-firmware"]:
dev.upgrade_availble=True dev.upgrade_availble=True
force_syslog=True if db_sysconfig.get_sysconfig('force_syslog')=="True" else False force_syslog=True if db_sysconfig.get_sysconfig('force_syslog')=="True" else False
force_radius=True if db_sysconfig.get_sysconfig('force_radius')=="True" else False force_radius=True if db_sysconfig.get_sysconfig('force_radius')=="True" else False
@ -577,17 +581,20 @@ def check_update(options,router=False):
results = tuple(call) results = tuple(call)
result: Dict[str, str] = results[0] result: Dict[str, str] = results[0]
arch=result['architecture-name'] arch=result['architecture-name']
try:
call = router.api.path(
"/system/routerboard"
)
call = router.api.path( routerboard = tuple(call)
"/system/routerboard" routerboard: Dict[str, str] = routerboard[0]
) result.update(routerboard)
except Exception as e:
routerboard = tuple(call) if 'no such command' not in str(e):
routerboard: Dict[str, str] = routerboard[0] log.error(e)
result.update(routerboard) pass
upgrade=False upgrade=False
if result['current-firmware']!= result['upgrade-firmware']: if result['board-name']!='x86' and result['current-firmware']!= result['upgrade-firmware'] and result['board-name']!='x86':
upgrade=True upgrade=True
if _latest_version and _installed_version < _latest_version: if _latest_version and _installed_version < _latest_version:
return True, _installed_version,arch,upgrade return True, _installed_version,arch,upgrade