Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File callback RPC not updating the running config #153

Open
Jojosep opened this issue Jun 23, 2017 · 0 comments
Open

File callback RPC not updating the running config #153

Jojosep opened this issue Jun 23, 2017 · 0 comments

Comments

@Jojosep
Copy link

Jojosep commented Jun 23, 2017

Hello, i've been struggling with this issue for a couple of days.

I have a custom yang model with the following structure:

container box {
    leaf boxId {
        type string;
        config true;
        description
            "Box identifier"
    }
}

The box-state container (defined in the same yang file) has the same structure with the "-state" suffix.

I can edit config this data from other netopeer clients but the problems appears when I try to set this data from a file callback I created. The code for this callback is:

int boxid_callback(const char *filepath, xmlDocPtr *edit_config, int *exec) {
    FILE *fp = NULL;
    char *line = NULL;
    size_t len;
    xmlDocPtr doc = NULL;
    xmlNsPtr ns = NULL;
    xmlNodePtr root = NULL;

    fp = fopen(filepath, "r");
    if(fp != NULL){
        getline(&line, &len, fp);
        fclose(fp);
    }

    if(line != NULL && len > 0){
        deleteNewLineChar(line);
        nc_verb_warning("The new boxId is %s", line);
        if (boxGetBoxId() == NULL || strcmp(boxGetBoxId(), line) != 0){
            setBoxId(line); // here I set the boxId on my private structures
           //transapi_init(edit_config); <-- Pay attention to this line; I'll come here in a minute
            *exec = 1;

            doc = xmlNewDoc(BAD_CAST "1.0");
            xmlDocSetRootElement(doc, root = xmlNewDocNode(doc, NULL, BAD_CAST "box", NULL));
            ns = xmlNewNs(root, BAD_CAST "myCompanyDomain.com", NULL);
            xmlSetNs(root, ns);
            xmlNewChild(root, root->ns, BAD_CAST "boxId", BAD_CAST line);
            *edit_config = doc;
            free(line);
            line = NULL;
        }
    }

    return 0;
}

I created a box-init.c file which creates the startup config and uses the transapi_init function in my code. The transapi_init function seems to be working when executed from box-init.c but it's not creating any structure when executed from the file callback.

Whenever this function is executed (because the file gets modified) I get the following output in the netopeer server's output (executed with -v5 --I know there's only 3 levels but...):

netopeer-server[17724]: The new boxId is blackUnicorn01
netopeer-server[17724]: unknown element boxId!
netopeer-server[17724]: Merging the node boxId (src/datastore/edit_config.c:2330)
netopeer-server[17724]: Creating the node boxId (src/datastore/edit_config.c:1492)
netopeer-server[17724]: Deleting the node boxId (src/datastore/edit_config.c:1008)
netopeer-server[17724]: RelaxNG validation on subdatastore 1681692778
netopeer-server[17724]: subdatastore 1681692778 fails to validate
netopeer-server[17724]: FMON: Performing edit-config RPC failed.

I'm don't know if it's actually a bug or if there is something missing in my code; could you please help me out?

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant