Skip to content

Commit 10753a8

Browse files
authored
Remove breakout ints for preprov devices (#509)
1 parent 4e1b4d5 commit 10753a8

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

plugins/modules/dcnm_interface.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,8 @@ def __init__(self, module):
19161916
self.dcnm_version = dcnm_version_supported(self.module)
19171917

19181918
self.inventory_data = {}
1919+
self.manageable = []
1920+
self.unmanageable = []
19191921

19201922
self.paths = self.dcnm_intf_paths[self.dcnm_version]
19211923

@@ -3946,7 +3948,10 @@ def dcnm_intf_get_have_all_breakout_interfaces(self, sno):
39463948
if resp and "DATA" in resp and resp["DATA"]:
39473949
for elem in resp["DATA"]:
39483950
if elem.get('templateName', None) == "breakout_interface":
3949-
breakout.append(elem['entityName'])
3951+
# Make sure the serial number for this device is a manageable device
3952+
# We cannot manage breakout interfaces for pre-provisioned devices
3953+
if elem.get('serialNumber') in self.manageable.values():
3954+
breakout.append(elem['entityName'])
39503955
self.have_breakout.append({sno: breakout})
39513956

39523957
def dcnm_intf_get_have_all(self, sw):
@@ -5812,22 +5817,26 @@ def dcnm_intf_update_inventory_data(self):
58125817

58135818
if self.module.params["state"] != "query":
58145819

5815-
# Get all switches which are managable. Changes must be avoided to all switches which are not part of this list
5816-
managable_ip = [
5817-
(key, self.inventory_data[key]["serialNumber"])
5818-
for key in self.inventory_data
5819-
if str(self.inventory_data[key]["managable"]).lower() == "true"
5820-
]
5821-
managable_hosts = [
5822-
(
5823-
self.inventory_data[key]["logicalName"],
5824-
self.inventory_data[key]["serialNumber"],
5825-
)
5826-
for key in self.inventory_data
5827-
if str(self.inventory_data[key]["managable"]).lower() == "true"
5828-
]
5820+
# Get all switches which are manageable and unmanageable
5821+
manageable_ip = []
5822+
manageable_hosts = []
5823+
unmanageable_ip = []
5824+
unmanageable_hosts = []
5825+
5826+
for key in self.inventory_data:
5827+
serial_number = self.inventory_data[key]["serialNumber"]
5828+
logical_name = self.inventory_data[key]["logicalName"]
5829+
is_manageable = str(self.inventory_data[key]["managable"]).lower() == "true"
5830+
5831+
if is_manageable:
5832+
manageable_ip.append((key, serial_number))
5833+
manageable_hosts.append((logical_name, serial_number))
5834+
else:
5835+
unmanageable_ip.append((key, serial_number))
5836+
unmanageable_hosts.append((logical_name, serial_number))
58295837

5830-
managable = dict(managable_ip + managable_hosts)
5838+
self.manageable = dict(manageable_ip + manageable_hosts)
5839+
self.unmanageable = dict(unmanageable_ip + unmanageable_hosts)
58315840

58325841
# Build a mapping of serial numbers to switch roles. This will be required to build default ethernet
58335842
# payload during overridden state. for switch role leaf the default policy for ethernet interface must
@@ -5842,13 +5851,13 @@ def dcnm_intf_update_inventory_data(self):
58425851
}
58435852
)
58445853

5845-
# Get all switches which are managable. Deploy must be avoided to all switches which are not part of this list
5854+
# Get all switches which are manageable. Deploy must be avoided to all switches which are not part of this list
58465855
ronly_sw_list = []
58475856
for cfg in self.config:
5848-
# Check if there are any switches which are not managable in the config.
5857+
# Check if there are any switches which are not manageable in the config.
58495858
if cfg.get("switch", None) is not None:
58505859
for sw in cfg["switch"]:
5851-
if sw not in managable:
5860+
if sw not in self.manageable:
58525861
if sw not in ronly_sw_list:
58535862
ronly_sw_list.append(sw)
58545863

0 commit comments

Comments
 (0)