From 42ed70f4a8f6e1b29b089bb21028a6128ce5c29f Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 15 Feb 2023 14:59:44 +0100 Subject: [PATCH 1/2] [config-gen] Also ignore lag members with lag being ignored --- networking_ccloud/tools/netbox_config_gen.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/networking_ccloud/tools/netbox_config_gen.py b/networking_ccloud/tools/netbox_config_gen.py index 3c8168f6..ed5fbc5c 100644 --- a/networking_ccloud/tools/netbox_config_gen.py +++ b/networking_ccloud/tools/netbox_config_gen.py @@ -180,7 +180,10 @@ def __init__(self, region, args, verbose=False, verify_ssl=False): @classmethod def _ignore_filter(cls, items: Iterable[NbRecord]) -> Generator[NbRecord, None, None]: for item in items: - if any(x.slug in cls.ignore_tags for x in getattr(item, 'tags', list())): + if hasattr(item, 'lag') and item.lag and \ + any(x.slug in cls.ignore_tags for x in getattr(item.lag, 'tags', list())): + print(f'LAG of interface {item.url} has ignore tag set') + elif any(x.slug in cls.ignore_tags for x in getattr(item, 'tags', list())): print(f'Item {item.url} has ignore tag set') else: yield item From 3a9ee1741ec2b289873847afb4f174dccb9e1fba Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 15 Feb 2023 15:30:38 +0100 Subject: [PATCH 2/2] [config-gen] Do not fail if no address-scope path is given Without the default value, the address-scope path evaluates to None which is not iterable. With an empty iterable we omit this error. --- networking_ccloud/tools/netbox_config_gen.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/networking_ccloud/tools/netbox_config_gen.py b/networking_ccloud/tools/netbox_config_gen.py index ed5fbc5c..5bf22338 100644 --- a/networking_ccloud/tools/netbox_config_gen.py +++ b/networking_ccloud/tools/netbox_config_gen.py @@ -591,7 +591,8 @@ def get_connected_devices(self, switches: List[NbRecord]) -> Tuple[Set[NbRecord] print(f"Device {switch.name} port {iface.name} is connected to " f"device {far_device.name} port {iface.connected_endpoint.name} " f"role {far_device.device_role.name}") - + if far_device.name == "qa-de-1-rt415b": + print ports_to_device = device_ports_map.get(far_device, []) # ensure InfraNetworks are symmetric infra_nets_and_extra_vlans = self.make_infra_networks_and_extra_vlans(iface, svi_vlan_ip_map) @@ -834,7 +835,7 @@ def main(): 'Format should be: /...') parser.add_argument("-a", "--address-scope-vrf-map", type=Path, nargs="+", help="Path to file containing a mapping of address scope names to VRFs. If this is omitted, " - "no mapping will be generated.") + "no mapping will be generated.", default=[]) parser.add_argument("-s", "--shell", action="store_true") parser.add_argument("-o", "--output")