Ejemplo n.º 1
0
def clear(argv):
    """Print all help messages for commands that take the "clear" modifier
        syntax: clear help
    """
    output = lib.output.CLIoutput("help")
    output.setVirtualNameValue("Help", _CLEAR_HELP_TEXT)
    output.completeOutputSuccess()
    return output
Ejemplo n.º 2
0
def _gen_timezones(output, timezones):
    output.beginList(_XMLTAG_TimeZoneList)
    for x in timezones:
        output.setVirtualNameValue(_XMLTAG_TimeZone, x)
    output.endList(_XMLTAG_TimeZoneList)

    output.completeOutputSuccess()
    return output
Ejemplo n.º 3
0
def add(argv):
    """Print all help messages for commands that take the "add" modifier
        syntax: add help
    """
    output = lib.output.CLIoutput("help")
    output.setVirtualNameValue("Help", _ADD_HELP_TEXT)
    output.completeOutputSuccess()
    return output
Ejemplo n.º 4
0
def _gen_timezones(output, timezones):
    output.beginList(_XMLTAG_TimeZoneList)
    for x in timezones:
        output.setVirtualNameValue(_XMLTAG_TimeZone, x)
    output.endList(_XMLTAG_TimeZoneList)
    
    output.completeOutputSuccess()
    return output
Ejemplo n.º 5
0
Archivo: ip.py Proyecto: rajat007/vfm
def _ip_address_spec(output, ipaddress, netmask, interface, scope, active):
    """Output an IPaddressSpec in XML form"""
    output.beginAssembling("IPaddressSpec")
    output.setVirtualNameValue("IPaddress", ipaddress)
    output.setVirtualNameValue("IPnetmask", netmask)
    output.setVirtualNameValue("InterfaceName", interface)
    output.setVirtualNameValue("Active", scope)
    output.setVirtualNameValue("Scope", active)
    output.endAssembling("IPaddressSpec")
Ejemplo n.º 6
0
Archivo: ip.py Proyecto: gautamrege/vfm
def _ip_address_spec(output, ipaddress, netmask, interface, scope, active ):
    """Output an IPaddressSpec in XML form"""
    output.beginAssembling("IPaddressSpec")
    output.setVirtualNameValue("IPaddress", ipaddress)
    output.setVirtualNameValue("IPnetmask", netmask)
    output.setVirtualNameValue("InterfaceName", interface)
    output.setVirtualNameValue("Active", scope)
    output.setVirtualNameValue("Scope", active)
    output.endAssembling("IPaddressSpec")
Ejemplo n.º 7
0
Archivo: arp.py Proyecto: rajat007/vfm
def show(argv):
    """Show the contents of the ARP cache
        syntax: show arp
    """
    output = lib.output.CLIoutput("arp", _output_handlers)
    if len(argv) != 1:
        output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__))
        return output

    arp_entries = open("/proc/net/arp", 'r').readlines()
    output.beginList("ARPentryList")
    for line in arp_entries[1:]:  # skip header
        fields = line.split()
        output.beginAssembling("ARPentry")
        output.setVirtualNameValue("IPaddress", fields[0])
        if int(fields[2], 16) == 0:
            output.setVirtualNameValue("HWaddress", "(unresolved)")
        else:
            output.setVirtualNameValue("HWaddress", fields[3])
        output.setVirtualNameValue("InterfaceName", fields[5])
        output.endAssembling("ARPentry")

    output.endList("ARPentryList")
    output.completeOutputSuccess()
    #print output
    return output
Ejemplo n.º 8
0
def show(argv):
    """Show the contents of the ARP cache
        syntax: show arp
    """
    output = lib.output.CLIoutput("arp", _output_handlers)
    if len(argv) != 1:
        output.completeOutputError(InvalidArgumentCount (syntax = show.__doc__))
        return output

    arp_entries = open("/proc/net/arp", 'r').readlines()
    output.beginList("ARPentryList")
    for line in arp_entries[1:]:           # skip header
        fields = line.split()
        output.beginAssembling("ARPentry")
        output.setVirtualNameValue("IPaddress", fields[0])
        if int(fields[2], 16) == 0:
            output.setVirtualNameValue("HWaddress", "(unresolved)")
        else:
            output.setVirtualNameValue("HWaddress", fields[3])
        output.setVirtualNameValue("InterfaceName", fields[5])
        output.endAssembling("ARPentry")

    output.endList("ARPentryList")
    output.completeOutputSuccess()
    #print output
    return output
Ejemplo n.º 9
0
def show(argv):
    """Get the hostname
        syntax: show hostname
   """ 
    output = lib.output.CLIoutput("hostname")
    if len(argv) > 1:
        output.completeOutputError(InvalidArgumentCount (syntax=show.__doc__))
        return output
    # Get hostname from the system.
    hostname = getSystemHostname()
    #print hostname
    if hostname is None:
        output.completeOutputError("unable to determine current hostname")
        return output
    output.beginAssembling("hostname")
    output.setVirtualNameValue("hostname",hostname)
    output.endAssembling("hostname")
    output.completeOutputSuccess()
    return output
Ejemplo n.º 10
0
Archivo: ip.py Proyecto: gautamrege/vfm
def _show_ip_routes(output, argv):
    """Show network routes
        syntax: show ip route
    """
    cmd = [_ROUTE, '-n']
    (exitval, output_result, err, fullstatus) = lib.process.execute_command(cmd)
    
    output.beginList("IProuteList")
    for ln in output_result[2:]:        
        fields = ln.split()
        if fields[-1] == "lo":
            continue
        output.beginAssembling("IProute")
        output.setVirtualNameValue("Destination", fields[0])
        output.setVirtualNameValue("IPnetmask", fields[2])
        output.setVirtualNameValue("Gateway", fields[1])
        output.setVirtualNameValue("InterfaceName", fields[-1])
        output.endAssembling("IProute")
    output.endList("IProuteList")
Ejemplo n.º 11
0
Archivo: ip.py Proyecto: rajat007/vfm
def _show_ip_routes(output, argv):
    """Show network routes
        syntax: show ip route
    """
    cmd = [_ROUTE, '-n']
    (exitval, output_result, err,
     fullstatus) = lib.process.execute_command(cmd)

    output.beginList("IProuteList")
    for ln in output_result[2:]:
        fields = ln.split()
        if fields[-1] == "lo":
            continue
        output.beginAssembling("IProute")
        output.setVirtualNameValue("Destination", fields[0])
        output.setVirtualNameValue("IPnetmask", fields[2])
        output.setVirtualNameValue("Gateway", fields[1])
        output.setVirtualNameValue("InterfaceName", fields[-1])
        output.endAssembling("IProute")
    output.endList("IProuteList")
Ejemplo n.º 12
0
def edit(argv):
    """Print help messages
        syntax: help
                help commands
                help <command-category>
                help <modifier>
                help [<modifier>] <command-name>
        modifier: add | clear | edit | no | show
    """
    output = lib.output.CLIoutput("help")
    if len(argv) == 1:
        # No argument - print out the general help
        output.setVirtualNameValue("Help", _GENERAL_HELP)
        output.completeOutputSuccess()
        return output

    # Now the arguments can be a category or a modifier or a command
    # Try treat it as a category first
    if len(argv) == 2:
        category = argv[1]
        try:
            output.setVirtualNameValue("Help", _display_help_category(category))
            output.completeOutputSuccess()
            return output
        except KeyError:
            # Not a category. Fine.
            pass

    # Maybe it's a modifier or a plugin... Get the plugin.
    try:
        try:
            modifier, cmd, plugin_name = \
                      lib.command_ref.cmdToPlugin(argv[1:])
        except lib.command_ref.UnknownPluginException, ex:
            modifier = ex.getModifier()
            # No plugin because the user wants help on a modifier ("help no")?
            # If the exception doesn't have any command, that means the user
            # only entered a modifier.
            if not ex.getCommand():
                output.setVirtualNameValue('Help', _display_modifier_help(modifier))
                output.completeOutputSuccess()
                return output
            raise ex

        if not sys.modules.has_key(plugin_name):
            try:
                __import__(plugin_name)
            except ImportError:
                raise NameError("INTERNAL ERROR: no such plugin: " + \
                                plugin_name)

        module = sys.modules[plugin_name]
        doc_str = None
        if hasattr(module, modifier):
            function = getattr(module, modifier)
            doc_str = getattr(function, '__doc__', None)

        if doc_str is None and modifier == lib.command_ref.EDIT_MODIFIER:
            doc_str = module.__doc__
        if doc_str is not None:
            output.setVirtualNameValue('Help', doc_str)
            output.completeOutputSuccess()
            return output
Ejemplo n.º 13
0
def iomodule_spec(output, id , name , type, mac, guid, num_vhba, num_vnic, slot, port,support_speed):
    output.beginAssembling("IomoduleListAll")
    output.setVirtualNameValue("ID", id)
    output.setVirtualNameValue("NAME", name)
    output.setVirtualNameValue("TYPE", type)
    output.setVirtualNameValue("MAC", mac)
    output.setVirtualNameValue("GUID", guid)
    output.setVirtualNameValue("NUM_VHBA", num_vhba)
    output.setVirtualNameValue("NUM_VNIC", num_vnic)
    output.setVirtualNameValue("SLOT", slot)
    output.setVirtualNameValue("PORT", port)
    output.setVirtualNameValue("SUPPORT_SPEED", support_speed)
    output.endAssembling("IomoduleListAll")  
Ejemplo n.º 14
0
def _bridge_spec(output, guid, name, desc, num_gateway_module,
                 firmware_version, bxm_guid):
    """Outout the bridge spec """
    output.beginAssembling("Bridge_Device")
    output.setVirtualNameValue("GUID", guid)
    output.setVirtualNameValue("NAME", name)
    output.setVirtualNameValue("DESCRIPTION", desc)
    output.setVirtualNameValue("NUM_GW_MODULE", num_gateway_module)
    output.setVirtualNameValue("FIRMWARE_VERSION", firmware_version)
    output.setVirtualNameValue("BXM_GUID", bxm_guid)
    output.endAssembling("Bridge_Device")
Ejemplo n.º 15
0
def _bridge_detail(output, name, desc, running_mode, firmware_module, vfm_guid,
                   no_gw_modules, gw_module_index, gw_module_id, int_protocol,
                   ext_protocol, no_int_protocol, no_ext_protocol, int_ports,
                   ext_ports, gw_ids, port_id, phy_index, type, protocol,
                   state, mac, wwnn, wwpn, fcid, ib_guid, lid, qpn, sl,
                   support_speed, actual_speed, rx_stat, tx_stat,
                   last_keep_alive):
    output.beginAssembling("Bridge_Device")
    output.setVirtualNameValue("name", name)
    output.setVirtualNameValue("desc", desc)
    output.setVirtualNameValue("state", state)
    output.setVirtualNameValue("running-mode", running_mode)
    output.setVirtualNameValue("firmware-module", firmware_module)
    output.setVirtualNameValue("vfm-guid", vfm_guid)
    output.setVirtualNameValue("number-gw-module", no_gw_module)
    output.setVirtualNameValue("gw-module-index", gw_module_index)
    output.setVirtualNameValue("gw-module-id", gw_module_id)
    output.setVirtualNameValue("int_protocol", int_protocol)
    output.setVirtualNameValue("ext_protocol", ext_protocol)
    output.setVirtualNameValue("no_int_protocols", no_int_protocol)
    output.setVirtualNameValue("no_ext_protocols", no_ext_protocol)
    output.setVirtualNameValue("int-ports", int_ports)
    output.setVirtualNameValue("ext-ports", ext_ports)
    output.setVirtualNameValue("gw-ids", gw_ids)
    output.setVirtualNameValue("port-id", port_id)
    output.setVirtualNameValue("phy-index", phy_index)
    output.setVirtualNameValue("type", type)
    output.setVirtualNameValue("protocol", protocol)
    output.setVirtualNameValue("state", state)
    output.setVirtualNameValue("mac", mac)
    output.setVirtualNameValue("wwnn", wwnn)
    output.setVirtualNameValue("wwpn", wwpn)
    output.setVirtualNameValue("fcid", fcid)
    output.setVirtualNameValue("ib_guid", ib_guid)
    output.setVirtualNameValue("lid", lid)
    output.setVirtualNameValue("qpn", qpn)
    output.setVirtualNameValue("sl", sl)
    output.setVirtualNameValue("support-speed", support_speed)
    output.setVirtualNameValue("actual-speed", actual_speed)
    output.setVirtualNameValue("rx-stat", rx_stat)
    output.setVirtualNameValue("tx-stat", tx_stat)
    output.setVirtualNameValue("last-keep-alive", last_keep_alive)
    output.endAssembling("Bridge_Device")
