TR181-XPON
1.4.0
TR-181 PON manager.
|
#include "populate_dm_startup.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <amxc/amxc_macros.h>
#include <amxc/amxc.h>
#include <amxp/amxp_timer.h>
#include "data_model.h"
#include "dm_info.h"
#include "pon_ctrl.h"
#include "xpon_mgr_constants.h"
#include "xpon_trace.h"
Go to the source code of this file.
Data Structures | |
struct | _task |
Macros | |
#define | QUERY_ONUS_INTERVAL_MS 10000 |
#define | QUERY_ONUS_NR_TIMES 30 |
Typedefs | |
typedef enum _task_type | task_type_t |
typedef struct _task | task_t |
Enumerations | |
enum | _task_type { task_none , task_query_indexes , task_query_content , task_type_nr } |
Functions | |
static const char * | task_type_to_string (task_type_t type) |
static void | task_init (task_t *const task, const char *const path, uint32_t index, task_type_t type) |
static void | task_clean (task_t *const task) |
static task_t * | task_create (const char *const path, uint32_t index, task_type_t type) |
static void | task_delete (amxc_llist_it_t *hit) |
static bool | check_return_values (int rc, const amxc_var_t *const ret, const char *func, const char *const path, uint32_t index) |
static void | query_children (const char *const path, uint32_t index, object_id_t id, bool templates) |
static void | query_content (const task_t *task) |
static void | query_indexes (const task_t *task) |
static void | schedule_remaining_tasks (void) |
static void | handle_task (UNUSED amxp_timer_t *timer, UNUSED void *priv) |
static void | query_onu_instances (amxp_timer_t *timer, UNUSED void *priv) |
bool | pplt_dm_init (void) |
void | pplt_dm_cleanup (void) |
Variables | |
static amxp_timer_t * | s_timer_query_onus = NULL |
static uint32_t | s_cntr_query_onus = 0 |
static amxc_llist_t | s_tasks = { 0 } |
static amxp_timer_t * | s_timer_handle_tasks = NULL |
static bool | s_onu_initialised [MAX_NR_OF_ONUS] = { 0 } |
#define QUERY_ONUS_INTERVAL_MS 10000 |
Query ONU instances every 10 s during the first 5 minutes after startup.
30 intervals of 10 s corresponds to 5 minutes.
Definition at line 104 of file populate_dm_startup.c.
#define QUERY_ONUS_NR_TIMES 30 |
Definition at line 105 of file populate_dm_startup.c.
A task to help in populating the XPON DM after startup.
If 'path' refers to a template object, then:
typedef enum _task_type task_type_t |
Task type.
When populating the XPON DM at startup, the plugin schedules 2 types of tasks:
enum _task_type |
Task type.
When populating the XPON DM at startup, the plugin schedules 2 types of tasks:
Enumerator | |
---|---|
task_none | |
task_query_indexes | |
task_query_content | |
task_type_nr |
Definition at line 119 of file populate_dm_startup.c.
|
static |
Do basic checks on the return values of a call towards the vendor module.
[in] | rc | return code of the call towards the vendor module. |
[in] | ret | result returned by vendor module |
[in] | func | name of the function called in the vendor module. For logging only. |
[in] | path | object path for which function was called. This can refer to a singleton or template object. For logging only. |
[in] | index | if function was called for an instance, this parameter is the instance index. It must be 0 if the function was called for a singleton. For logging only. |
The function returns false if:
Definition at line 225 of file populate_dm_startup.c.
|
static |
Handle the 1st task from s_tasks, remove it from the list, and delete it.
Subsequently reschedule the timer if there are remaining tasks.
Definition at line 536 of file populate_dm_startup.c.
void pplt_dm_cleanup | ( | void | ) |
Clean up the part responsible for populating the XPON DM at startup.
The plugin must call this function once when stopping.
Definition at line 648 of file populate_dm_startup.c.
bool pplt_dm_init | ( | void | ) |
Initialize the part responsible for populating the XPON DM at startup.
To start the whole process of the populating the XPON DM, the function schedules a task to query the instances of XPON.ONU every 10 s. (The plugin will stop the timer when it has found MAX_NR_OF_ONUS ONUs, or when 5 minutes have passed since startup.)
The plugin must call this function once at startup.
Definition at line 619 of file populate_dm_startup.c.
|
static |
Query the children of an object.
[in] | path | object path of a singleton or template object |
[in] | index | instance index for a template object. 0 (not applicable) for a singleton. |
[in] | id | object ID (caller normally derived it from path) |
[in] | templates | true if the function should query the children which are template objects, false if it should query the children which are singleton objects. |
The function appends a task to 's_tasks' for each child. It does not do any updates to the XPON DM.
For a child which is a singleton, it adds a task of type 'task_query_content'. For a child which is a template, it adds a task of type 'task_query_indexes'.
Example: An instance of "XPON.ONU.x.ANI" has children which are singletons, and children which are templates:
Definition at line 288 of file populate_dm_startup.c.
|
static |
Ask vendor module for object content, update DM and add tasks to query children.
[in] | task | has info about the object to query. If the field 'index' is 0, the task queries a singleton object, else it queries the instance with that index of a template object. |
The object content consists of the values to be assigned to the params of the object.
The function calls the function get_object_content() in the pon_ctrl namespace of the vendor module. It adds the instance to the XPON DM if it queried the instance of a template object, or it updates the object if it queried a singleton object.
The function subsequently adds tasks to 's_tasks' to handle the children of the object. It adds a task of type 'task_query_content' for each child which is a singleton, and it adds a task of type 'task_query_indexes' for each child which is a template.
Definition at line 356 of file populate_dm_startup.c.
|
static |
Ask the vendor module which instances it should create for a template object.
[in] | task | has info about the template object |
The function calls the function get_list_of_instances() in the pon_ctrl namespace of the vendor module. It appends a task of type task_query_content to 's_tasks' for each instance which does not yet exist in the XPON DM.
The function does not change anything in the XPON DM.
If the get_list_of_instances() call fails, the function logs an error and immediately returns an error. It does not retry.
Example: if task->path is XPON.ONU, it asks the vendor module if there are any instances for this object. If the vendor module returns the indexes 1 and 2, XPON.ONU.1 already exists and XPON.ONU.2 not, the function appends a task to 's_tasks' to query the content of XPON.ONU.2.
Check instance exists.
For an XPON.ONU instance also check if it's already initialised.
Definition at line 436 of file populate_dm_startup.c.
|
static |
Ask vendor module for instances of XPON.ONU.
[in,out] | timer | timer to query the instances of XPON.ONU every 10 s |
The function stops the timer if the number of instances of XPON.ONU is MAX_NR_OF_ONUS, or if 5 minutes passed since startup.
Otherwise the function calls query_indexes() for XPON.ONU.
Definition at line 574 of file populate_dm_startup.c.
|
static |
|
static |
|
static |
Create task and append it to 's_tasks'.
If it fails to create the task or to append the task to 's_tasks', the function is a no-op.
Definition at line 176 of file populate_dm_startup.c.
|
static |
Definition at line 196 of file populate_dm_startup.c.
|
static |
|
static |
|
static |
Counts the number of times the plugin has queried for the existence of ONUs since startup.
Definition at line 89 of file populate_dm_startup.c.
|
static |
Definition at line 96 of file populate_dm_startup.c.
|
static |
Definition at line 92 of file populate_dm_startup.c.
|
static |
Definition at line 94 of file populate_dm_startup.c.
|
static |
Definition at line 84 of file populate_dm_startup.c.