Exemplo n.º 1
0
    def run(self, opts, flags):
        keymap = 'interface'
        intf = None
        if opts:
            if isinstance(opts[0], TInterface):
                # "show interface <interface>"
                intf = opts[0]
            elif isinstance(opts[0], TKeyword):
                if opts[0] == 'mgmt':
                    # "show interface mgmt"
                    intf = opts[0]
                    keymap = 'mgmt-interface'
        if intf:
            intflist = [intf]
        else:
            intflist = get_interface_list()

        for intf in intflist:
            if 'transceiver' in opts:
                keymap = 'interface-transceiver'
            data = get_interface(intf)
            line = "Interface %s" % intf
            if 'brief' in opts:
                # Show only the interface + oper and admin state.
                if 'link_state' in data:
                    line += " is %s" % data['link_state']
                    if data['link_state'] == 'down' and 'admin_state' in data:
                        line += " (administratively %s)" % data['admin_state']
                cli_out(line)
            else:
                # Show all interface attributes in keymap.
                cli_out(line + ':')
                out_kv(keymap, data)
Exemplo n.º 2
0
    def run(self, opts, flags):
        keymap = "interface"
        intf = None
        if opts:
            if isinstance(opts[0], TInterface):
                # "show interface <interface>"
                intf = opts[0]
            elif isinstance(opts[0], TKeyword):
                if opts[0] == "mgmt":
                    # "show interface mgmt"
                    intf = opts[0]
                    keymap = "mgmt-interface"
        if intf:
            intflist = [intf]
        else:
            intflist = get_interface_list()

        for intf in intflist:
            if "transceiver" in opts:
                keymap = "interface-transceiver"
            data = get_interface(intf)
            line = "Interface %s" % intf
            if "brief" in opts:
                # Show only the interface + oper and admin state.
                if "link_state" in data:
                    line += " is %s" % data["link_state"]
                    if data["link_state"] == "down" and "admin_state" in data:
                        line += " (administratively %s)" % data["admin_state"]
                cli_out(line)
            else:
                # Show all interface attributes in keymap.
                cli_out(line + ":")
                out_kv(keymap, data)
Exemplo n.º 3
0
 def enum(self):
     return get_interface_list()
Exemplo n.º 4
0
 def enum(self):
     return get_interface_list()