Srikanth Vavilapalli | 1725e49 | 2014-12-01 17:50:52 -0800 | [diff] [blame^] | 1 | # |
| 2 | # Copyright (c) 2013 Big Switch Networks, Inc. |
| 3 | # |
| 4 | # Licensed under the Eclipse Public License, Version 1.0 (the |
| 5 | # "License"); you may not use this file except in compliance with the |
| 6 | # License. You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.eclipse.org/legal/epl-v10.html |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 13 | # implied. See the License for the specific language governing |
| 14 | # permissions and limitations under the License. |
| 15 | # |
| 16 | |
| 17 | import fmtcnv |
| 18 | |
| 19 | """ |
| 20 | FLOW_ENTRY_SUBMODE_COMMAND_DESCRIPTION = { |
| 21 | 'name' : 'flow-entry', |
| 22 | 'mode' : 'config-switch*', |
| 23 | 'command-type' : 'config-submode', |
| 24 | 'short-help' : 'Enter flow-entry submode, configure single static flow entry', |
| 25 | 'doc' : 'flow-entry|flow-entry', |
| 26 | 'doc-example' : 'flow-entry|flow-entry-example', |
| 27 | 'obj-type' : 'flow-entry', |
| 28 | 'parent-field' : 'switch', |
| 29 | 'submode-name' : 'config-switch-flow-entry', |
| 30 | 'args' : { |
| 31 | 'field' : 'name', |
| 32 | 'type' : 'identifier', |
| 33 | 'completion' : 'complete-object-field', |
| 34 | 'scoped' : True, |
| 35 | 'syntax-help' : 'Enter name for a flow-entry', |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | # obj_type flow-entry field hard-timeout |
| 40 | FLOW_ENTRY_EDIT_HARD_TIMEOUT_COMMAND_DESCRIPTION = { |
| 41 | 'name' : 'hard-timeout', |
| 42 | 'mode' : 'config-switch-flow-entry', |
| 43 | 'short-help' : 'Set hard-timeout for this flow', |
| 44 | 'doc' : 'flow-entry|hard-timeout', |
| 45 | 'doc-example' : 'flow-entry|hard-timeout-example', |
| 46 | 'command-type' : 'config', |
| 47 | 'args' : ( |
| 48 | { |
| 49 | 'field' : 'hard-timeout', |
| 50 | 'base-type' : 'integer', |
| 51 | 'range' : (0, 65535), |
| 52 | 'doc' : 'flow-entry|hard-timeout-field', |
| 53 | } |
| 54 | ) |
| 55 | } |
| 56 | |
| 57 | |
| 58 | # obj_type flow-entry field idle-timeout |
| 59 | FLOW_ENTRY_EDIT_IDLE_TIMEOUT_COMMAND_DESCRIPTION = { |
| 60 | 'name' : 'idle-timeout', |
| 61 | 'mode' : 'config-switch-flow-entry', |
| 62 | 'short-help' : 'Set idle-timout for this flow', |
| 63 | 'doc' : 'flow-entry|idle-timeout', |
| 64 | 'doc-example' : 'flow-entry|idle-timeout-example', |
| 65 | 'command-type' : 'config', |
| 66 | 'args' : ( |
| 67 | { |
| 68 | 'field' : 'idle-timeout', |
| 69 | 'base-type' : 'integer', |
| 70 | 'range' : (0, 65535), |
| 71 | 'doc' : 'flow-entry|idle-timeout-field', |
| 72 | } |
| 73 | ) |
| 74 | } |
| 75 | |
| 76 | |
| 77 | # obj_type flow-entry field actions |
| 78 | FLOW_ENTRY_EDIT_ACTIONS_COMMAND_DESCRIPTION = { |
| 79 | 'name' : 'actions', |
| 80 | 'mode' : 'config-switch-flow-entry', |
| 81 | 'short-help' : 'Set actions for this flow', |
| 82 | 'doc' : 'flow-entry|actions', |
| 83 | 'doc-example' : 'flow-entry|actions-example', |
| 84 | 'command-type' : 'config', |
| 85 | 'args' : ( |
| 86 | { |
| 87 | 'field' : 'actions', |
| 88 | 'type' : 'string', |
| 89 | 'completion' : 'complete-staticflow-actions', |
| 90 | 'doc' : 'flow-entry|action-field', |
| 91 | } |
| 92 | ) |
| 93 | } |
| 94 | |
| 95 | |
| 96 | # obj_type flow-entry field active |
| 97 | FLOW_ENTRY_EDIT_ACTIVE_COMMAND_DESCRIPTION = { |
| 98 | 'name' : 'active', |
| 99 | 'mode' : 'config-switch-flow-entry', |
| 100 | 'short-help' : 'Set flow active', |
| 101 | 'doc' : 'flow-entry|active', |
| 102 | 'doc-example' : 'flow-entry|active-example', |
| 103 | 'command-type' : 'config', |
| 104 | 'args' : ( |
| 105 | { |
| 106 | # this should be improved, but this is the old syntax |
| 107 | 'field' : 'active', |
| 108 | 'type' : 'enum', |
| 109 | 'values' : ('True', 'False'), |
| 110 | 'doc' : 'flow-entry|active-field-+', |
| 111 | # XXX roth -- does not show up in wiki |
| 112 | } |
| 113 | ) |
| 114 | } |
| 115 | |
| 116 | |
| 117 | # obj_type flow-entry field priority |
| 118 | FLOW_ENTRY_EDIT_PRIORITY_COMMAND_DESCRIPTION = { |
| 119 | 'name' : 'priority', |
| 120 | 'mode' : 'config-switch-flow-entry', |
| 121 | 'short-help' : 'Set priority of the flow', |
| 122 | 'doc' : 'flow-entry|priority', |
| 123 | 'doc-example' : 'flow-entry|priority-example', |
| 124 | 'command-type' : 'config', |
| 125 | 'args' : ( |
| 126 | { |
| 127 | 'field' : 'priority', |
| 128 | 'base-type' : 'integer', |
| 129 | 'range' : (0, 65535), |
| 130 | 'doc' : 'flow-entry|priority-field', |
| 131 | } |
| 132 | ) |
| 133 | } |
| 134 | |
| 135 | |
| 136 | # obj_type flow-entry field cookie |
| 137 | FLOW_ENTRY_EDIT_COOKIE_COMMAND_DESCRIPTION = { |
| 138 | 'name' : 'cookie', |
| 139 | 'mode' : 'config-switch-flow-entry', |
| 140 | 'command-type' : 'config', |
| 141 | 'short-help' : 'Associate cookie for flow', |
| 142 | 'doc' : 'flow-entry|cookie', |
| 143 | 'doc-example' : 'flow-entry|cookie-example', |
| 144 | 'args' : ( |
| 145 | { |
| 146 | 'field' : 'cookie', |
| 147 | 'type' : 'integer', |
| 148 | } |
| 149 | ) |
| 150 | } |
| 151 | |
| 152 | |
| 153 | # obj_type flow-entry field wildcards |
| 154 | FLOW_ENTRY_EDIT_WILDCARDS_COMMAND_DESCRIPTION = { |
| 155 | 'name' : 'wildcards', |
| 156 | 'mode' : 'config-switch-flow-entry', |
| 157 | 'command-type' : 'config', |
| 158 | 'short-help' : 'Configure wildcards for flow', |
| 159 | 'doc' : 'flow-entry|wildcards', |
| 160 | 'doc-example' : 'flow-entry|wildcards-example', |
| 161 | 'args' : ( |
| 162 | { |
| 163 | 'field' : 'wildcards', |
| 164 | 'base-type' : 'integer', |
| 165 | 'range' : (0, 2**32-1), |
| 166 | 'doc' : 'flow-entry|wildcards-field', |
| 167 | } |
| 168 | ) |
| 169 | } |
| 170 | |
| 171 | |
| 172 | # obj_type flow-entry field ingress-port |
| 173 | FLOW_ENTRY_EDIT_INGRESS_PORT_COMMAND_DESCRIPTION = { |
| 174 | 'name' : 'ingress-port', |
| 175 | 'mode' : 'config-switch-flow-entry', |
| 176 | 'command-type' : 'config', |
| 177 | 'short-help' : 'Configure wildcards for flow', |
| 178 | 'doc' : 'flow-entry|ingress-port', |
| 179 | 'doc-example' : 'flow-entry|ingress-port-example', |
| 180 | 'args' : ( |
| 181 | { |
| 182 | 'field' : 'ingress-port', |
| 183 | 'base-type' : 'integer', |
| 184 | 'range' : (0, 2**16-1), # OF V2 uses 2^32 for ports |
| 185 | 'doc' : 'flow-entry|ingress-port-field', |
| 186 | } |
| 187 | ) |
| 188 | } |
| 189 | |
| 190 | |
| 191 | # obj_type flow-entry field src-mac |
| 192 | FLOW_ENTRY_EDIT_SRC_MAC_COMMAND_DESCRIPTION = { |
| 193 | 'name' : 'src-mac', |
| 194 | 'mode' : 'config-switch-flow-entry', |
| 195 | 'command-type' : 'config', |
| 196 | 'short-help' : 'Configure src-mac match for flow', |
| 197 | 'doc' : 'flow-entry|src-mac', |
| 198 | 'doc-example' : 'flow-entry|src-mac-example', |
| 199 | 'obj-type' : 'flow-entry', |
| 200 | 'args' : ( |
| 201 | { |
| 202 | 'field' : 'src-mac', |
| 203 | 'type' : 'host', |
| 204 | 'completion' : 'complete-alias-choice', |
| 205 | 'other' : 'host|mac', |
| 206 | 'data-handler' : 'alias-to-value', |
| 207 | 'doc' : 'flow-entry|src-mac-field', |
| 208 | } |
| 209 | ) |
| 210 | } |
| 211 | |
| 212 | |
| 213 | # obj_type flow-entry field dst-mac |
| 214 | FLOW_ENTRY_EDIT_DST_MAC_COMMAND_DESCRIPTION = { |
| 215 | 'name' : 'dst-mac', |
| 216 | 'mode' : 'config-switch-flow-entry', |
| 217 | 'command-type' : 'config', |
| 218 | 'short-help' : 'Configure dst-mac match for flow', |
| 219 | 'doc' : 'flow-entry|dst-mac', |
| 220 | 'doc-example' : 'flow-entry|dst-mac-example', |
| 221 | 'obj-type' : 'flow-entry', |
| 222 | 'args' : ( |
| 223 | { |
| 224 | 'field' : 'dst-mac', |
| 225 | 'type' : 'host', |
| 226 | 'completion' : 'complete-alias-choice', |
| 227 | 'other' : 'host|mac', |
| 228 | 'data-handler' : 'alias-to-value', |
| 229 | 'doc' : 'flow-entry|dst-mac-field', |
| 230 | } |
| 231 | ) |
| 232 | } |
| 233 | |
| 234 | |
| 235 | # obj_type flow-entry field vlan-id |
| 236 | FLOW_ENTRY_EDIT_VLAN_ID_COMMAND_DESCRIPTION = { |
| 237 | 'name' : 'vlan-id', |
| 238 | 'mode' : 'config-switch-flow-entry', |
| 239 | 'short-help' : 'Configure vlan-id match for flow', |
| 240 | 'doc' : 'flow-entry|vlan-id', |
| 241 | 'doc-example' : 'flow-entry|vlan-id-example', |
| 242 | 'command-type' : 'config', |
| 243 | 'args' : ( |
| 244 | { |
| 245 | 'field' : 'vlan-id', |
| 246 | 'base-type' : 'integer', |
| 247 | 'range' : (0, 2**12-1), |
| 248 | 'doc' : 'flow-entry|vlan-id-field', |
| 249 | } |
| 250 | ) |
| 251 | } |
| 252 | |
| 253 | |
| 254 | # obj_type flow-entry field vlan-priority |
| 255 | FLOW_ENTRY_EDIT_VLAN_PRIORITY_COMMAND_DESCRIPTION = { |
| 256 | 'name' : 'vlan-priority', |
| 257 | 'mode' : 'config-switch-flow-entry', |
| 258 | 'short-help' : 'Configure vlan-priority match for flow', |
| 259 | 'doc' : 'flow-entry|vlan-priority', |
| 260 | 'doc-example' : 'flow-entry|vlan-priority-example', |
| 261 | 'command-type' : 'config', |
| 262 | 'args' : ( |
| 263 | { |
| 264 | 'field' : 'vlan-priority', |
| 265 | 'base-type' : 'integer', |
| 266 | 'range' : (0,7), |
| 267 | 'doc' : 'flow-entry|vlan-priority-field', |
| 268 | } |
| 269 | ) |
| 270 | } |
| 271 | |
| 272 | |
| 273 | # obj_type flow-entry field ether-type |
| 274 | FLOW_ENTRY_EDIT_ETHER_TYPE_COMMAND_DESCRIPTION = { |
| 275 | 'name' : 'ether-type', |
| 276 | 'mode' : 'config-switch-flow-entry', |
| 277 | 'short-help' : 'Configure ether-type match for flow', |
| 278 | 'doc' : 'flow-entry|ether-type', |
| 279 | 'doc-example' : 'flow-entry|ether-type-example', |
| 280 | 'command-type' : 'config', |
| 281 | 'args' : { |
| 282 | 'choices' : ( |
| 283 | { |
| 284 | 'field' : 'ether-type', |
| 285 | 'base-type' : 'hex-or-decimal-integer', |
| 286 | 'range' : (1536,65536), |
| 287 | 'data-handler' : 'hex-to-integer', |
| 288 | 'doc' : 'flow-entry|ether-type-field', |
| 289 | }, |
| 290 | { |
| 291 | 'field' : 'ether-type', |
| 292 | 'type' : 'enum', |
| 293 | 'values' : fmtcnv.ether_type_to_number_dict, |
| 294 | }, |
| 295 | ), |
| 296 | }, |
| 297 | } |
| 298 | |
| 299 | |
| 300 | # obj_type flow-entry field tos-bits |
| 301 | FLOW_ENTRY_EDIT_TOS_BITS_COMMAND_DESCRIPTION = { |
| 302 | 'name' : 'tos-bits', |
| 303 | 'mode' : 'config-switch-flow-entry', |
| 304 | 'short-help' : 'Configure ether-type match for flow', |
| 305 | 'doc' : 'flow-entry|tos-bits', |
| 306 | 'doc-example' : 'flow-entry|tos-bits-example', |
| 307 | 'command-type' : 'config', |
| 308 | 'args' : ( |
| 309 | { |
| 310 | 'field' : 'tos-bits', |
| 311 | 'base-type' : 'integer', |
| 312 | 'range' : (0,63), |
| 313 | 'doc' : 'flow-entry|tos-bits-field', |
| 314 | } |
| 315 | ) |
| 316 | } |
| 317 | |
| 318 | |
| 319 | # obj_type flow-entry field protocol |
| 320 | FLOW_ENTRY_EDIT_PROTOCOL_COMMAND_DESCRIPTION = { |
| 321 | 'name' : 'protocol', |
| 322 | 'mode' : 'config-switch-flow-entry', |
| 323 | 'short-help' : 'Configure ether-type match for flow', |
| 324 | 'doc' : 'flow-entry|protocol', |
| 325 | 'doc-example' : 'flow-entry|protocol-example', |
| 326 | 'command-type' : 'config', |
| 327 | 'args' : ( |
| 328 | { |
| 329 | 'field' : 'protocol', |
| 330 | 'base-type' : 'integer', |
| 331 | 'range' : (0,255), |
| 332 | 'doc' : 'flow-entry|protocol-field', |
| 333 | } |
| 334 | ) |
| 335 | } |
| 336 | |
| 337 | |
| 338 | # obj_type flow-entry field src-ip |
| 339 | FLOW_ENTRY_EDIT_SRC_IP_COMMAND_DESCRIPTION = { |
| 340 | 'name' : 'src-ip', |
| 341 | 'mode' : 'config-switch-flow-entry', |
| 342 | 'short-help' : 'Configure src-ip match for flow', |
| 343 | 'doc' : 'flow-entry|src-ip', |
| 344 | 'doc-example' : 'flow-entry|src-ip-example', |
| 345 | 'command-type' : 'config', |
| 346 | 'args' : { |
| 347 | 'choices' : ( |
| 348 | { |
| 349 | 'field' : 'src-ip', |
| 350 | 'help-name' : 'ip-address', |
| 351 | 'type' : 'ip-address', |
| 352 | 'completion-text' : 'src-ip-address', |
| 353 | 'doc' : 'flow-entry|src-ip-field', |
| 354 | }, |
| 355 | { |
| 356 | 'field' : 'src-ip', |
| 357 | 'help-name' : 'cidr-range', |
| 358 | 'type' : 'cidr-range', |
| 359 | 'completion-text' : 'src-ip-cidr-range', |
| 360 | 'doc' : 'flow-entry|src-ip-field', |
| 361 | }, |
| 362 | ) |
| 363 | }, |
| 364 | } |
| 365 | |
| 366 | |
| 367 | # obj_type flow-entry field dst-ip |
| 368 | FLOW_ENTRY_EDIT_DST_IP_COMMAND_DESCRIPTION = { |
| 369 | 'name' : 'dst-ip', |
| 370 | 'mode' : 'config-switch-flow-entry', |
| 371 | 'short-help' : 'Configure dst-ip match for flow', |
| 372 | 'doc' : 'flow-entry|dst-ip', |
| 373 | 'doc-example' : 'flow-entry|dst-ip-example', |
| 374 | 'command-type' : 'config', |
| 375 | 'args' : { |
| 376 | 'choices' : ( |
| 377 | { |
| 378 | 'field' : 'dst-ip', |
| 379 | 'help-name' : 'ip-address', |
| 380 | 'type' : 'ip-address', |
| 381 | 'completion-text' : 'dst-ip-address', |
| 382 | 'doc' : 'flow-entry|dst-ip-field', |
| 383 | }, |
| 384 | { |
| 385 | 'field' : 'dst-ip', |
| 386 | 'help-name' : 'cidr-range', |
| 387 | 'type' : 'cidr-range', |
| 388 | 'completion-text' : 'dst-ip-cidr-range', |
| 389 | 'doc' : 'flow-entry|dst-ip-field', |
| 390 | }, |
| 391 | ) |
| 392 | }, |
| 393 | } |
| 394 | |
| 395 | |
| 396 | # obj_type flow-entry field src-port |
| 397 | FLOW_ENTRY_EDIT_SRC_PORT_COMMAND_DESCRIPTION = { |
| 398 | 'name' : 'src-port', |
| 399 | 'mode' : 'config-switch-flow-entry', |
| 400 | 'short-help' : 'Configure src-port match for flow', |
| 401 | 'doc' : 'flow-entry|src-port', |
| 402 | 'doc-example' : 'flow-entry|src-port-example', |
| 403 | 'command-type' : 'config', |
| 404 | 'args' : { |
| 405 | 'choices' : ( |
| 406 | { |
| 407 | 'field' : 'src-port', |
| 408 | 'base-type' : 'hex-or-decimal-integer', |
| 409 | 'range' : (0,65535), |
| 410 | 'data-handler' : 'hex-to-integer', |
| 411 | 'doc' : 'flow-entry|src-port-field', |
| 412 | }, |
| 413 | { |
| 414 | 'field' : 'src-port', |
| 415 | 'type' : 'enum', |
| 416 | 'values' : fmtcnv.tcp_name_to_number_dict, |
| 417 | }, |
| 418 | ) |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | |
| 423 | # obj_type flow-entry field dst-port |
| 424 | FLOW_ENTRY_EDIT_DST_PORT_COMMAND_DESCRIPTION = { |
| 425 | 'name' : 'dst-port', |
| 426 | 'mode' : 'config-switch-flow-entry', |
| 427 | 'short-help' : 'Configure dst-port match for flow', |
| 428 | 'doc' : 'flow-entry|dst-port', |
| 429 | 'doc-example' : 'flow-entry|dst-port-example', |
| 430 | 'command-type' : 'config', |
| 431 | 'args' : { |
| 432 | 'choices' : ( |
| 433 | { |
| 434 | 'field' : 'dst-port', |
| 435 | 'base-type' : 'hex-or-decimal-integer', |
| 436 | 'range' : (0,65535), |
| 437 | 'data-handler' : 'hex-to-integer', |
| 438 | 'doc' : 'flow-entry|dst-port-field', |
| 439 | }, |
| 440 | { |
| 441 | 'field' : 'dst-port', |
| 442 | 'type' : 'enum', |
| 443 | 'values' : fmtcnv.tcp_name_to_number_dict, |
| 444 | }, |
| 445 | ) |
| 446 | }, |
| 447 | } |
| 448 | # |
| 449 | # FORMATS |
| 450 | # |
| 451 | |
| 452 | import fmtcnv |
| 453 | |
| 454 | |
| 455 | FLOW_ENTRY_FORMAT = { |
| 456 | 'flow-entry' : { |
| 457 | 'field-orderings' : { |
| 458 | 'default' : [ 'Idx', |
| 459 | 'switch', |
| 460 | 'name', |
| 461 | 'active', |
| 462 | 'idle-timeout', |
| 463 | 'hard-timeout', |
| 464 | 'cookie', |
| 465 | 'priority', |
| 466 | 'wildcards', |
| 467 | 'ingress-port', |
| 468 | 'src-mac', |
| 469 | 'dst-mac', |
| 470 | 'ether-type', |
| 471 | 'vlan-id', |
| 472 | 'vlan-priority', |
| 473 | 'src-ip', |
| 474 | 'dst-ip', |
| 475 | 'protocol', |
| 476 | 'tos-bits', |
| 477 | 'src-port', |
| 478 | 'dst-port', |
| 479 | 'actions', |
| 480 | ] |
| 481 | }, |
| 482 | 'fields' : { |
| 483 | 'switch' : { 'formatter' : fmtcnv.replace_switch_with_alias }, |
| 484 | 'ether-type' : { 'formatter' : fmtcnv.decode_ether_type }, |
| 485 | 'protocol' : { 'formatter' : fmtcnv.decode_network_protocol }, |
| 486 | 'src-port' : { 'formatter' : fmtcnv.decode_src_port }, |
| 487 | 'dst-port' : { 'formatter' : fmtcnv.decode_dst_port }, |
| 488 | 'ingress-port' : { 'formatter' : fmtcnv.decode_openflow_port }, |
| 489 | }, |
| 490 | }, |
| 491 | } |
| 492 | """ |
| 493 | |