Ejemplo n.º 16
0
def _bridge_select(output, desc, state, running_mode , 
		  firmware_module , vfm_guid, no_gw_module, 
		  gw_module_index, last_keep_alive):
    """Output of the show bridge """
    output.beginAssembling("Bridge_Device")
    output.setVirtualNameValue("desc", desc)
    output.setVirtualNameValue("state",state)
    output.setVirtualNameValue("running-mode", running_mode)
    output.setVirtualNameValue("firmware-version",firmware_module)
    output.setVirtualNameValue("vfm-guid",vfm_guid)
    output.setVirtualNameValue("number-gw-module",no_gw_module)
    output.setVirtualNameValue("gw-Module-Index",gw_module_index)
    output.setVirtualNameValue("last-keep-alive",last_keep_alive)
    output.endAssembling("Bridge_Device")
Ejemplo n.º 17
0
def _bridge_spec(output, guid, name, desc, num_gateway_module, firmware_version, bxm_guid):
    """Outout the bridge spec """
    output.beginAssembling("Bridge_Device")
    output.setVirtualNameValue("GUID", guid)
    output.setVirtualNameValue("NAME", name)
    output.setVirtualNameValue("DESCRIPTION", desc)
    output.setVirtualNameValue("NUM_GW_MODULE", num_gateway_module)
    output.setVirtualNameValue("FIRMWARE_VERSION", firmware_version)
    output.setVirtualNameValue("BXM_GUID", bxm_guid)
    output.endAssembling("Bridge_Device")
Ejemplo n.º 18
0
def _vadapter_spec(output, id, value):    

    output.beginAssembling("VadapterListAll")

    output.setVirtualNameValue("ID", id)
    output.setVirtualNameValue("NAME", value['name'])
    output.setVirtualNameValue("IO_MODULE_ID", value['io_module_id'])
    output.setVirtualNameValue("VFABRIC", value['vfabric_id'])
    output.setVirtualNameValue("PROTOCOL", value['protocol'])
    output.setVirtualNameValue("INIT_TYPE", value['init_type'])
    output.setVirtualNameValue("DESC", value['desc'])

    # When we get transient states, the state will automatically get udpated.
    # By default, it is RUNNING
    output.setVirtualNameValue("STATUS", value.get('status', 'RUNNING'))
    output.setVirtualNameValue("RUNNING_MODE", value.get('running_mode', 'OFFLINE'))


    if value['protocol'] == 1:
        output.setVirtualNameValue("MAC", value['en_attr']['mac'])
        output.setVirtualNameValue("PROMISCUOUS", value['en_attr']['promiscuous_mode'])
        output.setVirtualNameValue("SILENT", value['en_attr']['silent_listener'])
        output.setVirtualNameValue("VLAN", value['en_attr']['vlan'])
    
    elif value['protocol'] == 3:
        output.setVirtualNameValue("WWNN", value['fc_attr']['wwnn'])
        output.setVirtualNameValue("WWPN", value['fc_attr']['wwpn'])
        output.setVirtualNameValue("FC_ID",value['fc_attr']['fcid'])
        output.setVirtualNameValue("SPMA", value['fc_attr']['spma'])
        output.setVirtualNameValue("FPMA", value['fc_attr']['fpma'])

    output.endAssembling("VadapterListAll") 
Ejemplo n.º 19
0
def _gateway_spec(output, gw_id, gw_module, bxm_guid, name, desc, int_port,
                  ext_port, ingress_learning, ingress_secure, egress_secure,
                  flood, checksum_offload):
    """Output the gateway spec"""
    output.beginAssembling("GatewayList")
    output.setVirtualNameValue("GW_ID", gw_id)
    output.setVirtualNameValue("GW_MODULE", gw_module)
    output.setVirtualNameValue("BXM_GUID", bxm_guid)
    output.setVirtualNameValue("NAME", name)
    output.setVirtualNameValue("DESC", desc)
    output.setVirtualNameValue("INT_PORT", int_port)
    output.setVirtualNameValue("EXT_PORT", ext_port)
    output.setVirtualNameValue("INGRESS_LEARNING", ingress_learning)
    output.setVirtualNameValue("INGRESS_SECURE", ingress_secure)
    output.setVirtualNameValue("EGRESS_SECURE", egress_secure)
    output.setVirtualNameValue("FLOOD", flood)
    output.setVirtualNameValue("CHECKSUM_OFFLOAD", checksum_offload)
    output.endAssembling("GatewayList")
