Page cover
githubEdit

Profiles

Vendor Lua hooks for devices manager (TR-069 and USP CPEs).

Introduction to how Lua scripts are executed by Oktopus: Scripts

Function Contract

All Lua hooks should return two values:

-- success
return value, nil

-- failure
return nil, "error message"

Notes:

  • For get_* payload builders, return CWMP XML as string.

  • For parse_*, return a Lua table compatible with expected Go resource structs.

  • For metadata/capabilities, return string/boolean/table depending on function.

Shared Helper (optional)

local function response_to_map(response)
  local out = {}
  for _, param in ipairs(response.list or {}) do
    out[param.name] = param.value
  end
  return out
end

Functions

get_vendor()

Returns the vendor label used by the API.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

get_data_model()

Returns the data model handled by the script.

Protocol:

CWMP

Params:

None.

Return:

  • value: string (for example: TR-098, TR-181)

  • err: nil or string

Example:

get_device_capabilities()

Defines which resources/features are enabled for this model.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: table with capability keys

  • err: nil or string

Example:

get_device_specs()

Defines device behavior details (for example traceroute wait time).

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: table

  • err: nil or string

Example:

is_real_time()

Indicates whether this model should be treated as real-time for operations.

Protocol:

CWMP

Params:

None.

Return:

  • value: boolean

  • err: nil or string

Example:

get_radio()

Builds CWMP payload to fetch radio data.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (CWMP XML)

  • err: nil or string

Example:

parse_radio(response)

Parses CWMP response into radio resource list.

Protocol:

CWMP and USP

Params:

  1. response [table] CWMP response (response.list)

Return:

  • value: table ([]Radio)

  • err: nil or string

Example:

set_radio(radios)

Builds CWMP payload to update radio configuration.

Protocol:

CWMP and USP

Params:

  1. radios [table] radio list

Return:

  • value: string (CWMP XML)

  • err: nil or string

Example:

get_ssid()

Builds CWMP payload to fetch SSID data.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (CWMP XML)

  • err: nil or string

Example:

parse_ssid(response)

Parses CWMP response into SSID resource list.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table ([]Ssid)

  • err: nil or string

Example:

set_ssid(ssids)

Builds CWMP payload to update SSID configuration.

Protocol:

CWMP and USP

Params:

  1. ssids [table]

Return:

  • value: string (CWMP XML)

  • err: nil or string

Example:

get_site_survey_diagnostic_state()

Returns site survey diagnostic state.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

set_site_survey_diagnostic_state()

Sets site survey diagnostic state to Requested.

Protocol:

USP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

get_site_survey_results()

Builds payload to fetch site survey results.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_site_survey(response)

Parses site survey result set.

Protocol:

CWMP e USP

Params:

  1. response [table]

Return:

  • value: table (map[string][]NeighborSites)

  • err: nil or string

Example:

get_connected_devices()

Builds payload to fetch connected devices.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_connected_devices(response)

Parses connected devices response.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table (ConnectedDevices)

  • err: nil or string

Example:

set_speed_test(test)

Builds payload to configure speed test.

Protocol:

CWMP and USP

