Srikanth Vavilapalli | 1725e49 | 2014-12-01 17:50:52 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright (c) 2013 Big Switch Networks, Inc. |
| 4 | # |
| 5 | # Licensed under the Eclipse Public License, Version 1.0 (the |
| 6 | # "License"); you may not use this file except in compliance with the |
| 7 | # License. You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.eclipse.org/legal/epl-v10.html |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 | # implied. See the License for the specific language governing |
| 15 | # permissions and limitations under the License. |
| 16 | # |
| 17 | |
| 18 | # CLI for forwarding configuration |
| 19 | # |
| 20 | |
| 21 | # -------------------------------------------------------------------------------- |
| 22 | # Update running config |
| 23 | # |
| 24 | |
| 25 | import run_config |
| 26 | def running_config_forwarding(context, config, words): |
| 27 | t_obj_type = 'forwarding-config' |
| 28 | |
| 29 | forwarding_table = context.get_table_from_store(t_obj_type) |
| 30 | if len(forwarding_table) > 1: |
| 31 | print 'running_config_forwarding: more than one forwarding record' |
| 32 | if len(forwarding_table) == 0: |
| 33 | return |
| 34 | |
| 35 | forwarding_config = forwarding_table[0] |
| 36 | newline_printed = False |
| 37 | if run_config.not_default_value( |
| 38 | t_obj_type, 'access-priority', |
| 39 | forwarding_config.get('access-priority')): |
| 40 | if newline_printed is False: |
| 41 | newline_printed = True |
| 42 | config.append("!\n") |
| 43 | config.append( |
| 44 | 'forwarding access-priority %s\n' % |
| 45 | forwarding_config.get('access-priority')) |
| 46 | if run_config.not_default_value( |
| 47 | t_obj_type, 'core-priority', |
| 48 | forwarding_config.get('core-priority')): |
| 49 | if newline_printed is False: |
| 50 | newline_printed = True |
| 51 | config.append("!\n") |
| 52 | config.append( |
| 53 | 'forwarding core-priority %s\n' % |
| 54 | forwarding_config.get('core-priority')) |
| 55 | |
| 56 | forwarding_running_config_tuple = ( |
| 57 | ( |
| 58 | { |
| 59 | 'optional' : False, |
| 60 | 'field' : 'running-config', |
| 61 | 'type' : 'enum', |
| 62 | 'values' : 'forwarding', |
| 63 | 'short-help' : 'Forwarding Configuration', |
| 64 | 'doc' : 'running-config|forwarding-show', |
| 65 | }, |
| 66 | ), |
| 67 | ) |
| 68 | run_config.register_running_config('forwarding', 2200, None, |
| 69 | running_config_forwarding, |
| 70 | forwarding_running_config_tuple) |
| 71 | |
| 72 | # -------------------------------------------------------------------------------- |