r2 - 2008-11-04 - 21:06:43 - MartinBjoerklundYou are here: TWiki >  Main Web > YangExamples > YangExamplesExecdInterface
submodule execd-interfaces {

    belongs-to execd { prefix execd; }

    import yang-types { prefix yang; }
    import inet-types { prefix inet; }
    import ieee-types { prefix ieee; }

    include execd-types;
  
    description
        "The 'interfaces' component provides support for configuring network
         interfaces, both link-level (including VLAN-tagged interfaces)
         and IP addresses (IPv4 and IPv6).

         The data model is loosely based on (a subset of) Juniper's, in
         particular the sub-division of interfaces into numbered 'logical
         units' - this allows for grouping of IP addresses, as well as for
         configuring VLAN tagging without exposing the interface naming
         scheme used natively by Linux for this.";

    revision "2008-11-04" {
        description "draft-ietf-netmod-yang-02 compatible.";
    }
    revision "2007-08-29" {
        description "Syntax fixes after pyang validation.";
    }
    revision "2007-06-08" {
        description "Initial revision.";
    }
    
    typedef interfaceSpeed {
        type enumeration {
            enum ten { value "10";}
            enum hundred { value "100";}
            enum thousand { value "1000"; }
        }
    }
    
    typedef interfaceDuplex {
        type enumeration {
            enum "half";
            enum "full";
        }
    }

    grouping commonPacketsCounters {
        leaf bytes {
            type yang:counter64;
        }
        leaf packets {
            type yang:counter64;
        }
        leaf errors {
            type yang:counter32;
        }
        leaf dropped {
            type yang:counter32;
        }
    }
    
    grouping txPacketsCounters {
        uses commonPacketsCounters;
        leaf collisions {
            type yang:counter32;
        }
    }
    
    grouping interfaces {
        container interfaces {
            list interface {
                must "(duplex and speed) or (not(duplex) and not(speed))" {
                    error-message "Neither or both of 'speed' and 'duplex'
                                   must be set";
                }
                key name;
                leaf name {
                    type interfaceName;
                }
                leaf description {
                    type string;
                }
                leaf enabled {
                    type boolean;
                    default true;
                }
                leaf speed {
                    type interfaceSpeed;
                    description "not supported for all types of interfaces";
                }
                leaf duplex {
                    type interfaceDuplex;
                    description "not supported for all types of interfaces";
                }
                leaf mtu {
                    type int16 {
                        range "68..1500";
                    }
                }
                leaf mac {
                    type ieee:mac-address;
                }
                container status {
                    config false;
          
                    leaf link {
                        type enumeration {
                            enum up;
                            enum down;
                        }
                    }
                    leaf speed {
                        type interfaceSpeed;
                    }
                    leaf duplex {
                        type interfaceDuplex;
                    }
                    leaf mtu {
                        type int32;
                    }
                    leaf mac {
                        type ieee:mac-address;
                    }
                    container receive {
                        uses commonPacketsCounters;
                    }
                    container transmit {
                        uses txPacketsCounters;
                    }
                }
                list unit {
                    key name;
                    leaf name {
                        type interfaceLogicalUnit;
                    }
                    leaf enabled {
                        type boolean;
                    }
                    leaf description {
                        type string;
                    }
                    leaf vlan-id {
                        type ieee:vlanid;
                    }
                    container status {
                        container receive {
                            uses commonPacketsCounters;
                        }
                        container transmit {
                            uses txPacketsCounters;
                        }
                    }
                    container family {
                        choice family {
                            case c1 {
                                container inet {
                                    list address {
                                        key name;
                                        leaf name {
                                            type inet:ipv4-address;
                                        }
                                        leaf prefix-length {
                                            type prefixLengthIPv4;
                                        }
                                        leaf broadcast {
                                            type inet:ipv4-address;
                                        }
                                    }
                                }
                            }
                            case c2 {
                                container inet6 {
                                    list address {
                                        key name;
                                        leaf name {
                                            type inet:ipv6-address;
                                        }
                                        leaf prefix-length {
                                            type prefixLengthIPv6;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
  

    

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
YANG
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback