📚Docs + Omada work #708

This commit is contained in:
jokob-sk
2024-06-29 10:28:14 +10:00
parent f64ebae3ee
commit eae93ef6b2
11 changed files with 239 additions and 70 deletions

View File

@@ -1,9 +1,9 @@
{
"code_name": "folder_name",
"unique_prefix": "",
"plugin_type": "core|general|system|scanner|other|publisher",
"plugin_type": "scanner",
"enabled": true,
"data_source": "script|app-db-query|template|sqlite-db-query",
"data_source": "script",
"mapped_to_table": "CurrentScan",
"data_filters": [
{
@@ -122,6 +122,25 @@
}
]
},
{
"function": "list_example",
"type": "list",
"default_value": ["existing_entry_1", "existing_entry_2"],
"options": [],
"localized": ["name", "description"],
"name": [
{
"language_code": "en_us",
"string": "Setting name"
}
],
"description": [
{
"language_code": "en_us",
"string": "Description / simple setup instructions"
}
]
},
{
"function": "multiselect_example_from_setting",
"type": "text.multiselect",
@@ -255,7 +274,7 @@
},
{
"column": "Watched_Value3",
"mapped_to_column": "cur_SyncHubNodeName",
"mapped_to_column": "cur_Type",
"css_classes": "col-sm-2",
"show": true,
"type": "label",
@@ -265,14 +284,14 @@
"name": [
{
"language_code": "en_us",
"string": "Sync Node"
"string": "Device Type"
}
]
},
{
"column": "Watched_Value4",
"css_classes": "col-sm-2",
"show": true,
"show": false,
"type": "label",
"default_value": "",
"options": [],
@@ -280,7 +299,7 @@
"name": [
{
"language_code": "en_us",
"string": "Device GUID"
"string": "N/A"
}
]
},
@@ -288,7 +307,7 @@
"column": "Dummy",
"mapped_to_column": "cur_ScanMethod",
"mapped_to_column_data": {
"value": "sync"
"value": "Example Plugin"
},
"css_classes": "col-sm-2",
"show": true,

View File

@@ -6,7 +6,6 @@ import sys
import json
import sqlite3
# Define the installation path and extend the system path for plugin imports
INSTALL_PATH = "/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
@@ -47,18 +46,18 @@ def main():
#"database_column_definitions": [
# {
# "column": "Object_PrimaryID", <--------- the value I save into primaryId
# "mapped_to_column": "cur_MAC", <--------- gets unserted into the CurrentScan DB table column cur_MAC
# "mapped_to_column": "cur_MAC", <--------- gets inserted into the CurrentScan DB table column cur_MAC
#
for device in device_data:
plugin_objects.add_object(
primaryId = device['some_id'],
secondaryId = device['some_id'],
watched1 = device['some_id'],
watched2 = device['some_id'],
watched3 = device['some_id'],
watched4 = device['some_id'],
primaryId = device['mac_address'],
secondaryId = device['ip_address'],
watched1 = device['hostname'],
watched2 = device['vendor'],
watched3 = device['device_type'],
watched4 = device['last_seen'],
extra = '',
foreignKey = device['some_id'])
foreignKey = device['mac_address'])
mylog('verbose', [f'[{pluginName}] New entries: "{len(new_devices)}"'])
@@ -75,7 +74,34 @@ def get_device_data(some_setting):
# do some processing, call exteranl APIs, and return a device_data list
# ...
#
# Sample data for testing purposes, you can adjust the processing in main() as needed
# ... before adding it to the plugin_objects.add_object(...)
device_data = [
{
'device_id': 'device1',
'mac_address': '00:11:22:33:44:55',
'ip_address': '192.168.1.2',
'hostname': 'iPhone 12',
'vendor': 'Apple Inc.',
'device_type': 'Smartphone',
'last_seen': '2024-06-27 10:00:00',
'port': '1',
'network_id': 'network1'
},
{
'device_id': 'device2',
'mac_address': '00:11:22:33:44:66',
'ip_address': '192.168.1.3',
'hostname': 'Moto G82',
'vendor': 'Motorola Inc.',
'device_type': 'Laptop',
'last_seen': '2024-06-27 10:05:00',
'port': '',
'network_id': 'network1'
}
]
# Return the data to be detected by teh main application
return device_data
if __name__ == '__main__':