Chinaunix首页 | 论坛 | 博客
  • 博客访问: 156004
  • 博文数量: 40
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 410
  • 用 户 组: 普通用户
  • 注册时间: 2014-02-11 09:11
文章分类

全部博文(40)

文章存档

2020年(1)

2017年(36)

2014年(3)

我的朋友

分类: 系统运维

2017-03-19 11:37:09


点击(此处)折叠或打开

  1. <!--
  2. *******************************************************
  3. * <CONFIG> Specify the config operation.
  4. *
  5. * operation - config operation to perform
  6. *
  7. ********************************************************
  8. -->
  9.     <xs:simpleType name="operation_t">
  10.         <xs:restriction base="xs:string">
  11.             <xs:enumeration value="none"/>
  12.             <xs:enumeration value="set"/>
  13.             <xs:enumeration value="unset"/>
  14.             <xs:enumeration value="dump"/>
  15.         </xs:restriction>
  16.     </xs:simpleType>

  17.     <xs:complexType name="config_t">
  18.         <!-- operation : set unset dump -->
  19.         <xs:attribute name="operation" type="operation_t" use="optional" default="set"/>
  20.         <!-- priority : 设置配置节点的优先级,在匹配或者比较一个配置节点的时候首先匹配或者比较priority,
  21.                         如果匹配或者相等在匹配其他内容。
  22.                        整体的使用:
  23.                            1).konf_tree_compare
  24.                               priority seq_num sub_num line
  25.                            2).konf_tree_find_conf
  26.                               priority seq_num line
  27.                            3).konf_tree_del_pattern
  28.                               priority seq_num!=0的情况 seq_num==0的情况 pattern line
  29.                            4).normalize_seq
  30.                               当执行完set或者unset操作后,konfd会对指定priority(set或者unset命令中使用-p指定的priority)
  31.                               节点的seq_num做一次重新排序,以保证seq_num的连续性.
  32.                        hi,高8位,只有在konf_tree_fprintf中配合splitter使用
  33.                        lo,低8位,未被使用
  34.              命令 : -p 0x7f00
  35.                        -->
  36.         <xs:attribute name="priority" type="xs:string" use="optional" default="0x7f00"/>
  37.         <!-- pattern : 设置位置,对line进行正则匹配
  38.                        如果是set,匹配到节点后,line相同则不进行设置,line不同则删除匹配到的节点然后插入新节点;
  39.                        如果是unset,删除匹配到的节点以及其子树;
  40.                        如果是dump,返回匹配到的节点以及其字数;
  41.              注意 : 在unset和dump操作中,指定line是没有任何意义的,只需要指定pattern即可
  42.              命令 : -r regexp
  43.                        -->
  44.         <xs:attribute name="pattern" type="xs:string" use="optional" default="^${__cmd}"/>
  45.         <!-- file : 重定向dump操作获取道德节点数据到指定文件
  46.              注意 : 只在dump_running_config函数中被使用
  47.                     严格要求使用绝对路径指定file
  48.              命令 : -f path
  49.                     -->
  50.         <xs:attribute name="file" type="xs:string" use="optional" default="startup-config"/>
  51.         <!-- splitter : 指定顶层节点之间是否使用分隔符"!\n"
  52.                         splitter==0 或者 priority.hi != 0即使用分隔符
  53.              注意 : 只在set操作中有效
  54.              命令 : -i(不使用分隔符)
  55.                         -->
  56.         <xs:attribute name="splitter" type="bool_t" use="optional" default="true"/>
  57.         <!-- sequence : 指定存储节点的序号seq_num的变量名称
  58.                         如果指定了节点的序号,那么priority不能为0,否则在函数konf_tree_del_pattern中会报错
  59.              注意 : seq_num从1开始依次递增;
  60.                         seq_num==0属于特殊情况,而事实上配置树中根本不会出现seq==true且seq_num==0的情况;
  61.                         配置树中的seq_num是连续的,例如如果第一次即直接指定seq_num=99,那么seq_num会被自动修改为1;
  62.              命令 : -q seq_num(1 2 3 4 5 ......)
  63.                         -->
  64.         <xs:attribute name="sequence" type="xs:string" use="optional" default="0"/>
  65.         <!-- unique : 在set操作中指定节点是否要具有唯一性
  66.                       如果为treu,在set执行针对unique的操作konf_tree_del_pattern
  67.                       如果为false,直接set,可能会导致配置树中同时存在多个相同的节点
  68.              命令 : -n(节点不具有唯一性)
  69.                       -->
  70.         <xs:attribute name="unique" type="bool_t" use="optional" default="true"/>
  71.         <!-- depth : 路径深度,如果指定了depth则使用depth的值,如果没有指定depth则使用command的view的depth;
  72.              clish : clish发送给konfd的命令中的path是这样生成的:当depth不为0时,clish将shell->pwdv[1]~shell->pwdv[depth]中的line
  73.                      全部集合在一起形成命令中的path,一旦其中有一个pwd的line为null,那么整个path都将为NULL;
  74.              命令 : 可以通过-h选项指定路径深度,但是插入节点的时候根本不是根据-h指定的深度来设置节点的深度,
  75.                      而是根据真正的路径深度pwdc来设置的-->
  76.         <xs:attribute name="depth" type="xs:string" use="optional"/>
  77.         <!-- SET操作在处理unique前会判断其路径是否存在,不存在则报错
  78.              SET操作在处理unique时有三种情况:
  79.              一、节点已存在,不插入新节点
  80.                 priority== && seq_num== && {new.seq==true && cur.seq==false} && pattern== && line==
  81.              二、位置被占领,删除占领位置的所有节点,然后插入新节点
  82.                 priority== && seq_num== && {new.seq==true && cur.seq==false} && pattern== && line!=
  83.              三、set命令错误
  84.                 1).seq==true 但是 priority==0
  85.                 2).指定的pattern是非法的正则匹配串
  86.              _________________________________________________
  87.                 priority!=0时,priority不同的节点都被保留
  88.                 seq==true
  89.                 {
  90.                     seq_num!=0时,seq_num不同的节点都被保留
  91.                     seq_num==0时, seq_num也是0(即seq==false)的节点都被保留
  92.                     注意:因为konfd的树中不可能存在seq==true&&seq_num=0的节点,
  93.                           所以当执行set操作且seq_num被指定为0时,
  94.                           意味着及时存在着相同的节点但是其seq==true,
  95.                           那么仍然会插入新的节点!!!
  96.                 }
  97.                 pattern不同的节点会被保留
  98.                 line相同, 则不会插入新节点
  99.                 line不同, 删除当前节点
  100.              -->
  101.         <!--在set操作中有效的命令
  102.             -s operation
  103.             -p priority
  104.             -q seq_num
  105.             -r pattern
  106.             -l line
  107.             -i splitter
  108.             -n unique
  109.             -->
  110.         <!--在unset操作中有效的命令
  111.             -s operation
  112.             -p priority
  113.             -q seq_num
  114.             -r pattern
  115.             -->
  116.         <!--在dump操作中有效的配置
  117.             -s operation
  118.             -q seq_num
  119.             -r pattern
  120.             -f file
  121.             -h depth
  122.             -->
  123.         <!--各命令的初始化
  124.             this->op = KONF_QUERY_OP_NONE;
  125.             this->pattern = NULL;
  126.             this->priority = 0;
  127.             this->seq = BOOL_FALSE;
  128.             this->seq_num = 0;
  129.             this->pwdc = 0;
  130.             this->pwd = NULL;
  131.             this->line = NULL;
  132.             this->path = NULL;
  133.             this->splitter = BOOL_TRUE;
  134.             this->unique = BOOL_TRUE;
  135.             this->depth = -1;
  136.             -->
  137.         <!--配置树节点中的数据
  138.             struct konf_tree_s
  139.             {
  140.                 lub_list_t *list;
  141.                 char *line;
  142.                 unsigned short priority;
  143.                 unsigned short seq_num; 0-N(0为无效值相当于seq=false,有效值从1开始)
  144.                 unsigned short sub_num; KONF_ENTRY_NEW | KONF_ENTRY_OK
  145.                 bool_t splitter; true | false
  146.                 int depth; 0-N(有命令中的pwdc设置)
  147.             };
  148.             -->
  149.     </xs:complexType>

阅读(1978) | 评论(0) | 转发(0) |
0

上一篇:CLISH konfd使用详解

下一篇:CLISH VIEW的depth

给主人留下些什么吧!~~