Esempio n. 1
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
Esempio n. 2
0
File: arp.py Progetto: 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
Esempio n. 3
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
Esempio 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
Esempio n. 5
0
def _show_bridge(output, argv, bridge_id):
    """
       Show bridge
           syntax : show bridge
    """
    output.beginList("BridgeSpecList")
    _get_bridge_from_db(output, "bridge", bridge_id)
    output.endList("BridgeSpecList")
    output.completeOutputSuccess()
Esempio n. 6
0
def _show_iomodule(output, argv):
    """
       Show iomodule
           syntax : show iomodule
    """
    output.beginList("IomoduleSpecList")
    _get_iomodule_values(output, "iomodule")
    output.endList("IomoduleSpecList")
    output.completeOutputSuccess()
Esempio n. 7
0
def _show_bridge(output, argv, bridge_id):
    """
       Show bridge
           syntax : show bridge
    """
    output.beginList("BridgeSpecList")
    _get_bridge_from_db(output, "bridge", bridge_id)
    output.endList("BridgeSpecList")
    output.completeOutputSuccess()
Esempio n. 8
0
def _show_vfabric(output, argv):
    """
       Show vfabric
           syntax : show vfabric
    """
    param1 = 0
    output.beginList("VfabricSpecList")
    param1 = _get_vfabric_values(output, "vfabric", "All")
    output.endList("VfabricSpecList")
    if param1 != -1:
        output.completeOutputSuccess()
    return output
Esempio n. 9
0
def _show_vfabric_module(output, argv, vfabric_id):
    """
       Show vfabric <vfabric_id>
           syntax : show vfabric <vfabric_id>
    """
    param1 = 0
    output.beginList("VfabricSpecList")
    _get_vfabric_values(output, "vfabric", vfabric_id)
    output.endList("VfabricSpecList")
    if param1 != -1:
        output.completeOutputSuccess()
    return output
Esempio n. 10
0
def _show_vfabric(output, argv):
    """
       Show vfabric
           syntax : show vfabric
    """
    param1 = 0
    output.beginList("VfabricSpecList")
    param1 = _get_vfabric_values(output, "vfabric", "All")
    output.endList("VfabricSpecList")
    if param1 != -1 :
        output.completeOutputSuccess()
    return output
Esempio n. 11
0
def _show_vfabric_module(output, argv, vfabric_id):
    """
       Show vfabric <vfabric_id>
           syntax : show vfabric <vfabric_id>
    """
    param1 = 0
    output.beginList("VfabricSpecList")
    _get_vfabric_values(output, "vfabric", vfabric_id)
    output.endList("VfabricSpecList")
    if param1 != -1:
        output.completeOutputSuccess()
    return output 
Esempio n. 12
0
def _show_vadapter(output, argv):
    """
       Show vadapter
           syntax : show vadapter
    """
    param1 = 0
    output.beginList("VadapterSpecList")
    param1 =_get_vadapter_values(output, "vadapter", "ALL")
    output.endList("VadapterSpecList")
    if param1 != -1 :
         output.completeOutputSuccess()
    return output
Esempio n. 13
0
def _show_vadapter_module(output, argv, vadapter_id):
    """
       Show vadapter <vadapter-id>
           syntax : show vadapter <vadapter-id>
    """
    param1 = 0
    output.beginList("VadapterSpecList")
    param1 =  _get_vadapter_values(output, "vadapter", vadapter_id)    
    output.endList("VadapterSpecList")
    if param1 != -1 :
        output.completeOutputSuccess()
    return output
Esempio n. 14
0
File: ip.py Progetto: 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")
Esempio n. 15
0
def _show_gateway(output, argv):
    """
       Show gateway
           syntax : show gateway
		    show gateway < gateway-id >
		    show gateway < help | ?  >
    """

    if len(argv) > 1 or argv[0] == "?" or argv[0] == "help" or argv[0] == "":
        output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__))
        return output

    elif len(argv) == 1:
        print argv[0]

    output.beginList("GatewaySpecList")
    _get_gateway_from_db(output, "gateway")
    output.endList("GatewaySpecList")
    output.completeOutputSuccess()
Esempio n. 16
0
def _show_gateway(output, argv):
    """
       Show gateway
           syntax : show gateway
		    show gateway < gateway-id >
		    show gateway < help | ?  >
    """
   
    if len(argv) > 1 or argv[0] == "?" or argv[0] == "help" or argv[0] == "":
	output.completeOutputError(InvalidArgumentCount(syntax =show.__doc__))
	return output

    elif len(argv) == 1:
	print argv[0]

    output.beginList("GatewaySpecList")
    _get_gateway_from_db(output,"gateway")
    output.endList("GatewaySpecList")
    output.completeOutputSuccess()
Esempio n. 17
0
File: ip.py Progetto: 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")
Esempio n. 18
0
File: ip.py Progetto: gautamrege/vfm
 if len(argv) >= 1:
     addr = argv[0]
     try:
         checkIp(addr)
     except UnknownIpCheck, ex:
         output.completeOutputError(InvalidArgumentCount(2, argv[0],
             _show_ip_addresses.__doc__, str(ex)))
         return output
     if len(argv) == 2:
         if (argv[1] == '' or not "usage".startswith(argv[1].lower())):
             output.completeOutputError(InvalidArgumentCount(
                 3, argv[1], _show_ip_addresses.__doc__))
             return output
 cmd = [_IP, 'addr']
 (exitval, output_result, err, fullstatus) = lib.process.execute_command(cmd)
 output.beginList("IPaddressSpecList")
 for ln in output_result[1:]:      
     fields = ln.split()
     if fields[-1].find('eth') == 0:
        ethernet = fields[-1]
        netmask = getSubNetMask(ethernet)
        addr = fields[1].split("/")
        ipAddress = addr[0]
        scope = fields[5]
        active = isActive(ethernet) 
        _ip_address_spec(output, ipAddress, netmask, ethernet, scope, active )
 output.endList("IPaddressSpecList")
    
 if len(argv) == 2:
     _ipaddr_usage(output, address_list, addr)
     return
Esempio n. 19
0
def _show_imodule_module(output, argv, io_module):
    output.beginList("IomoduleSpecList")
    _get_iomodule_values(output, "iomodule", io_module)
    output.endList("IomoduleSpecList")
    output.completeOutputSuccess()
Esempio n. 20
0
File: ip.py Progetto: rajat007/vfm
            checkIp(addr)
        except UnknownIpCheck, ex:
            output.completeOutputError(
                InvalidArgumentCount(2, argv[0], _show_ip_addresses.__doc__,
                                     str(ex)))
            return output
        if len(argv) == 2:
            if (argv[1] == '' or not "usage".startswith(argv[1].lower())):
                output.completeOutputError(
                    InvalidArgumentCount(3, argv[1],
                                         _show_ip_addresses.__doc__))
                return output
    cmd = [_IP, 'addr']
    (exitval, output_result, err,
     fullstatus) = lib.process.execute_command(cmd)
    output.beginList("IPaddressSpecList")
    for ln in output_result[1:]:
        fields = ln.split()
        if fields[-1].find('eth') == 0:
            ethernet = fields[-1]
            netmask = getSubNetMask(ethernet)
            addr = fields[1].split("/")
            ipAddress = addr[0]
            scope = fields[5]
            active = isActive(ethernet)
            _ip_address_spec(output, ipAddress, netmask, ethernet, scope,
                             active)
    output.endList("IPaddressSpecList")

    if len(argv) == 2:
        _ipaddr_usage(output, address_list, addr)