Ejemplo n.º 20
0
def _vfabric_spec(output, id, value):
    """ Display for the show vfabric """
    output.beginAssembling("VfabricListAll")

    output.setVirtualNameValue("ID", id)
    output.setVirtualNameValue("NAME", value['name'])
    output.setVirtualNameValue("CTX_TABLE_ID", value['ctx_table_id'])
    output.setVirtualNameValue("PRIMARY_GW_ID", value['primary_gateway'])
    output.setVirtualNameValue("PROTOCOL", value['protocol'])
    output.setVirtualNameValue("TYPE", value.get('type', 'HOST_INITIATED'))
    output.setVirtualNameValue("NUM_VADAPTER", value['num_vadapter_id'])
    output.setVirtualNameValue("VADAPTER_IDs", value['vadapter_id'])
    output.setVirtualNameValue("DESC", value['desc'])
    output.setVirtualNameValue("BACKUP_GW_ID", value['backup_gateway'])
    output.setVirtualNameValue("AUTO_FAILOVER", value['auto_failover'])
    output.setVirtualNameValue("AUTO_FAILBACK", value['auto_failback'])
    #Running mode:default set to OFFLINE
    output.setVirtualNameValue("RUNNING_MODE",
                               value.get('running_mode', 'OFFLINE'))
    output.setVirtualNameValue("HA_STATE", value.get('ha_state', 'NORMAL'))

    if value['protocol'] == 1:
        output.setVirtualNameValue("MAC", value['en_attr']['mac'])
        output.setVirtualNameValue("VLAN", value['en_attr']['vlan'])

    if value['protocol'] == 3:
        output.setVirtualNameValue("WWNN", value['fc_attr']['wwnn'])
        output.setVirtualNameValue("WWPN", value['fc_attr']['wwpn'])
        output.setVirtualNameValue("FCID", value['fc_attr']['fcid'])

    output.endAssembling("VfabricListAll")
Ejemplo n.º 21
0
def _vfabric_spec(output, id, value):
    """ Display for the show vfabric """
    output.beginAssembling("VfabricListAll")

    output.setVirtualNameValue("ID", id)
    output.setVirtualNameValue("NAME", value['name'])
    output.setVirtualNameValue("CTX_TABLE_ID", value['ctx_table_id'])
    output.setVirtualNameValue("PRIMARY_GW_ID", value['primary_gateway'])
    output.setVirtualNameValue("PROTOCOL", value['protocol'])
    output.setVirtualNameValue("TYPE", value.get('type','HOST_INITIATED'))
    output.setVirtualNameValue("NUM_VADAPTER", value['num_vadapter_id'])
    output.setVirtualNameValue("VADAPTER_IDs", value['vadapter_id'])
    output.setVirtualNameValue("DESC", value['desc'])
    output.setVirtualNameValue("BACKUP_GW_ID",value['backup_gateway'])
    output.setVirtualNameValue("AUTO_FAILOVER",value['auto_failover'])
    output.setVirtualNameValue("AUTO_FAILBACK",value['auto_failback'])
    #Running mode:default set to OFFLINE
    output.setVirtualNameValue("RUNNING_MODE", value.get('running_mode', 'OFFLINE'))
    output.setVirtualNameValue("HA_STATE", value.get('ha_state', 'NORMAL'))

    if value['protocol'] == 1:
        output.setVirtualNameValue("MAC", value['en_attr']['mac'])
        output.setVirtualNameValue("VLAN", value['en_attr']['vlan'])

    if value['protocol'] == 3:
        output.setVirtualNameValue("WWNN", value['fc_attr']['wwnn'])
        output.setVirtualNameValue("WWPN", value['fc_attr']['wwpn'])
        output.setVirtualNameValue("FCID", value['fc_attr']['fcid'])
        
    output.endAssembling("VfabricListAll")
