cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
958
Views
5
Helpful
3
Replies

Yang Model Compilation syntax error: illegal keyword:

Jerems
Spotlight
Spotlight

Hi Guys,

 

May i ask you to help in solving an issue i am facing with a service package for which an error is issued once i want to compile it using the make command please. Pyang also indicates the same error:

 

container cisco-ios {​

when "deref(../name)/../ncs:module[1]/ncs:name='tailf-ned-cisco-ios'" {​

tailf:dependency "../name";​

}​

tailf:cli-drop-node-name;​

list interface {​

tailf:info "GigabitEthernet interface";​

key iface_id;​

leaf iface_id {​

tailf:info "GigabitEthernet Interface ID";​

mandatory true;​

type leafref {​

path "deref(../../../name)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";​

}​

}​

}

}

pyang yang/create_routing-instance.yang
yang/create_routing-instance.yang:48: error: syntax error: illegal keyword: ​

 

Line 48 is the one beginning by "Container cisco-ios {​"

Please let me know if you need further informations.

Thanks in advance for your help,

 

Regards,

Jerems

1 Accepted Solution

Accepted Solutions

cohult
Cisco Employee
Cisco Employee

Hi,

If your YANG model looks something like this dummy one:

module dummy {
  namespace "urn:dummy";
  prefix dummy;

  import tailf-ncs {
    prefix ncs;
  }
  import tailf-common {
    prefix tailf;
  }
  import tailf-ned-cisco-ios {
    prefix ios;
  }

  container dummy {
    leaf name {
      type leafref {
        path '/ncs:devices/ncs:device/ncs:name';
      }
    }
    container cisco-ios {
      when "deref(../name)/../ncs:module[1]/ncs:name='tailf-ned-cisco-ios'" {
        tailf:dependency "../name";
      }
      tailf:cli-drop-node-name;
      list interface {
        tailf:info "GigabitEthernet interface";
        key iface_id;
        leaf iface_id {
          tailf:info "GigabitEthernet Interface ID";
          mandatory true;
          type leafref {
            path "deref(../../../name)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";
          }
        }
      }
    }
  }
}

...and you are, for example, referencing the cisco-ios-cli-x.x example NED that comes with NSO, you need to add the path to the YANG models you are referring to from your YANG model. When referencing a NED you need to point to the NED YANG models that have been transformed by ncsc and are ready to be loaded into NSO. 

$ pyang -f yang -p $NCS_DIR/packages/neds/cisco-ios-cli-3.8/src/ncsc-out/modules/yang -p $NCS_DIR/src/ncs/yang dummy.yang

With the ncsc compiler you use the --yangpath flag.

View solution in original post

3 Replies 3

Alexander Stevenson
Cisco Employee
Cisco Employee

 

Hello @Jerems,

 

I'm seeing the same error when I use an online YANG Validator (https://yangcatalog.org/yangvalidator

 

1: error: syntax error: illegal keyword: ​

 

Accord to this discussion , the 'container' substatements are as follows:

 

7.5.2.  The container's Substatements

                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | presence     | 7.5.5   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+

 

This is a tricky one. I played with it for a while and didn't solve in yet. I used every flag imaginable in pyang and am no closer than when I started. I would follow read the discussion linked above and reformat as necessary.

 

Hope this helps!

cohult
Cisco Employee
Cisco Employee

Hi,

If your YANG model looks something like this dummy one:

module dummy {
  namespace "urn:dummy";
  prefix dummy;

  import tailf-ncs {
    prefix ncs;
  }
  import tailf-common {
    prefix tailf;
  }
  import tailf-ned-cisco-ios {
    prefix ios;
  }

  container dummy {
    leaf name {
      type leafref {
        path '/ncs:devices/ncs:device/ncs:name';
      }
    }
    container cisco-ios {
      when "deref(../name)/../ncs:module[1]/ncs:name='tailf-ned-cisco-ios'" {
        tailf:dependency "../name";
      }
      tailf:cli-drop-node-name;
      list interface {
        tailf:info "GigabitEthernet interface";
        key iface_id;
        leaf iface_id {
          tailf:info "GigabitEthernet Interface ID";
          mandatory true;
          type leafref {
            path "deref(../../../name)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";
          }
        }
      }
    }
  }
}

...and you are, for example, referencing the cisco-ios-cli-x.x example NED that comes with NSO, you need to add the path to the YANG models you are referring to from your YANG model. When referencing a NED you need to point to the NED YANG models that have been transformed by ncsc and are ready to be loaded into NSO. 

$ pyang -f yang -p $NCS_DIR/packages/neds/cisco-ios-cli-3.8/src/ncsc-out/modules/yang -p $NCS_DIR/src/ncs/yang dummy.yang

With the ncsc compiler you use the --yangpath flag.

Jerems
Spotlight
Spotlight

Thanks a lot Cohult !!!