Params:

  1. test [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_speed_test_result(speed_test_type)

Builds payload to fetch speed test result.

Protocol:

CWMP and USP

Params:

  1. speed_test_type [string] (download or upload)

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_speed_test_result(speed_test_type, response)

Parses speed test result.

Protocol:

CWMP and USP

Params:

  1. speed_test_type [string]

  2. response [table]

Return:

  • value: table (Speedtest)

  • err: nil or string

Example:

get_download_diagnostic_state()

Returns download diagnostic state path or state marker for the model.

Protocol:

CWMP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

get_upload_diagnostic_state()

Returns upload diagnostic state path or state marker for the model.

Protocol:

CWMP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

get_statistics()

Builds payload to fetch statistics.

Protocol:

CWMP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_statistics(response)

Parses statistics response.

Protocol:

CWMP

Params:

  1. response [table]

Return:

  • value: table (map[string][]Stats)

  • err: nil or string

Example:

get_interface_wan()

Builds payload to fetch WAN interfaces.

Protocol:

CWMP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_interface_lan()

Builds payload to fetch LAN interfaces.

Protocol:

CWMP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_interface_wan(response)

Parses WAN interfaces response.

Params:

  1. response [table]

Return:

  • value: table (map[string]Port)

  • err: nil or string

Example:

parse_get_interface_lan(response)

Parses LAN interfaces response.

Protocol:

CWMP

Params:

  1. response [table]

Return:

  • value: table (map[string]Port)

  • err: nil or string

Example:

get_wan_options()

Returns WAN configuration options supported by the model.

Protocol:

CWMP

Params:

None.

Return:

  • value: table ([]WanOptions)

  • err: nil or string

Example:

get_port()

Builds payload to fetch TR-098/TR-181 ports.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_port(response)

Parses TR-098/TR-181 ports response.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table (map[string]Port)

  • err: nil or string

Example:

set_port(ports)

Builds payload to update port configuration.

Protocol:

CWMP and USP

Params:

  1. ports [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

add_port(port)

Builds payload to add a new port/object.

Protocol:

CWMP

Params:

  1. port [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_bridge()

Builds payload to fetch bridge data.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_bridge(response)

Parses bridge response.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table ([]Bridge)

  • err: nil or string

Example:

set_bridge(bridges)

Builds payload to update bridge configuration.

Protocol:

CWMP and USP

Params:

  1. bridges [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_ping()

Builds payload to fetch ping diagnostics config.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_ping(response)

Parses ping diagnostics config.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table (Ping)

  • err: nil or string

Example:

get_ping_diagnostic_state()

Returns ping diagnostic state path/state.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

set_ping(ping)

Builds payload to execute/update ping diagnostics.

Protocol:

CWMP and USP

Params:

  1. ping [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_ping_result()

Builds payload to fetch ping result.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_ping_result(response)

Parses ping result response.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table (PingResult)

  • err: nil or string

Example:

get_traceroute()

Builds payload to fetch traceroute diagnostics config.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_traceroute(response)

Parses traceroute diagnostics config.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table (Traceroute)

  • err: nil or string

Example:

get_traceroute_diagnostic_state()

Returns traceroute diagnostic state path/state.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

set_traceroute(traceroute)

Builds payload to execute/update traceroute diagnostics.

Protocol:

CWMP and USP

Params:

  1. traceroute [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_traceroute_result_number_of_hops()

Returns the parameter path/state used to read hop count.

Protocol:

CWMP

Params:

None.

Return:

  • value: string

  • err: nil or string

Example:

get_traceroute_result(number_of_hops)

Builds payload to fetch traceroute hop details.

Protocol:

CWMP and USP

Params:

  1. number_of_hops [integer]

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_traceroute_result(response)

Parses traceroute result response.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table (TracerouteResult)

  • err: nil or string

Example:

get_hwinfo()

Builds payload to fetch hardware information.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_hwinfo(response)

Parses hardware information response.

Protocol:

CWMP

Params:

  1. response [table]

Return:

  • value: table (Hwinfo)

  • err: nil or string

Example:

get_pon()

Builds payload to fetch PON information.

Protocol:

CWMP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_pon(response)

Parses PON information response.

Protocol:

CWMP

Params:

  1. response [table]

Return:

  • value: table (Pon)

  • err: nil or string

Example:

get_voice()

Builds payload to fetch voice accounts/lines.

Protocol:

CWMP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_voice(response)

Parses voice data response.

Protocol:

CWMP

Params:

  1. response [table]

Return:

  • value: table ([]Voice)

  • err: nil or string

Example:

set_voice(voice)

Builds payload to update voice profile settings.

Protocol:

CWMP

Params:

  1. voice [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

set_line(line)

Builds payload to update voice line settings.

Protocol:

CWMP

Params:

  1. line [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_cellular()

Builds payload to fetch cellular information.

Protocol:

CWMP and USP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_get_cellular(response)

Parses cellular information response.

Protocol:

CWMP and USP

Params:

  1. response [table]

Return:

  • value: table ([]Cellular)

  • err: nil or string

Example:

set_cellular(cellular)

Builds payload to update cellular settings.

Protocol:

CWMP and USP

Params:

  1. cellular [table]

Return:

  • value: string (XML)

  • err: nil or string

Example:

get_xdsl()

Builds payload to fetch xDSL information.

Protocol:

CWMP

Params:

None.

Return:

  • value: string (XML)

  • err: nil or string

Example:

parse_xdsl(response)

Parses xDSL information response.

Protocol:

CWMP

Params:

  1. response [table]

Return:

  • value: table ([]XDSL)

  • err: nil or string

Example:

Last updated