Ejemplo n.º 22
0
            output.completeOutputError(
                "count should be a number greater than 0")
            return output
        if (cnt > 1024):
            output.completeOutputError("count should not exceed 1024")
            return output
    except ValueError:
        output.completeOutputError("count should be a number greater than 0")
        return output

    try:
        ipaddr = socket.gethostbyname(name)
    except socket.error, e:
        output.completeOutputError("cannot resolve '%s': %s" % (name, e))
        return output

    try:
        pipe = popen2.Popen4("/bin/ping -nb -c %d -w %d %s" % \
                                                (cnt, cnt+10, name),
                                                0)
        #output.beginList("PingSpecList")
        output.beginAssembling("Ping")
        output.setVirtualNameValue("PingOutput", pipe)
        output.endAssembling("Ping")
        #output.endList("PingSpecList")
        output.completeOutputSuccess()
    except OSError, e:
        output.completeOutputError("Internal error: ping failed: %s" % (e, ))

    return output
Ejemplo n.º 23
0
def _bridge_detail(output, name , desc, running_mode,
		  firmware_module , vfm_guid, no_gw_modules,
		  gw_module_index, gw_module_id,
		  int_protocol, ext_protocol, no_int_protocol,
		  no_ext_protocol, int_ports, ext_ports, gw_ids,
		  port_id, phy_index, type, protocol, state, mac,
		  wwnn, wwpn, fcid, ib_guid, lid, qpn, sl, support_speed,
		  actual_speed, rx_stat, tx_stat, last_keep_alive):
    output.beginAssembling("Bridge_Device")
    output.setVirtualNameValue("name", name)
    output.setVirtualNameValue("desc", desc)
    output.setVirtualNameValue("state",state)
    output.setVirtualNameValue("running-mode", running_mode)
    output.setVirtualNameValue("firmware-module",firmware_module)
    output.setVirtualNameValue("vfm-guid",vfm_guid)
    output.setVirtualNameValue("number-gw-module",no_gw_module)
    output.setVirtualNameValue("gw-module-index",gw_module_index)
    output.setVirtualNameValue("gw-module-id",gw_module_id)
    output.setVirtualNameValue("int_protocol", int_protocol)
    output.setVirtualNameValue("ext_protocol",ext_protocol)
    output.setVirtualNameValue("no_int_protocols",no_int_protocol)
    output.setVirtualNameValue("no_ext_protocols",no_ext_protocol)
    output.setVirtualNameValue("int-ports",int_ports)
    output.setVirtualNameValue("ext-ports",ext_ports)
    output.setVirtualNameValue("gw-ids",gw_ids)
    output.setVirtualNameValue("port-id",port_id)
    output.setVirtualNameValue("phy-index",phy_index)
    output.setVirtualNameValue("type",type)
    output.setVirtualNameValue("protocol",protocol)
    output.setVirtualNameValue("state",state)
    output.setVirtualNameValue("mac",mac)
    output.setVirtualNameValue("wwnn",wwnn)
    output.setVirtualNameValue("wwpn",wwpn)
    output.setVirtualNameValue("fcid",fcid)
    output.setVirtualNameValue("ib_guid",ib_guid)
    output.setVirtualNameValue("lid",lid)
    output.setVirtualNameValue("qpn",qpn)
    output.setVirtualNameValue("sl",sl)
    output.setVirtualNameValue("support-speed",support_speed)
    output.setVirtualNameValue("actual-speed",actual_speed)
    output.setVirtualNameValue("rx-stat",rx_stat)
    output.setVirtualNameValue("tx-stat",tx_stat)
    output.setVirtualNameValue("last-keep-alive",last_keep_alive)
    output.endAssembling("Bridge_Device")
Ejemplo n.º 24
0
def _gateway_spec(output, gw_id, gw_module, bxm_guid, name, 
                    desc, int_port, ext_port,ingress_learning,
                    ingress_secure, egress_secure, flood, checksum_offload):
    """Output the gateway spec"""
    output.beginAssembling("GatewayList")
    output.setVirtualNameValue("GW_ID", gw_id)
    output.setVirtualNameValue("GW_MODULE", gw_module)
    output.setVirtualNameValue("BXM_GUID", bxm_guid)
    output.setVirtualNameValue("NAME", name)
    output.setVirtualNameValue("DESC", desc)
    output.setVirtualNameValue("INT_PORT",int_port)
    output.setVirtualNameValue("EXT_PORT", ext_port)
    output.setVirtualNameValue("INGRESS_LEARNING", ingress_learning)
    output.setVirtualNameValue("INGRESS_SECURE", ingress_secure)
    output.setVirtualNameValue("EGRESS_SECURE",egress_secure)
    output.setVirtualNameValue("FLOOD", flood)
    output.setVirtualNameValue("CHECKSUM_OFFLOAD", checksum_offload)
    output.endAssembling("GatewayList")
