Hi,
I tried to build a NETCONF server that sends a notification that has multiple “identityref”.
The code is:
static void send_notif_monitoring(int usage, int threshold, char *nsf_name, int severity)
{
confd_tag_value_t vals[8];
int i = 0;
struct confd_identityref idref_alarm, idref_acqui;
idref_alarm.id = nsfmi_MEM_USAGE_ALARM;
idref_alarm.ns = nsfmi__ns;
idref_acqui.id = nsfmi_subscription;
idref_acqui.ns = nsfmi__ns;
CONFD_SET_TAG_XMLBEGIN(&vals[i], nsfmi_i2nsf_system_detection_alarm, nsfmi__ns); i++;
CONFD_SET_TAG_IDENTITYREF(&vals[i], nsfmi_acquisition_method, idref_acqui); i++;
CONFD_SET_TAG_IDENTITYREF(&vals[i], nsfmi_alarm_category, idref_alarm); i++;
CONFD_SET_TAG_UINT8(&vals[i], nsfmi_usage, usage); i++;
CONFD_SET_TAG_UINT8(&vals[i], nsfmi_threshold, threshold); i++;
CONFD_SET_TAG_STR(&vals[i], nsfmi_nsf_name, nsf_name); i++;
CONFD_SET_TAG_ENUM_VALUE(&vals[i], nsfmi_severity, severity); i++;
CONFD_SET_TAG_XMLEND(&vals[i], nsfmi_i2nsf_system_detection_alarm, nsfmi__ns); i++;
send_notification(vals, i);
}
The YANG data model is as follow:
module ietf-i2nsf-nsf-monitoring {
yang-version 1.1;
namespace
"urn:ietf:params:xml:ns:yang:ietf-i2nsf-nsf-monitoring";
prefix
nsfmi;
import ietf-inet-types{
prefix inet;
reference
"Section 4 of RFC 6991";
}
import ietf-yang-types {
prefix yang;
reference
"Section 3 of RFC 6991";
}
typedef severity {
type enumeration {
enum critical {
description
"The 'critical' severity level indicates that
an immediate corrective action is required.
A 'critical' severity is reported when a service
becomes totally out of service and must be restored.";
}
enum high {
description
"The 'high' severity level indicates that
an urgent corrective action is required.
A 'high' severity is reported when there is
a severe degradation in the capability of the
service and its full capability must be restored.";
}
enum middle {
description
"The 'middle' severity level indicates the
existence of a non-service-affecting fault
condition and corrective action should be done
to prevent a more serious fault. The 'middle'
severity is reported when the detected problem
is not degrading the capability of the service but
might happen if not prevented.";
}
enum low {
description
"The 'low' severity level indicates the detection
of a potential fault before any effect is felt.
The 'low' severity is reported when an action should
be done before a fault happen.";
}
}
description
"An indicator representing severity level.
The severity level starting from the highest are critical,
high, middle, and low.";
}
identity characteristics {
description
"Base identity for monitoring information
characteristics";
}
identity acquisition-method {
base characteristics;
description
"The type of acquisition-method. It can be multiple
types at once.";
}
identity subscription {
base acquisition-method;
description
"The acquisition-method type is subscription.";
}
identity query {
base acquisition-method;
description
"The acquisition-method type is query.";
}
identity emission-type {
base characteristics;
description
"The type of emission-type.";
}
identity periodical {
base emission-type;
description
"The emission-type type is periodical.";
}
identity on-change {
base emission-type;
description
"The emission-type type is on-change.";
}
identity dampening-type {
base characteristics;
description
"The type of dampening-type.";
}
identity no-dampening {
base dampening-type;
description
"The dampening-type is no-dampening.";
}
identity on-repetition {
base dampening-type;
description
"The dampening-type is on-repetition.";
}
identity alarm-type {
description
"Base identity for detectable alarm types";
}
identity MEM-USAGE-ALARM {
base alarm-type;
description
"A memory alarm is alerted.";
}
identity CPU-USAGE-ALARM {
base alarm-type;
description
"A CPU alarm is alerted.";
}
identity DISK-USAGE-ALARM {
base alarm-type;
description
"A disk alarm is alerted.";
}
notification i2nsf-system-detection-alarm {
description
"This notification is sent, when a system alarm
is detected.";
leaf alarm-category {
type identityref {
base alarm-type;
}
description
"The alarm category for
system-detection-alarm notification";
}
leaf acquisition-method {
type identityref {
base acquisition-method;
}
description
"The acquisition-method for characteristics";
}
leaf emission-type {
type identityref {
base emission-type;
}
description
"The emission-type for characteristics";
}
leaf dampening-type {
type identityref {
base dampening-type;
}
description
"The dampening-type for characteristics";
}
leaf usage {
type uint8 {
range "0..100";
}
units "percent";
description
"Specifies the used percentage";
}
leaf threshold {
type uint8 {
range "0..100";
}
units "percent";
description
"The threshold percentage triggering the alarm or
the event";
}
leaf message {
type string;
description
"This is a freetext annotation for
monitoring a notification's content.";
}
leaf vendor-name {
type string;
description
"The name of the NSF vendor";
}
leaf nsf-name {
type string;
description
"The name (or IP) of the NSF generating the message.";
}
leaf module-name {
type string;
description
"The module name outputting the message.";
}
leaf severity {
type severity;
description
"The severity of the alarm such as critical, high,
middle, low.";
}
}
}
The developer log is the only clue I get:
12-Jan-2021::16:05:41.801 xenial confd[24322]: devel-c Failed to send notification for stream I2NSF: ‘alarm-category’ cannot occur here as a child to ‘i2nsf-system-detection-alarm’.
This error happened only when using multiple identities. If I remove one of the CONFD_SET_TAG_IDENTITYREF, the notification is sent correctly.
Any help is appreciated.
Thank you
Patrick