Skip to content

Commit

Permalink
Upd with username and password
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Mar 20, 2024
1 parent ec48731 commit 4976cbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions bin/infrasonar
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from dataclasses import dataclass
from setproctitle import setproctitle
from typing import Any, Optional, Dict, List, Tuple

__version__ = '0.1.15' # Update version in setup as well
__version__ = '0.1.16' # Update version in setup as well


_labels_example = """
Expand Down Expand Up @@ -1354,12 +1354,14 @@ def _unifi_devices(container_id: int, api: str, verify_ssl: bool, token: str,
port = config.get('port', 443) or 443
site = config.get('site', 'default') or 'default'
vssl = config.get('ssl', False)
username = config.get('username', '')
password = config.get('password', '')

data = asyncio.run(async_get_check_data(api, verify_ssl, asset['id'],
token, ucontroller,
'device'))
for device in data['data']['device']:
device['_parent'] = (address, port, site, vssl)
device['_parent'] = (address, port, site, vssl, username, password)
device_map[device['name'].upper()] = device # name=guid

asyncio.run(asyncio.sleep(0.5))
Expand Down Expand Up @@ -1430,7 +1432,7 @@ def _unifi_devices(container_id: int, api: str, verify_ssl: bool, token: str,
asset['id'], name = not_installed[name.lower()]

asset['name'] = name
asset['collectors'] = [{
cnf = {
'key': udevice,
'config': {
'controller': device['_parent'][0],
Expand All @@ -1439,7 +1441,11 @@ def _unifi_devices(container_id: int, api: str, verify_ssl: bool, token: str,
'mac': device['name'].upper(),
'ssl': device['_parent'][3],
},
}]
}
if ucontroller == 'unificontrollersvc':
cnf['config']['username'] = device['_parent'][4]
cnf['config']['password'] = device['_parent'][5]
asset['collectors'] = [cnf]
assets.append(asset)
return assets, total

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name='infrasonar',
version='0.1.15', # Update version in infrasonar as well
version='0.1.16', # Update version in infrasonar as well
description='InfraSonar Toolkit',
url='https://github.com/infrasonar/toolkit',
long_description=long_description,
Expand Down

0 comments on commit 4976cbf

Please sign in to comment.