Code Duplication    Length = 18-18 lines in 3 locations

scripts/console/2025.1.0/001_retire_vlans.py 1 location

@@ 66-83 (lines=18) @@
63
64
    for uni in ("uni_a", "uni_z"):
65
        intf_id = evc[uni]["interface_id"]
66
        if (
67
            "tag" in evc[uni]
68
            and evc[uni]["tag"]
69
            and "tag_type" in evc[uni]["tag"]
70
            and evc[uni]["tag"]["tag_type"] in ("vlan", 1)
71
        ):
72
            tag = evc[uni]["tag"]["value"]
73
            if isinstance(tag, int):
74
                in_use_tags[intf_id].append((tag, evc_id))
75
            elif isinstance(tag, list):
76
                for tag_item in tag:
77
                    if isinstance(tag_item, int):
78
                        in_use_tags[intf_id].append((tag_item, evc_id))
79
                    elif isinstance(tag_item, list) and len(tag_item) == 1:
80
                        in_use_tags[intf_id].append((tag_item[0], evc_id))
81
                    elif isinstance(tag_item, list) and len(tag_item) == 2:
82
                        for val in range(tag_item[0], tag_item[1]+1):
83
                            in_use_tags[intf_id].append((val, evc_id))
84
85
evc_disable_set = set()
86

scripts/console/2023.2.0/002_recover_vlans.py 1 location

@@ 63-80 (lines=18) @@
60
        in_use_tags[intfb].add(svlan)
61
    for uni in ("uni_a", "uni_z"):
62
        intf_id = evc[uni]["interface_id"]
63
        if (
64
            "tag" in evc[uni]
65
            and evc[uni]["tag"]
66
            and "tag_type" in evc[uni]["tag"]
67
            and evc[uni]["tag"]["tag_type"] in ("vlan", 1)
68
        ):
69
            tag = evc[uni]["tag"]["value"]
70
            if isinstance(tag, int):
71
                in_use_tags[intf_id].add(tag)
72
            elif isinstance(tag, list):
73
                for tag_item in tag:
74
                    if isinstance(tag_item, int):
75
                        in_use_tags[intf_id].add(tag_item)
76
                    elif isinstance(tag_item, list) and len(tag_item) == 1:
77
                        in_use_tags[intf_id].add(tag_item[0])
78
                    elif isinstance(tag_item, list) and len(tag_item) == 2:
79
                        for val in range(tag_item[0], tag_item[1]+1):
80
                            in_use_tags[intf_id].add(val)
81
82
switch_rm_flows = {}
83
flow_manager = controller.napps[('kytos', 'flow_manager')]

scripts/console/2023.2.0/001_use_tags.py 1 location

@@ 51-68 (lines=18) @@
48
49
    for uni in ("uni_a", "uni_z"):
50
        intf_id = evc[uni]["interface_id"]
51
        if (
52
            "tag" in evc[uni]
53
            and evc[uni]["tag"]
54
            and "tag_type" in evc[uni]["tag"]
55
            and evc[uni]["tag"]["tag_type"] in ("vlan", 1)
56
        ):
57
            tag = evc[uni]["tag"]["value"]
58
            if isinstance(tag, int):
59
                in_use_tags[intf_id].append((tag, evc_id))
60
            elif isinstance(tag, list):
61
                for tag_item in tag:
62
                    if isinstance(tag_item, int):
63
                        in_use_tags[intf_id].append((tag_item, evc_id))
64
                    elif isinstance(tag_item, list) and len(tag_item) == 1:
65
                        in_use_tags[intf_id].append((tag_item[0], evc_id))
66
                    elif isinstance(tag_item, list) and len(tag_item) == 2:
67
                        for val in range(tag_item[0], tag_item[1]+1):
68
                            in_use_tags[intf_id].append((val, evc_id))
69
70
switch_rm_flows = {}
71
flow_manager = controller.napps[('kytos', 'flow_manager')]