Ejemplo n.º 25
0
def show(argv):
    """Get the current time and date. 
        syntax: show clock
                show clock timezones [all]
        The default is to show timezones in the USA.
    """

    output = lib.output.CLIoutput("clock", _output_handlers)

    if len(argv) > 3:
        lib.errorhandler.InvalidArgumentCount(syntax=show.__doc__)
        return output

    if len(argv) >= 2 and (argv[1] == '' or \
           not "timezones".startswith(argv[1].lower())):
        lib.errorhandler.InvalidArgumentCount(2, argv[1], show.__doc__)
        return output

    if len(argv) == 3 and (argv[2] == '' or \
           not "all".startswith(argv[2].lower())):
        lib.errorhandler.InvalidArgumentCount(3, argv[2], show.__doc__)
        return output

    if len(argv) == 3:
        return _show_timezones(output)
    elif len(argv) == 2:
        return _show_usa_timezones(output)

    now_time = time.strftime(_TIME_FORMAT)
    dateInfo = now_time.split(' ')

    output.beginAssembling(_XMLTAG_TIMESPEC)

    output.setVirtualNameValue(_XMLTAG_Year, dateInfo[0])
    output.setVirtualNameValue(_XMLTAG_Month, dateInfo[1])
    output.setVirtualNameValue(_XMLTAG_MonthName, dateInfo[2])
    output.setVirtualNameValue(_XMLTAG_Date, dateInfo[3])
    output.setVirtualNameValue(_XMLTAG_DayName, dateInfo[4])
    output.setVirtualNameValue(_XMLTAG_Hour, dateInfo[5])
    output.setVirtualNameValue(_XMLTAG_Minute, dateInfo[6])
    output.setVirtualNameValue(_XMLTAG_Second, dateInfo[7])

    TZoffsetString = dateInfo[8]

    output.beginAssembling(_XMLTAG_TZD)

    output.setVirtualNameValue(_XMLTAG_TZDoffset, TZoffsetString[0])
    output.setVirtualNameValue(_XMLTAG_TZDhours, TZoffsetString[1:3])
    output.setVirtualNameValue(_XMLTAG_TZDminutes, TZoffsetString[3:5])
    output.setVirtualNameValue(_XMLTAG_TZDlabel, dateInfo[9])

    TZlocation = _TZLOCATION_UNAVAILABLE
    try:
        # factor out most of the relative path in the symbolic link value
        TZlocation = os.readlink(_TZLOCATION_LINK)
        TZlocation = TZlocation.replace(".." + _TZ_TARGET_DIR, "")
    except:
        pass

    output.setVirtualNameValue(_XMLTAG_TZDlocation, TZlocation)

    output.endAssembling(_XMLTAG_TZD)

    output.endAssembling(_XMLTAG_TIMESPEC)
    output.completeOutputSuccess()
    return output
Ejemplo n.º 26
0
        if doc_str is None and modifier == lib.command_ref.EDIT_MODIFIER:
            doc_str = module.__doc__
        if doc_str is not None:
            output.setVirtualNameValue('Help', doc_str)
            output.completeOutputSuccess()
            return output
    except (lib.command_ref.UnknownPluginException,
            NameError, AttributeError), ex:
        pass

    # Try to match it in the general section help dict.
    orig_arg = string.join(argv[1:]).lower()
    try:
        help_text = _select_one_help_from_dict(orig_arg, _ALL_COMMANDS_DICT)
        header = _make_help_header('Commands')
        output.setVirtualNameValue('Help', header + help_text)
        output.completeOutputSuccess()
        return output
    except KeyError, ex:
        _logger.debug("=== not in the section of all commands")

    # Error. Nothing matches. Try to show the help for the modifier
    help_text = _display_modifier_help(modifier)
    output.completeOutputError('No help available for "%s".\n' % orig_arg +
                            help_text)
    return output


def _display_modifier_help(modifier):
    '''Do the help on a modifier.'''
    if modifier == lib.command_ref.SHOW_MODIFIER:
