예제 #1
0
def bcli_help_types():
    '''Show help for type/vars used in CLI commands.
    '''
    types = boscli.get_cli().get_type_names()
    types.sort()
    for t in types:
        print "%s => %s" % (t, boscli.get_cli().get_type(t).help())
예제 #2
0
def bcli_cli_pager_STATE(state):
    """Activate or Deactivate the command output pager.
    """
    if state in ['on', 'up']:
        boscli.get_cli().pager_on()
    else:
        boscli.get_cli().pager_off()
def bcli_exit():
    """Exit from configure mode or from CLI (if we are at NORMAL mode).
    """
    if boscli.boscli.get_cli().get_mode() == boscli.privileges.NORMAL:
        boscli.get_cli().quit()
    else:
        print "Exit from actual mode..."
        boscli.get_cli().change_mode(boscli.privileges.NORMAL)
예제 #4
0
def bcli_alias_remove_ALIAS(alias_name):
    """Remove the asigned value for an alias.
    """
    alias = '@' + alias_name
    if alias not in boscli.get_cli().get_alias().keys():
        print "%s not defined" % (alias)
    else:    
        boscli.get_cli().remove_alias(alias)
        print "%s removed" % (alias)
예제 #5
0
def bcli_help_show_allcommands():
    """Show a list of all available commands (only for active mode).
    """
    cmd_list = []
    for cmd in boscli.get_cli().get_active_functions():
        cmd_list.append(boscli.get_cli().get_normalize_func_name(cmd))
    cmd_list.sort()
    for cmd in cmd_list:
        print cmd
예제 #6
0
def bcli_help_show_allcommands_full():
    """Show basic help for all availables commands (only for active mode).
    """
    cmd_list = []
    for cmd in boscli.get_cli().get_active_functions():
        str = ''
        str = str + boscli.get_cli().get_normalize_func_name(cmd)
        str = str + " => " + boscli.helpers.get_function_help(cmd).split('\n')[0]
        cmd_list.append(str)
    cmd_list.sort()
    for cmd in cmd_list: print cmd
예제 #7
0
def bcli_cli_pager():
    """Show if the pager is active or not.
    """
    if boscli.get_cli().pager() == True:
        print "Pager status: ON"
    else:
        print "Pager status: OFF"
예제 #8
0
def get_function_help(function):
    '''Return all the doc of a function.
If the function have no doc, it returns "Not documented yet"
'''
    f = boscli.get_cli().get_function(function)
    doc = f.__doc__
    if doc == None:
        doc = "Not documented yet\n"
    return doc    
예제 #9
0
def bcli_alias_define_STRING_STRING(alias_name, alias_value):
    """Define/Overwrite an alias.
    Set the value of the alias to the string especified as second argument. 
    """
    boscli.get_cli().add_alias('@' + alias_name, alias_value)
    print "%s => %s" % ('@' + alias_name, alias_value)
예제 #10
0
# Licensed under GPL v3 or later, see COPYING for the whole text

'''
  $Id:$
  $URL:$
  Alea-Soluciones (Bifer) (c) 2007
  Created: eferro - 7/8/2007
'''



import boscli
import boscli.bostypes
import boscli.privileges

boscli.get_cli().set_privilege(boscli.privileges.MANUF, boscli.privileges.NORMAL, 'bcli_cli_exec_FILE')
boscli.get_cli().set_privilege(boscli.privileges.MANUF, boscli.privileges.NORMAL, 'bcli_cli_reload')

class BiferShellAliasType(boscli.bostypes.BiferShellType):
    def __init__(self): 
        boscli.bostypes.BiferShellType.__init__(self)
    def values(self, incomplete_word):
        alias = []
        for a in boscli.get_cli().get_alias().keys():
            alias.append(a[1:])
        return alias

boscli.get_cli().add_type('ALIAS', BiferShellAliasType())


