예제 #1
0
    def craft_members_modification_to_remove_vlan(self, interface_node,
                                                  vlan_name, number):
        members_modifications = []

        vlan_id_list = interface_node.xpath(
            "unit/family/bridge/vlan-id-list") + interface_node.xpath(
                "unit/family/bridge/vlan-id")

        for vlan_members_node in vlan_id_list:
            if vlan_members_node.text == vlan_name:
                members_modifications.append(
                    to_ele("<{tag} operation=\"delete\">{id}</{tag}>".format(
                        tag=vlan_members_node.tag, id=vlan_members_node.text)))
            else:
                vlan_list = parse_range(vlan_members_node.text)
                if number in vlan_list:
                    members_modifications.append(
                        to_ele(
                            "<vlan-id-list operation=\"delete\">{}</vlan-id-list>"
                            .format(vlan_members_node.text)))

                    below = vlan_list[:vlan_list.index(number)]
                    if len(below) > 0:
                        members_modifications.append(
                            to_ele("<vlan-id-list>{}</vlan-id-list>".format(
                                to_range(below))))

                    above = vlan_list[vlan_list.index(number) + 1:]
                    if len(above) > 0:
                        members_modifications.append(
                            to_ele("<vlan-id-list>{}</vlan-id-list>".format(
                                to_range(above))))

        return members_modifications
예제 #2
0
    def craft_members_modification_to_remove_vlan(self, interface_node,
                                                  vlan_name, number):
        members_modifications = []
        for vlan_members_node in interface_node.xpath(
                "unit/family/ethernet-switching/vlan/members"):
            if vlan_members_node.text == vlan_name:
                members_modifications.append(
                    to_ele("<members operation=\"delete\">{}</members>".format(
                        vlan_members_node.text)))
            else:
                vlan_list = parse_range(vlan_members_node.text)
                if number in vlan_list:
                    members_modifications.append(
                        to_ele("<members operation=\"delete\">{}</members>".
                               format(vlan_members_node.text)))

                    below = vlan_list[:vlan_list.index(number)]
                    if len(below) > 0:
                        members_modifications.append(
                            to_ele("<members>{}</members>".format(
                                to_range(below))))

                    above = vlan_list[vlan_list.index(number) + 1:]
                    if len(above) > 0:
                        members_modifications.append(
                            to_ele("<members>{}</members>".format(
                                to_range(above))))

        return members_modifications
예제 #3
0
    def list_vlan_members(self, interface_node, config):
        vlans = set()

        vlan_id_list = interface_node.xpath(
            "unit/family/bridge/vlan-id-list") + interface_node.xpath(
                "unit/family/bridge/vlan-id")

        for members in vlan_id_list:
            vlans = vlans.union(parse_range(members.text))

        return sorted(vlans)
예제 #4
0
 def list_vlan_members(self, interface_node, config):
     vlans = set()
     for members in interface_node.xpath(
             "unit/family/ethernet-switching/vlan/members"):
         vlan_id = value_of(config.xpath(
             'data/configuration/vlans/vlan/name[text()="{}"]/../vlan-id'.
             format(members.text)),
                            transformer=int)
         if vlan_id:
             vlans = vlans.union([vlan_id])
         else:
             vlans = vlans.union(parse_range(members.text))
     return sorted(vlans)