blob: 60a35731efdc02d32a2b19349b35c24135e1d11f [file] [log] [blame]
Tomáš Peckadac27d42021-02-22 13:20:05 +01001module czechlight-network {
2 yang-version 1.1;
3 namespace "http://czechlight.cesnet.cz/yang/czechlight-network";
4 prefix cla-network;
5
6 import ietf-interfaces {
7 prefix if;
8 }
9
Tomáš Pecka2a4ea7b2021-03-30 17:01:37 +020010 import ietf-routing {
11 prefix rt;
12 }
13
Tomáš Peckadac27d42021-02-22 13:20:05 +010014 import ietf-ip {
15 prefix ip;
16 }
17
18 import iana-if-type {
19 prefix ianaift;
20 }
21
Tomáš Pecka2d87fd12021-05-30 14:20:28 +020022 import ietf-ipv6-unicast-routing {
23 prefix v6ur;
24 }
25
Tomáš Peckadac27d42021-02-22 13:20:05 +010026 revision 2021-02-22 {
27 description
28 "Initial version. Removes interface statistics in ietf-interfaces model, removes deprecated container
29 ietf-interfaces:interface-state and makes the nodes in ietf-interfaces model config false.";
30 }
31
Tomáš Pecka44131292021-03-10 12:30:43 +010032 // We don't support discontinuity time (yet)
33 deviation /if:interfaces/if:interface/if:statistics/if:discontinuity-time { deviate not-supported; }
Tomáš Peckadac27d42021-02-22 13:20:05 +010034
Tomáš Pecka2d87fd12021-05-30 14:20:28 +020035 // IPv6 router advertisements is not supported
36 deviation /if:interfaces/if:interface/ip:ipv6/v6ur:ipv6-router-advertisements { deviate not-supported; }
37
Tomáš Pecka2a4ea7b2021-03-30 17:01:37 +020038 // Remove deprecated ietf-interfaces-state and ietf-routing containers. Beware, rt:routing-state references if:interfaces-state.
39 deviation /rt:routing-state { deviate not-supported; }
Tomáš Peckadac27d42021-02-22 13:20:05 +010040 deviation /if:interfaces-state { deviate not-supported; }
41
Tomáš Pecka71a98b02021-05-17 15:59:40 +020042 // As of now we implement the ietf-routing model to contain operational data only
Tomáš Pecka2a4ea7b2021-03-30 17:01:37 +020043 deviation /rt:routing { deviate add { config false; } }
Tomáš Pecka14e663e2021-03-08 13:35:33 +010044
Tomáš Pecka71a98b02021-05-17 15:59:40 +020045 // We do not support configuring some parts of if:interfaces tree
Tomáš Peckade0ef2f2021-07-08 13:23:50 +020046 deviation /if:interfaces/if:interface/ip:ipv4/ip:forwarding { deviate add { config false; } }
47 deviation /if:interfaces/if:interface/ip:ipv4/ip:mtu { deviate add { config false; } }
48 deviation /if:interfaces/if:interface/ip:ipv4/ip:neighbor { deviate add { config false; } }
49 deviation /if:interfaces/if:interface/ip:ipv6/ip:forwarding { deviate add { config false; } }
50 deviation /if:interfaces/if:interface/ip:ipv6/ip:mtu { deviate add { config false; } }
51 deviation /if:interfaces/if:interface/ip:ipv6/ip:neighbor { deviate add { config false; } }
52 deviation /if:interfaces/if:interface/ip:ipv6/ip:dup-addr-detect-transmits { deviate add { config false; } }
Tomáš Pecka71a98b02021-05-17 15:59:40 +020053
54 // User should not create new links or reconfigure link types
55 deviation /if:interfaces/if:interface/if:name {
56 deviate add {
Tomáš Peckac8523852023-08-30 16:59:32 +020057 must '. = "br0" or . = "eth0" or . = "eth1" or . = "eth2" or . = "osc" or . = "oscW" or . = "oscE"' {
Tomáš Pecka71a98b02021-05-17 15:59:40 +020058 error-message "Link name must be chosen from the following options: {br0, eth0, eth1, osc, oscW, oscE}.";
59 }
60 }
61 }
62
63 deviation /if:interfaces/if:interface/if:type {
64 deviate add {
65 must '(../if:name = "br0" and . = "ianaift:bridge") or
66 (../if:name = "eth0" and . = "ianaift:ethernetCsmacd") or
67 (../if:name = "eth1" and . = "ianaift:ethernetCsmacd") or
Tomáš Peckac8523852023-08-30 16:59:32 +020068 (../if:name = "eth2" and . = "ianaift:ethernetCsmacd") or
Tomáš Pecka71a98b02021-05-17 15:59:40 +020069 (../if:name = "osc" and . = "ianaift:ethernetCsmacd") or
70 (../if:name = "oscW" and . = "ianaift:ethernetCsmacd") or
71 (../if:name = "oscE" and . = "ianaift:ethernetCsmacd")' {
72 error-message "Link type can't be reconfigured.";
73 }
74 }
75 }
76
Tomáš Peckac2929a62021-06-05 17:21:03 +020077 augment /if:interfaces/if:interface {
78 description "Add the option to add this link to a bridge.";
79
80 leaf bridge {
81 must '. = "br0"' {
82 error-message "br0 is the only available bridge interface.";
83 }
84
85 when '(not(../ip:ipv4) or ../ip:ipv4/ip:enabled[.="false"]) and
86 (not(../ip:ipv6) or ../ip:ipv6/ip:enabled[.="false"])' {
87 description "IP protocols must be disabled for enslaved link.";
88 }
89
90 type if:interface-ref;
91 mandatory false;
92 description "The name of the bridge to add the link to.";
93 }
94 }
95
Tomáš Peckade0ef2f2021-07-08 13:23:50 +020096 // Make it hard to accidentally lose connection by removing ipv4/ipv6 presence containers or all IP addresses
97 deviation /if:interfaces/if:interface {
98 deviate add {
99 must 'if:enabled = "false" or
100 ip:ipv4/ip:enabled = "true" or
Tomáš Peckac2929a62021-06-05 17:21:03 +0200101 ip:ipv6/ip:enabled = "true" or
102 cla-network:bridge' {
Tomáš Peckadae59392021-10-13 09:11:21 +0200103 error-message "Enabled interface must always have at least one protocol active or it must be connected in the bridge.";
Tomáš Peckade0ef2f2021-07-08 13:23:50 +0200104 }
Tomáš Peckac2929a62021-06-05 17:21:03 +0200105 }
106 }
Tomáš Peckade0ef2f2021-07-08 13:23:50 +0200107
Tomáš Peckabd43a942021-08-04 10:12:49 +0200108 augment /if:interfaces/if:interface/ip:ipv4 {
109 description "Add the IPv4 autoconfiguration option (DHCP client).";
110
111 leaf dhcp-client {
112 type boolean;
113 default true;
114 description "Enable DHCP client.";
115 }
116 }
117
Tomáš Peckade0ef2f2021-07-08 13:23:50 +0200118 deviation /if:interfaces/if:interface/ip:ipv4 {
119 deviate add {
Tomáš Peckabd43a942021-08-04 10:12:49 +0200120 must 'ip:enabled = "false" or count(ip:address) > 0 or cla-network:dhcp-client = "true"' {
121 error-message "There must always be at least one IPv4 address or the autoconfiguration must be turned on unless the protocol is disabled.";
Tomáš Peckade0ef2f2021-07-08 13:23:50 +0200122 }
123 }
124 }
125
126 deviation /if:interfaces/if:interface/ip:ipv6 {
127 deviate add {
Tomáš Peckabd43a942021-08-04 10:12:49 +0200128 must 'ip:enabled = "false" or count(ip:address) > 0 or ip:autoconf/ip:create-global-addresses = "true"' {
129 error-message "There must always be at least one IPv6 address or the autoconfiguration must be turned on unless the protocol is disabled.";
Tomáš Peckade0ef2f2021-07-08 13:23:50 +0200130 }
131 }
132 }
133
Tomáš Pecka91d5fe72021-03-31 18:42:39 +0200134 identity dhcp {
135 base rt:routing-protocol;
136 description "Identity for route installed by DHCP.";
137 }
138 identity ra {
139 base rt:routing-protocol;
140 description "Identity for route installed by router advertisement.";
141 }
Tomáš Peckadac27d42021-02-22 13:20:05 +0100142}