def bcli_cli():
예제 #11
0
def get_basic_help(cmd):
    str = ""
    for func in get_functions(cmd):
        str = str + boscli.get_cli().get_normalize_func_name(func)
        str = str + " => " + boscli.helpers.get_function_help(func).split('\n')[0] + '\n'
    return str
def bcli_privilege_initial_manufacturer():
    """Set manufacturer level as initial privilege level for actual user
    """
    boscli.get_cli().change_initial_privilege(boscli.privileges.MANUF)
    print "Inital user privileges change to: 2 [manufacturer level]"
예제 #13
0
def bcli_help_basic():
    '''Show basic help. Same as '?<tab>' at command lines
    '''
    boscli.get_cli().basic_help()
def bcli_passwd_priv_enable():
    """Change configure enable privilege level password.
    """
    boscli.get_cli().change_priv_passwd(boscli.privileges.ENABLE)
예제 #15
0
def bcli_cli_reload():
    """Reload all the functions registered at CLI.
    Only for internal use.
    """
    print "Reloading extensions"
    boscli.get_cli().init_commands()
예제 #16
0
def bcli_cli_exec_FILE(file):
    """Execute a BosCli file.
    """
    boscli.get_cli().exec_cmds_file(file)
예제 #17
0
def get_active_cmds():
    '''Return the command enable in the actual mode'''
    functions = boscli.get_cli().get_active_functions()
    return sorted(list(set([a[0] for a in functions])))
예제 #18
0
def get_cmds():
    '''Return the command suported in the system. We consider a command (or
    a command family) the first word of a function'''
    functions = boscli.get_cli().get_functions()
    return sorted(list(set([a[0] for a in functions])))
예제 #19
0
def get_extended_help(cmd):
    str = ""
    for func in get_functions(cmd):
        str = str + boscli.get_cli().get_normalize_func_name(func)
        str = str + " => " + boscli.helpers.get_function_help(func) + '\n'
    return str
def bcli_passwd_priv_manufacturer():
    """Change configure manufacturer privilege level password.
    """
    boscli.get_cli().change_priv_passwd(boscli.privileges.MANUF)
def bcli_privilege_initial_enable():
    """Set enable level as initial privilege level for actual user
    """
    boscli.get_cli().change_initial_privilege(boscli.privileges.ENABLE)
    print "Inital user privileges change to: 1 [enable level]"
def bcli_normal():
    """Change mode to normal
    """
    boscli.get_cli().change_mode(boscli.privileges.NORMAL)
예제 #23
0
 def values(self, incomplete_word):
     alias = []
     for a in boscli.get_cli().get_alias().keys():
         alias.append(a[1:])
     return alias
def bcli_privilege_initial_normal():
    """Set normal level as initial privilege level for actual user
    """
    boscli.get_cli().change_initial_privilege(boscli.privileges.NONE)
    print "Inital user privileges change to: 0 [normal level]"
예제 #25
0
def get_functions(cmd):
    '''Return all the enabled functions that correspond to the comand indicated'''
    matchs = [a for a in boscli.get_cli().get_active_functions() if a[0] == cmd]
    return matchs
def bcli_passwd_configuremode():
    """Change configure mode access password.
    """
    boscli.get_cli().change_mode_passwd(boscli.privileges.CONFIGURE)
예제 #27
0
def bcli_cli_quit():
    """Exit from BosCli.
    """
    boscli.get_cli().quit()
예제 #28
0
def bcli_help():
    """Commands for interactive help.
    """
    boscli.get_cli().basic_help()
예제 #29
0
def bcli_alias_list():
    """Show defined aliases and the corresponding values.
    """
    alias = boscli.get_cli().get_alias()
    for alias_name in alias.keys():
        print "%s => %s" % (alias_name, alias[alias_name])
def bcli_configure():
    """Change mode to configuremode
    """
    boscli.get_cli().change_mode(boscli.privileges.CONFIGURE)