From b196a30f6aab3f2b68828975511cf1f5478e2818 Mon Sep 17 00:00:00 2001 From: Omar Sanchez Date: Tue, 2 Aug 2022 17:58:03 -0400 Subject: [PATCH 1/4] handle deprecated endpoint ip key field, added new ips field. fixed syntax error on string comparison --- acitoolkit/acitoolkit.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/acitoolkit/acitoolkit.py b/acitoolkit/acitoolkit.py index 495bf690..6d64059e 100755 --- a/acitoolkit/acitoolkit.py +++ b/acitoolkit/acitoolkit.py @@ -5135,6 +5135,7 @@ def __init__(self, name, parent): super(Endpoint, self).__init__(name, parent=parent) self.mac = None self.ip = None + self.ips = [] self.encap = None self.if_name = None self.if_dn = [] @@ -5210,7 +5211,7 @@ def _populate_from_attributes(self, attributes): self.encap = str(attributes.get('encap')) if 'lcC' in attributes: life_cycle = str(attributes.get('lcC')) - if life_cycle is not '': + if life_cycle != '': self.life_cycle = life_cycle if 'type' in attributes: self.type = str(attributes.get('type')) @@ -5391,7 +5392,12 @@ def _get(session, endpoint_name, interfaces, endpoints, epg = EPG(str(ep['dn']).split('/')[3][4:], app_profile) endpoint = Endpoint(str(ep['name']), parent=epg) endpoint.mac = str(ep['mac']) - endpoint.ip = str(ep['ip']) + endpoint.ip = str(ep.get('ip', "")) + for child in children: + if "fvIp" in child: + child_ip = str(child.get('fvIp', {}).get('attributes', {}).get('addr')) + if child_ip: + endpoint.ips.append(child_ip) endpoint.encap = str(ep['encap']) endpoint.timestamp = str(ep['modTs']) for child in children: From ba631f85f04c2b64690948c6c8b3ab3ab2fb7b42 Mon Sep 17 00:00:00 2001 From: Omar Sanchez Date: Tue, 2 Aug 2022 18:14:40 -0400 Subject: [PATCH 2/4] dont cast to string --- acitoolkit/acitoolkit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acitoolkit/acitoolkit.py b/acitoolkit/acitoolkit.py index 6d64059e..210cd649 100755 --- a/acitoolkit/acitoolkit.py +++ b/acitoolkit/acitoolkit.py @@ -5395,7 +5395,7 @@ def _get(session, endpoint_name, interfaces, endpoints, endpoint.ip = str(ep.get('ip', "")) for child in children: if "fvIp" in child: - child_ip = str(child.get('fvIp', {}).get('attributes', {}).get('addr')) + child_ip = child.get('fvIp', {}).get('attributes', {}).get('addr') if child_ip: endpoint.ips.append(child_ip) endpoint.encap = str(ep['encap']) From 4fe1ee125e49aa061d7918dfad38270b612c6e3d Mon Sep 17 00:00:00 2001 From: Omar Sanchez Date: Tue, 2 Aug 2022 18:19:43 -0400 Subject: [PATCH 3/4] upped version --- acitoolkit/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acitoolkit/__about__.py b/acitoolkit/__about__.py index f830c17f..d40ce263 100644 --- a/acitoolkit/__about__.py +++ b/acitoolkit/__about__.py @@ -19,7 +19,7 @@ __summary__ = "Toolkit for Cisco ACI Fabrics" __uri__ = "http://datacenter.github.io/acitoolkit/" -__version__ = "0.4" +__version__ = "0.41" __author__ = "Cisco Systems, Inc." __email__ = "acitoolkit@external.cisco.com" From 9e392653c5b41a410ffd451249b4f71769d3f441 Mon Sep 17 00:00:00 2001 From: Omar Sanchez Date: Tue, 2 Aug 2022 22:42:38 -0400 Subject: [PATCH 4/4] removed ips attribute, it is duplicate of secondary ips attr --- acitoolkit/acitoolkit.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/acitoolkit/acitoolkit.py b/acitoolkit/acitoolkit.py index 210cd649..ca7ad1cc 100755 --- a/acitoolkit/acitoolkit.py +++ b/acitoolkit/acitoolkit.py @@ -5135,7 +5135,6 @@ def __init__(self, name, parent): super(Endpoint, self).__init__(name, parent=parent) self.mac = None self.ip = None - self.ips = [] self.encap = None self.if_name = None self.if_dn = [] @@ -5393,11 +5392,6 @@ def _get(session, endpoint_name, interfaces, endpoints, endpoint = Endpoint(str(ep['name']), parent=epg) endpoint.mac = str(ep['mac']) endpoint.ip = str(ep.get('ip', "")) - for child in children: - if "fvIp" in child: - child_ip = child.get('fvIp', {}).get('attributes', {}).get('addr') - if child_ip: - endpoint.ips.append(child_ip) endpoint.encap = str(ep['encap']) endpoint.timestamp = str(ep['modTs']) for child in children: