簡體   English   中英

YANG:如何對沒有密鑰的嵌套列表配置數據建模

[英]YANG: how to model nested lists configuration data without key

我正在嘗試為此配置文件構建YANG模型,該模型具有沒有鍵的列表。 但是,由於必須使用YANG列表中的密鑰,所以我無法建立精確的YANG模型。 有什么想法如何表示列表列表而不用YANG中的鍵。

該文件包含ACL,其中可能有許多ACL(例如由用戶命名的ACL1,ACL2),並且具有如下示例中所示的規則。

acls:
  acl1:
  - rule:
      nw_src: 192.168.1.1/24  
      actions:
        allow: 1
  - rule:
      actions:
        allow: 0
  acl2:
  - rule:
      nw_src: 192.168.1.1/24  
      actions:
        allow: 0
  - rule:
      actions:
        allow: 1

我的YANG模特是

list acls{
     description "list of acls ";
      key "acl-name";
      ordered-by user;
      leaf acl-name {
        type string {
          length "1..64";
        }
      }
 list acle {
      description "This is a list of users in the system.";
      key "acle-name";
      ordered-by user;
      leaf acle-name {
        type string {
          length "1..64";
        }
        description
          "The name of access-list. A device MAY restrict the length
           and value of this name, possibly space and special
           characters are not allowed.";
      }

      container actions {
        description "actions for this acl entry ";    
        leaf allow {
          type uint8;
         }              
      } // end actions container       
   container match{
        description "match fields for this acl entry ";
    leaf nw_src{
         type inet:ipv4-address;
         }
    }
 }//match cont
 }//acle
} //acls

因此,相應的有效數據文件具有YANG所需的額外字段,但這些字段在我的原始配置文件中不存在,例如(aclname,acle,aclename)。

acls:
  acl1:
    aclname: acl1
    acle:
      rule11:
        aclename: rule11
        nw_src: 192.168.1.1/24
        actions:
          allow: 1
      rule12:
        aclename: rule12
        actions:
          allow: 0
  acl2:
    aclname: acl2
    acle:
      rule21:
        nw_src: 192.168.1.1/24    
        aclename: rule21
        actions:
          allow: 0
      rule22:
        aclename: rule22
        actions:
          allow: 1

RFC7950,7.8.2。 列表的“關鍵”聲明

如果列表表示配置,則“ key”語句必須存在,否則,則必須存在,它使用一個字符串作為參數,該字符串指定以空格分隔的列表,該列表由一個或多個葉子標識符組成。 葉子標識符不得在密鑰中多次出現。 每個這樣的葉子標識符必須引用列表的子葉子。 可以直接在列表的子語句中或列表中使用的分組中定義葉子。

關鍵字中指定的所有葉子的組合值用於唯一標識列表條目。 創建列表條目時,必須為所有鍵葉子賦予值。 因此,將忽略鍵葉子或其類型中的任何默認值。 鍵葉子中的所有“強制性”語句都會被忽略。

列出模型配置數據(無論是否嵌套)必須具有一個鍵。 沒有辦法解決這個問題,因為每個配置列表實例都必須是唯一可標識的,這樣instance-identifiers類的構造才能按預期工作。 如果沒有密鑰,您將很難告訴設備修改(甚至只是獲取)配置中的特定條目。 因此,您建議做的事情是無法實現的-這不是YANG的方式。

僅狀態數據( config false; )列表可能沒有鍵,因為它們不必以標准方式進行修改-它們的實例化/修改/刪除由設備的實現細節控制。

此外,您已經在示例中使用了鍵。 “ acl1”和“ acl2”顯然是“ acl”列表的實例,其鍵名已編碼為它們的名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM