ConfD User Community

Referencing augmented leaf

Hi Community,

I’m using ietf-alarms and ietf-alarms-x733.
The model of ietf-alarms-x733 augments al:alarm-notification adding it few more leaf attributes, for example: /al:alarm-notification/x733:event-type

I would like to construct notification including x733:event-type attribute but getting some errors. Reviewing examples, this forum, the manuals and the WWW didn’t help.

This is how I construct the notification:

CONFD_SET_TAG_XMLBEGIN(&notif_vals[i], al_alarm_notification,       al__ns);  i++;
CONFD_SET_TAG_STR(&notif_vals[i], al_resource,  "//object=mcp-1800//slot=msa");  i++;
CONFD_SET_TAG_IDENTITYREF(&notif_vals[i], al_alarm_type_id, idref);  i++;
CONFD_SET_TAG_STR(&notif_vals[i], al_alarm_type_qualifier,  "simulator");  i++;
CONFD_SET_TAG_ENUM_VALUE(&notif_vals[i], al_perceived_severity,  3);  i++;
CONFD_SET_TAG_STR(&notif_vals[i], al_alarm_text,  "Hello my first alarm in Muse!");  i++;
CONFD_SET_TAG_ENUM_VALUE(&notif_vals[i], x733_event_type,  5);  i++;
CONFD_SET_TAG_XMLEND(&notif_vals[i],   al_alarm_notification, al__ns);  i++;

This is the error I see:

devel-c Failed to send notification for stream notif: /alarm-notification/event-type: Invalid tagpath

I guess I need somehow to build the following path:

/al:alarm-notification/x733:event-type

But how?

Doron

Correct.

All the confd_tag_value_t elements in the array carry both a namespace and a tag value - from confd_lib.h:

struct xml_tag {
    u_int32_t tag;
    u_int32_t ns;
};

typedef struct confd_tag_value {
    struct xml_tag tag;
    confd_value_t v;
} confd_tag_value_t;

The value-setting macros such as CONFD_SET_TAG_STR() etc set the namespace to 0, which basically means “same as parent” - i.e. they “inherit” the namespace from e.g. CONFD_SET_TAG_XMLBEGIN(). This is not correct for your augmented leaf, and thus you need to set the namespace explicitly for that leaf - i.e. instead of

CONFD_SET_TAG_ENUM_VALUE(&notif_vals[i], x733_event_type,  5);  i++;

you need to do

CONFD_SET_TAG_ENUM_VALUE(&notif_vals[i], x733_event_type,  5); 
CONFD_SET_TAG_NS(&notif_vals[i], x733__ns);   i++;

(It would probably be preferable to use the x733_equipment_alarm #define from the header file instead of the 5, though.)

Aside: It is also possible to do the whole thing without the generated header files, using confd_str2hash() on the string forms for namespaces and tags instead of the #defines. This requires that schema information has been loaded into the library, though - the code in the netconf_notifications example doesn’t do that, but it can of course be added. With the schema loaded, you can also use the string form of the data values via confd_str2val() , and thus e.g. use "equipment-alarm" instead of 5 - or the x733_equipment_alarm #define - for the event-type leaf above.