mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
530 stars 343 forks source link

any added or modified xpath express by deviation is not checked whether the reference is correct #765

Closed lllyfeng closed 2 years ago

lllyfeng commented 2 years ago

I add a must expression to a target node, but the expression is wrong. but it's complied successfully by pyang for example: the original module:

module huawei-devm {
  namespace "urn:huawei:yang:huawei-devm";
  prefix devm;
  organization
    "Huawei Technologies Co., Ltd.";
  contact
    "Huawei Industrial Base
     Bantian, Longgang
     Shenzhen 518129
     People's Republic of China
     Website: http://www.huawei.com
     Email: support@huawei.com";
  description
    "Global configuration.";
  revision 2020-08-07 {
    description
      "Add container active-hardware-alarm-infos and history-hardware-alarm-infos.";
    reference
      "Huawei private.";
  }
  revision 2020-06-04 {
    description
      "Add units of up-to-last-clean, alarm-exist-days, enable-transmission-delay and physical-bandwidth.
       Modify operation-exclude for list chassis, mpu-board, lpu-board, card and port.
       Delete leaf current-id, next-id, current-run-mode and next-run-mode.
       Modify the description of port position.";
    reference
      "Huawei private.";
  }

  container devm {
    description
      "Global configuration.";
    container mpu-boards {
      description
        "List of MPU.";
      list mpu-board {
        key "position";
        description
          "Specify MPU.";
        leaf position {
          type string {
            length "1..32";
          }
          description
            "MPU position.";
        }
        leaf index {
          type uint32;
          config false;
          description
            "MPU index.";
        }
        leaf board-type {
          type string {
            length "0..30";
          }
          config false;
          description
            "MPU type.";
        }
        leaf sdram-size {
          type uint32;
          units MByte;
          config false;
          description
            "SDRAM size.";
        }
        leaf nvram-size {
          type uint32;
          units MByte;
          config false;
          description
            "NVRAM size.";
        }
        leaf flash-size {
          type uint32;
          units MByte;
          config false;
          description
            "Flash size.";
        }
      }
    }
  }
}

and my deviation module:

module huawei-devm-deviations-NE8000M8M14 {
  namespace "urn:huawei:yang:huawei-devm-deviations-NE8000M8M14";
  prefix devm-devs-NE8000M8M14;

  import huawei-devm {
    prefix devm;
  }

  organization
    "Huawei Technologies Co., Ltd.";
  contact
    "Huawei Industrial Base
     Bantian, Longgang
     Shenzhen 518129
     People's Republic of China
     Website: http://www.huawei.com
     Email: support@huawei.com";
  description
    "Global Configuration.";

  revision 2019-04-03 {
    description
      "Initial revision.";
    reference "Huawei private.";
  }

  deviation "/devm:devm/devm:mpu-boards/devm:mpu-board/devm:sdram-size" {
    deviate add {
       must "../devm:abc > ../devm:nvram-size";
    }
  }

}

NOTE: the abc node is not defined.