Ejemplo n.º 27
0
def _bridge_select(output, desc, state, running_mode, firmware_module,
                   vfm_guid, no_gw_module, gw_module_index, last_keep_alive):
    """Output of the show bridge """
    output.beginAssembling("Bridge_Device")
    output.setVirtualNameValue("desc", desc)
    output.setVirtualNameValue("state", state)
    output.setVirtualNameValue("running-mode", running_mode)
    output.setVirtualNameValue("firmware-version", firmware_module)
    output.setVirtualNameValue("vfm-guid", vfm_guid)
    output.setVirtualNameValue("number-gw-module", no_gw_module)
    output.setVirtualNameValue("gw-Module-Index", gw_module_index)
    output.setVirtualNameValue("last-keep-alive", last_keep_alive)
    output.endAssembling("Bridge_Device")
Ejemplo n.º 28
0
	    output.completeOutputError("count should be a number greater than 0")
	    return output
	if (cnt > 1024):
	    output.completeOutputError("count should not exceed 1024")
	    return output
    except ValueError:
        output.completeOutputError("count should be a number greater than 0")
        return output

    try:
        ipaddr = socket.gethostbyname(name)
    except socket.error, e:
        output.completeOutputError("cannot resolve '%s': %s" % (name, e))
        return output

    try:
        pipe = popen2.Popen4("/bin/ping -nb -c %d -w %d %s" % \
                                                (cnt, cnt+10, name),
                                                0)
	#output.beginList("PingSpecList")
        output.beginAssembling("Ping")
        output.setVirtualNameValue("PingOutput", pipe)
        output.endAssembling("Ping")
	#output.endList("PingSpecList")
        output.completeOutputSuccess()
    except OSError, e:
        output.completeOutputError("Internal error: ping failed: %s" % (e,))
       
    return output

Ejemplo n.º 29
0
def show(argv):
    """Get the current time and date. 
        syntax: show clock
                show clock timezones [all]
        The default is to show timezones in the USA.
    """

    output = lib.output.CLIoutput("clock", _output_handlers)

    if len(argv) > 3:
        lib.errorhandler.InvalidArgumentCount(syntax=show.__doc__)
        return output

    if len(argv) >= 2 and (argv[1] == '' or \
           not "timezones".startswith(argv[1].lower())):
        lib.errorhandler.InvalidArgumentCount(2, argv[1], show.__doc__)
        return output
        
    if len(argv) == 3 and (argv[2] == '' or \
           not "all".startswith(argv[2].lower())):
        lib.errorhandler.InvalidArgumentCount(3, argv[2], show.__doc__)
        return output
        
    if len(argv) == 3:
        return _show_timezones(output)
    elif len(argv) == 2:
        return _show_usa_timezones(output)

    now_time = time.strftime(_TIME_FORMAT)
    dateInfo = now_time.split(' ')

    output.beginAssembling(_XMLTAG_TIMESPEC)

    output.setVirtualNameValue(_XMLTAG_Year,       dateInfo[0])
    output.setVirtualNameValue(_XMLTAG_Month,      dateInfo[1])
    output.setVirtualNameValue(_XMLTAG_MonthName,  dateInfo[2])
    output.setVirtualNameValue(_XMLTAG_Date,       dateInfo[3])
    output.setVirtualNameValue(_XMLTAG_DayName,    dateInfo[4])
    output.setVirtualNameValue(_XMLTAG_Hour,       dateInfo[5])
    output.setVirtualNameValue(_XMLTAG_Minute,     dateInfo[6])
    output.setVirtualNameValue(_XMLTAG_Second,     dateInfo[7])

    TZoffsetString=dateInfo[8]

    output.beginAssembling(_XMLTAG_TZD)

    output.setVirtualNameValue(_XMLTAG_TZDoffset,  TZoffsetString[0])
    output.setVirtualNameValue(_XMLTAG_TZDhours,   TZoffsetString[1:3])
    output.setVirtualNameValue(_XMLTAG_TZDminutes, TZoffsetString[3:5])
    output.setVirtualNameValue(_XMLTAG_TZDlabel,   dateInfo[9])

    TZlocation = _TZLOCATION_UNAVAILABLE
    try: 
        # factor out most of the relative path in the symbolic link value
        TZlocation = os.readlink(_TZLOCATION_LINK)
        TZlocation = TZlocation.replace(".." + _TZ_TARGET_DIR, "")
    except:
        pass

    output.setVirtualNameValue(_XMLTAG_TZDlocation,   TZlocation)

    output.endAssembling(_XMLTAG_TZD)

    output.endAssembling(_XMLTAG_TIMESPEC)
    output.completeOutputSuccess()
    return output