def implement_show_running_config(context, data): """ Manager for the 'show running-config' command, which calls the specific detail functions for any of the parameters. """ # use the bigdb scoreboard to collect the running-config. global rc_scoreboard rc_scoreboard = BigDB_RC_scoreboard() context.rc_scoreboard = rc_scoreboard if len(data): # pick the word word = data['running-config'] choice = utif.full_word_from_choices(word, registry_items_enabled(context)) if choice: perform_running_config(choice, context, rc_scoreboard, data) else: yield context.error_msg("unknown running-config item: %s" % word) return # config[:-1] removes the last trailing newline # display any erros associated with the generation of the running config for item in rc_scoreboard.generate_errors(): print 'Warning; \n' + item yield '!\n' yield '! Warning: \n' + item else: # Create the order based on the registration value running_config_order = sorted( registry_items_enabled(context), key=lambda item: running_config_registry[item]['order']) # Since the scoreboard defines the ouutput order, the # running-config generators can be run in any order. for rc in running_config_order: perform_running_config(rc, context, rc_scoreboard, data) # display any erros associated with the generation of the running config for item in rc_scoreboard.generate_errors(): print 'Warning: \n' + item yield '!\n' yield '! Warning: \n' + item yield "!\n" yield "! %s" % 'NEED VERSION STRING\n' # context.do_show_version yield "! Current Time: %s\n" % \ datetime.datetime.now().strftime("%Y-%m-%d.%H:%M:%S %Z") yield "!\n" yield "version 1.0\n" # need a better determination of command syntax version for item in rc_scoreboard.generate(): yield item rc_scoreboard = None context.rc_scoreboard = None
def implement_show_running_config(context, data): """ Manager for the 'show running-config' command, which calls the specific detail functions for any of the parameters. """ # use the bigdb scoreboard to collect the running-config. global rc_scoreboard rc_scoreboard = BigDB_RC_scoreboard() context.rc_scoreboard = rc_scoreboard if len(data): # pick the word word = data['running-config'] choice = utif.full_word_from_choices(word, registry_items_enabled(context)) if choice: perform_running_config(choice, context, rc_scoreboard, data) else: yield context.error_msg("unknown running-config item: %s" % word) return # config[:-1] removes the last trailing newline # display any erros associated with the generation of the running config for item in rc_scoreboard.generate_errors(): print 'Warning; \n' + item yield '!\n' yield '! Warning: \n' + item else: # Create the order based on the registration value running_config_order = sorted(registry_items_enabled(context), key=lambda item: running_config_registry[item]['order']) # Since the scoreboard defines the ouutput order, the # running-config generators can be run in any order. for rc in running_config_order: perform_running_config(rc, context, rc_scoreboard, data) # display any erros associated with the generation of the running config for item in rc_scoreboard.generate_errors(): print 'Warning: \n' + item yield '!\n' yield '! Warning: \n' + item yield "!\n" yield "! %s" % 'NEED VERSION STRING\n' # context.do_show_version yield "! Current Time: %s\n" % \ datetime.datetime.now().strftime("%Y-%m-%d.%H:%M:%S %Z") yield "!\n" yield "version 1.0\n" # need a better determination of command syntax version for item in rc_scoreboard.generate(): yield item rc_scoreboard = None context.rc_scoreboard = None
def validate_config(typedef, value): if value.startswith('config://'): return value elif utif.full_word_from_choices( value, ['running-config', 'upgrade-config', 'trash']): return value else: for prefixes in ['http://', 'ftp://', 'tftp://', 'file://']: if value.startswith(prefixes): return value data = sdnsh.store.get_user_data_table(value, 'latest') if len(data): return value msg = 'not a valid copy, must be (running-config, upgrade-config ' \ 'or must start with config://, http://, ftp://, or tftp://' command._raise_argument_validation_exception(typedef, value, msg)
def implement_show_running_config(words): """ Manager for the 'show running-config' command, which calls the specific detail functions for any of the parameters. """ # LOOK! hardwired - need to use the obj_type_info and the field_list # LOOK! how are these sorted? config = [] if len(words) > 0: # pick the word choice = utif.full_word_from_choices(words[0], registry_items_enabled()) if sdnsh.netvirt_feature_enabled() and 'vns'.startswith(words[0]): if choice: return sdnsh.error_msg("%s and %s ambiguous" % (choice, 'vns')) choice = 'vns' if choice: perform_running_config(choice, sdnsh, config, words) else: return sdnsh.error_msg("unknown running-config item: %s" % words[0]) # config[:-1] removes the last trailing newline return ''.join(config)[:-1] else: # Create the order based on the registration value running_config_order = sorted(registry_items_enabled(), key=lambda item: running_config_registry[item]['order']) exclude_list=['vns'] for rc in running_config_order: if rc not in exclude_list: perform_running_config(rc, sdnsh, config, words) prefix = [] if len(config) > 0: date_string = datetime.datetime.now().strftime("%Y-%m-%d.%H:%M:%S %Z") prefix.append("!\n! ") prefix.append(sdnsh.do_show_version(words)) prefix.append("\n! Current Time: ") prefix.append(date_string) prefix.append("\n!\n") prefix.append("version 1.0\n") # need a better determination of command syntax version # config[:-1] removes the last trailing newline return ''.join(prefix) + ''.join(config)[:-1]
def validate_config(typedef, value): if value.startswith('config://'): return value elif utif.full_word_from_choices(value, ['running-config', 'upgrade-config', 'trash' ]): return value else: for prefixes in ['http://', 'ftp://', 'tftp://', 'file://']: if value.startswith(prefixes): return value data = sdnsh.store.get_user_data_table(value, 'latest') if len(data): return value msg = 'not a valid copy, must be (running-config, upgrade-config ' \ 'or must start with config://, http://, ftp://, or tftp://' command._raise_argument_validation_exception(typedef, value, msg)