Example #1
0
    def show_int(self, args):
        ports = []
        port_name = " ".join(args[1:])
        if len(args) > 1:
            port = self.switch_configuration.get_port_by_partial_name(port_name)
            if port:
                ports.append(port)
        else:
            ports = self.switch_configuration.ports
        if not ports:
            [self.write_line(l) for l in explain_missing_port(port_name)]
        for port in ports:
            if isinstance(port, VlanPort):
                _, port_id = split_port_name(port.name)
                self.write_line("Ve%s is down, line protocol is down" % port_id)
                self.write_line("  Hardware is Virtual Ethernet, address is 0000.0000.0000 (bia 0000.0000.0000)")
                if port.description:
                    self.write_line("  Port name is %s" % port.description)
                else:
                    self.write_line("  No port name")

                self.write_line("  Vlan id: %s" % port.vlan_id)
                self.write_line("  Internet address is %s, IP MTU 1500 bytes, encapsulation ethernet" % (
                    port.ips[0] if port.ips else "0.0.0.0/0"))
            else:
                _, port_id = split_port_name(port.name)
                self.write_line("GigabitEthernet%s is %s, line protocol is down" % (
                    port_id, "down" if port.shutdown is False else "disabled"))
                self.write_line("  Hardware is GigabitEthernet, address is 0000.0000.0000 (bia 0000.0000.0000)")
                self.write_line("  " + ", ".join([vlan_membership(port), port_mode(port), port_state(port)]))
                if port.description:
                    self.write_line("  Port name is %s" % port.description)
                else:
                    self.write_line("  No port name")
Example #2
0
    def show_int(self, args):
        ports = []
        port_name = " ".join(args[1:])
        if len(args) > 1:
            port = self.switch_configuration.get_port_by_partial_name(port_name)
            if port:
                ports.append(port)
        else:
            ports = self.switch_configuration.ports
        if not ports:
            [self.write_line(l) for l in explain_missing_port(port_name)]
        for port in ports:
            if isinstance(port, VlanPort):
                _, port_id = split_port_name(port.name)
                self.write_line("Ve%s is down, line protocol is down" % port_id)
                self.write_line("  Hardware is Virtual Ethernet, address is 0000.0000.0000 (bia 0000.0000.0000)")
                if port.description:
                    self.write_line("  Port name is %s" % port.description)
                else:
                    self.write_line("  No port name")

                self.write_line("  Vlan id: %s" % port.vlan_id)
                self.write_line("  Internet address is %s, IP MTU 1500 bytes, encapsulation ethernet" % (
                    port.ips[0] if port.ips else "0.0.0.0/0"))
            else:
                _, port_id = split_port_name(port.name)
                self.write_line("GigabitEthernet%s is %s, line protocol is down" % (
                    port_id, "down" if port.shutdown is False else "disabled"))
                self.write_line("  Hardware is GigabitEthernet, address is 0000.0000.0000 (bia 0000.0000.0000)")
                self.write_line("  " + ", ".join([vlan_membership(port), port_mode(port), port_state(port)]))
                if port.description:
                    self.write_line("  Port name is %s" % port.description)
                else:
                    self.write_line("  No port name")
Example #3
0
 def do_interface(self, *args):
     port = self.switch_configuration.get_port_by_partial_name("".join(args))
     if port:
         if isinstance(port, VlanPort):
             self.move_to(ConfigVirtualInterfaceCommandProcessor, port)
         else:
             self.move_to(ConfigInterfaceCommandProcessor, port)
     else:
         if "ve".startswith(args[0]):
             self.write_line("Error - invalid virtual ethernet interface number.")
         else:
             [self.write_line(l) for l in explain_missing_port(" ".join(args))]
Example #4
0
 def do_no_interface(self, *args):
     port = self.switch_configuration.get_port_by_partial_name("".join(args))
     if port:
         if isinstance(port, VlanPort):
             self.switch_configuration.remove_port(port)
             self.switch_configuration.add_port(self.switch_configuration.new("VlanPort", port.vlan_id, port.name))
         elif isinstance(port, Port):
             trunk_vlans = port.trunk_vlans
             access_vlan = port.access_vlan
             trunk_native_vlan = port.trunk_native_vlan
             port.reset()
             port.trunk_vlans = trunk_vlans
             port.access_vlan = access_vlan
             port.trunk_native_vlan = trunk_native_vlan
     else:
         [self.write_line(l) for l in explain_missing_port(" ".join(args))]
Example #5
0
 def do_interface(self, *args):
     port = self.switch_configuration.get_port_by_partial_name(
         "".join(args))
     if port:
         if isinstance(port, VlanPort):
             self.move_to(self.config_virtual_interface_processor, port)
         else:
             self.move_to(self.config_interface_processor, port)
     else:
         if "ve".startswith(args[0]):
             self.write_line(
                 "Error - invalid virtual ethernet interface number.")
         else:
             [
                 self.write_line(l)
                 for l in explain_missing_port(" ".join(args))
             ]
Example #6
0
 def do_no_interface(self, *args):
     port = self.switch_configuration.get_port_by_partial_name(
         "".join(args))
     if port:
         if isinstance(port, VlanPort):
             self.switch_configuration.remove_port(port)
             self.switch_configuration.add_port(
                 self.switch_configuration.new("VlanPort", port.vlan_id,
                                               port.name))
         elif isinstance(port, Port):
             trunk_vlans = port.trunk_vlans
             access_vlan = port.access_vlan
             trunk_native_vlan = port.trunk_native_vlan
             port.reset()
             port.trunk_vlans = trunk_vlans
             port.access_vlan = access_vlan
             port.trunk_native_vlan = trunk_native_vlan
     else:
         [self.write_line(l) for l in explain_missing_port(" ".join(args))]