Example #1
0
    def remove_trunk_vlan(self, interface_id, vlan):
        config = self.query(all_interfaces, self.custom_strategies.all_vlans)
        interface_node = self.get_interface_config(interface_id, config)
        if interface_node is None:
            raise UnknownInterface(interface_id)

        interface = self.node_to_interface(interface_node, config)

        if interface.port_mode is ACCESS:
            raise InterfaceInWrongPortMode("access")

        vlan_node = self.custom_strategies.vlan_node(config, vlan)
        vlan_name = first(vlan_node.xpath("name")).text

        modifications = self.custom_strategies.craft_members_modification_to_remove_vlan(
            interface_node, vlan_name, vlan)
        if len(modifications) == 0:
            raise TrunkVlanNotSet(interface_id)

        update = Update()
        update.add_interface(
            self.custom_strategies.interface_update(
                interface_id, "0", vlan_members=modifications))

        self._push(update)
Example #2
0
File: dell.py Project: idjaw/netman
    def remove_trunk_vlan(self, interface_id, vlan):
        interface_data = self.get_interface_data(interface_id)
        trunk_vlans = resolve_trunk_vlans(interface_data)

        if vlan not in trunk_vlans:
            raise TrunkVlanNotSet(interface_id)

        actual_port_mode = resolve_port_mode(interface_data)
        with self.config(), self.interface(interface_id):
            self.set("switchport {} allowed vlan remove {}", actual_port_mode, vlan)