Working with objects using the API

I have posted about this before, but figured I could give it another try. I am trying to work with objects trough the genieACS API. Being more specific I am trying to create and delete objects. These are both described in the API documentation:

AddObject: API Reference — GenieACS Documentation 1.2.9 documentation
DeleteObject: API Reference — GenieACS Documentation 1.2.9 documentation

The objects i’m working with as an example are VoiceProfiles: “InternetGatewayDevice.Services.VoiceService.1.VoiceProfile”

The creation of a new voiceProfile works. But when I try to delete it it doesn’t happen. This is the same with other objects I have tried. I can see that the task to delete the object is created, and no fault is generated when the task is executed.

I enabled the debug for genieAcs and I cannot find an error related to this task.

O hope someone can help me resolve this issue.

Adding/removing objects via the API is going to be fraught with issues as there is no guarantee of what id the CPE will assign to an instance. It is possible to figure this out, you will have to add the instance. Then refreshing the param. Then try to determine what the id is of the new instance. For some items where you will only have one item, its pretty straight forward.

I find its far easier to manage this by either pre-configuring the CPE with the exact number of instances there can be, and then enabling/disabling the instance instead of deleting it. And because the CPE is preconfigured with all the instances needed, I know the exact instance ID. For example, our DSL CPEs can be configured in routed or bridged mode. They com preconfigured with a pppoe instance for every WAN interface. And also with a bridged instance, with a status of disabled. When a CM wants the CPE in bridged mode, its a simple matter to disable PPP and enable the bridged interface.

For other things, this isn’t possible. We allow customers to create an arbitrary number of port forwarding instances. Managing this via the API would be fraught with peril. So the way I handle this is via a tag called UpdatePortForwards. When that tag is set, a provision script fires off that queries our subscriber management platform for the port forwards for the CM. Then its a simple matter of telling GenieACS that there should be 0 instances of the port forwards, except for the ones. Here is part of the script I use to manage port forwards:

function updatePortForwards(portForwards) {
    let keys = [

    for (let basePath of keys) {
        declare(basePath + '.[]', null, {path: 0});

        for (let forward of portForwards) {
            const path = basePath + '.[' + Object.keys(forward).map(key => key + ':' + forward[key]).join(',') + ']';

            log(`\r\n\r\nPortForwards - Updating - ${path}\r\n\r\n`, forward);

            declare(path, {path: 1}, {path: 1});
1 Like