Skip to content
Snippets Groups Projects
Commit 4134a52a authored by Rajmund Hruška's avatar Rajmund Hruška
Browse files

Fix: Compare networks using ipranges. (Redmine issue: #7603)

parent 595f19b6
No related branches found
No related tags found
No related merge requests found
...@@ -650,14 +650,15 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript): ...@@ -650,14 +650,15 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
:return: index of network :return: index of network
:rtype: int :rtype: int
""" """
if isinstance(network, NetworkModel): network = network if isinstance(network, NetworkModel) else networkmodel_from_typeddict(network)
for index, net in enumerate(netlist): for index, net in enumerate(netlist):
if network.network == net['network'] and (('netname' in net and network.netname == net['netname']) or network.source == net['source']): net = net if isinstance(net, NetworkModel) else networkmodel_from_typeddict(net)
return index # Convert to ipranges object so ranges and CIDRs can be compared.
else: # e.g. 195.113.220.80-195.113.220.95 should be equal to 195.113.220.80/28
for index, net in enumerate(netlist): iprange_net = mentat.datatype.internal.t_net(net.network)
if net.network == network['network'] and (('netname' in network and net.netname == network['netname']) or net.source == network['source']): iprange_network = mentat.datatype.internal.t_net(network.network)
return index if iprange_net == iprange_network and (net.netname == network.netname or net.source == network.source):
return index
return -1 return -1
@staticmethod @staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment