openconfig / public

Repository for publishing OpenConfig models, documentation, and other material for the community.
Apache License 2.0
890 stars 644 forks source link

openconfig-terminal-device module : bad augment when statement #40

Closed mberroug closed 1 week ago

mberroug commented 7 years ago

Hello,

I can't validate data with this defintion:

augment "/oc-platform:components/oc-platform:component" { when "/oc-platform:components/oc-platform:component/" + "oc-platform:state/oc-platform:type = 'OPTICAL_CHANNEL'" { description "Augment is active when component is of type OPTICAL_CHANNEL"; } description "Adding optical channel data to physical inventory";

uses terminal-optical-channel-top {
}

} In fact 'OPTICAL_CHANNEL' is not typed oc-platform-types:OPENCONFIG_HARDWARE_COMPONENT or oc-platform-types:OPENCONFIG_SOFTWARE_COMPONENT

type in openconfig-platorm.yang module is defined like leaf type { type union { type identityref { base oc-platform-types:OPENCONFIG_HARDWARE_COMPONENT; } type identityref { base oc-platform-types:OPENCONFIG_SOFTWARE_COMPONENT; } }

einarnn commented 7 years ago

OPTICAL_CHANNEL is defined in openconfig-transport-types.yang, with oc-platform-types:OPENCONFIG_HARDWARE_COMPONENT as its base, so it should probably be referred to as 'oc-opt-types:OPTICAL_CHANNEL' in the when statement below.

Cheers,

Einar

On 11 Jan 2017, 13:03 +0000, mberroug notifications@github.com, wrote:

Hello,

I can't validate data with this defintion:

augment "/oc-platform:components/oc-platform:component" { when "/oc-platform:components/oc-platform:component/" + "oc-platform:state/oc-platform:type = 'OPTICAL_CHANNEL'" { description "Augment is active when component is of type OPTICAL_CHANNEL"; } description "Adding optical channel data to physical inventory";

uses terminal-optical-channel-top { }

} In fact 'OPTICAL_CHANNEL' is not typed oc-platform-types:OPENCONFIG_HARDWARE_COMPONENT or oc-platform-types:OPENCONFIG_SOFTWARE_COMPONENT

type in openconfig-platorm.yang module is defined like leaf type { type union { type identityref { base oc-platform-types:OPENCONFIG_HARDWARE_COMPONENT; } type identityref { base oc-platform-types:OPENCONFIG_SOFTWARE_COMPONENT; } }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub (https://github.com/openconfig/public/issues/40), or mute the thread (https://github.com/notifications/unsubscribe-auth/AFKGcOxpC2n0O_TdAuFIInqGHDwzeQoQks5rRNM6gaJpZM4Lgjf-).

aashaikh commented 7 years ago

@mberroug can you please say more about how you're doing your module validation ? I just want to try to reproduce. We recently fixed a couple of XPATH and when statement bugs in the terminal optics model but may have missed this.

mberroug commented 7 years ago

Hello,

Thanks for your reply.

I am using yang2dsdl tool for data validation.

Following is what I have:

== Using pre-generated schemas

== Validating grammar and datatypes ... openconfig-terminal-device.data validates.

== Adding default values... done.

== Validating semantic constraints ... --- Validity error at "/nc:data/oc-platform:components/oc-platform:component": Found nodes that are valid only when "$root/oc-platform:components/oc-platform:component/oc-platform:state/oc-platform:type = 'OPTICAL_CHANNEL'"

@einarnn has right , I think we should have 'oc-opt-types:OPTICAL_CHANNEL' in the when statement instead of only 'OPTICAL_CHANNEL' .

Regards,

fnchooft commented 6 years ago

Confirmed to work if the when-statement is altered. Is there any change to get an update for these issues? There are some of these which would really be helpful for people starting with OpenConfig. Kind regards, and thanks for sharing.

fnchooft commented 6 years ago

Afternoon, i changed the when-statement to make sure it is valid for only those components with config/type = 'OPTICAL_CHANNEL'. This showed up during tests with ConfD-5.4.10.

augment "/oc-platform:components/oc-platform:component" {
    when "./oc-platform:config/oc-platform:type = 'oc-opt-types:OPTICAL_CHANNEL'" {
      description
        "Augment is active when component is of type
        OPTICAL_CHANNEL";
    }
    description
      "Adding optical channel data to physical inventory";

    uses terminal-optical-channel-top {
    }
  }
venkataraghavan19 commented 6 years ago

Adding Type string as one of the types supported in the union will help us solve the issue. Need not change the augment statement. grouping platform-component-state { description "Operational state data for device components.";

leaf type {
  type union {
    **type string;**
    type identityref {
      base oc-platform-types:OPENCONFIG_HARDWARE_COMPONENT;
    }
    type identityref {
      base oc-platform-types:OPENCONFIG_SOFTWARE_COMPONENT;
    }
  }
  description
    "Type of component as identified by the system";
}
venkataraghavan19 commented 6 years ago

There is one more issue with respect to discussed augment , the Optical channel container(inside uses terminal-optical-channel-top group) will be listed for all components when any one optical channel component is created . grouping terminal-operational-mode-top { description "Top-level grouping for vendor-supported operational modes";

container operational-modes {
  description
    "Enclosing container for list of operational modes";

  list mode {
    key "mode-id";
    config false;
    description
      "List of operational modes supported by the platform.
      The operational mode provides a platform-defined summary
      of information such as symbol rate, modulation, pulse
      shaping, etc.";

    leaf mode-id {
      type leafref {
        path "../state/mode-id";
      }
      description
        "Reference to mode-id";
    }

    container config {
      description
        "Configuration data for operational mode";

      uses terminal-operational-mode-config;
    }

    container state {

      config false;

      description
        "Operational state data for the platform-defined
        operational mode";

      uses terminal-operational-mode-config;
      uses terminal-operational-mode-state;
    }
  }
}

}

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 180 days with no activity. If you wish to keep this issue active, please remove the stale label or add a comment, otherwise will be closed in 14 days.