update ospf modules to fix bugs as software version changes (#56974)

This commit is contained in:
xuxiaowei0512 2019-05-30 00:40:31 +08:00 committed by Nathaniel Case
parent 0137c4343b
commit b7f4e2a190
2 changed files with 14 additions and 13 deletions

View file

@ -442,7 +442,7 @@ class OSPF(object):
# get process base info
root = ElementTree.fromstring(xml_str)
ospfsite = root.find("data/ospfv2/ospfv2comm/ospfSites/ospfSite")
ospfsite = root.find("ospfv2/ospfv2comm/ospfSites/ospfSite")
if ospfsite:
for site in ospfsite:
if site.tag in ["processId", "routerId", "vrfName"]:
@ -450,7 +450,7 @@ class OSPF(object):
# get Topology info
topo = root.find(
"data/ospfv2/ospfv2comm/ospfSites/ospfSite/ProcessTopologys/ProcessTopology")
"ospfv2/ospfv2comm/ospfSites/ospfSite/ProcessTopologys/ProcessTopology")
if topo:
for eles in topo:
if eles.tag in ["maxLoadBalancing"]:
@ -459,7 +459,7 @@ class OSPF(object):
# get nexthop info
ospf_info["nexthops"] = list()
nexthops = root.findall(
"data/ospfv2/ospfv2comm/ospfSites/ospfSite/ProcessTopologys/ProcessTopology/nexthopMTs/nexthopMT")
"ospfv2/ospfv2comm/ospfSites/ospfSite/ProcessTopologys/ProcessTopology/nexthopMTs/nexthopMT")
if nexthops:
for nexthop in nexthops:
nh_dict = dict()
@ -471,7 +471,7 @@ class OSPF(object):
# get areas info
ospf_info["areas"] = list()
areas = root.findall(
"data/ospfv2/ospfv2comm/ospfSites/ospfSite/areas/area")
"ospfv2/ospfv2comm/ospfSites/ospfSite/areas/area")
if areas:
for area in areas:
area_dict = dict()
@ -490,15 +490,12 @@ class OSPF(object):
area_dict["networks"].append(net_dict)
ospf_info["areas"].append(area_dict)
return ospf_info
def is_area_exist(self):
"""is ospf area exist"""
if not self.ospf_info:
return False
for area in self.ospf_info["areas"]:
if area["areaId"] == self.get_area_ip():
return True
@ -507,7 +504,6 @@ class OSPF(object):
def is_network_exist(self):
"""is ospf area network exist"""
if not self.ospf_info:
return False
@ -528,7 +524,6 @@ class OSPF(object):
if not self.ospf_info:
return False
for nexthop in self.ospf_info["nexthops"]:
if nexthop["ipAddress"] == self.nexthop_addr:
return True
@ -537,7 +532,6 @@ class OSPF(object):
def is_nexthop_change(self):
"""is ospf nexthop change"""
if not self.ospf_info:
return True
@ -555,6 +549,8 @@ class OSPF(object):
xml_area = ""
self.updates_cmd.append("ospf %s" % self.process_id)
xml_create = CE_NC_CREATE_PROCESS % self.process_id
set_nc_config(self.module, xml_create)
# nexthop weight
xml_nh = ""
@ -607,7 +603,7 @@ class OSPF(object):
self.updates_cmd.pop()
self.updates_cmd.append(
"authentication-mode %s %s %s" % (self.auth_mode, self.auth_key_id, self.auth_text_md5))
if xml_network or xml_auth:
if xml_network or xml_auth or not self.is_area_exist():
xml_area += CE_NC_XML_BUILD_MERGE_AREA % (
self.get_area_ip(), xml_network + xml_auth)
@ -884,6 +880,7 @@ class OSPF(object):
"""get end state info"""
ospf_info = self.get_ospf_dict(self.process_id)
if not ospf_info:
return
@ -892,6 +889,9 @@ class OSPF(object):
self.end_state["nexthops"] = ospf_info["nexthops"]
self.end_state["max_load_balance"] = ospf_info.get("maxLoadBalancing")
if self.end_state == self.existing:
self.changed = False
def work(self):
"""worker"""

View file

@ -1047,7 +1047,7 @@ class OspfVrf(object):
# get the vpn address family and RD text
ospf_sites = root.findall(
"data/ospfv2/ospfv2comm/ospfSites/ospfSite")
"ospfv2/ospfv2comm/ospfSites/ospfSite")
if ospf_sites:
for ospf_site in ospf_sites:
ospf_ele_info = dict()
@ -1063,7 +1063,8 @@ class OspfVrf(object):
"spfScheduleIntervalType"]:
ospf_ele_info[
ospf_site_ele.tag] = ospf_site_ele.text
self.ospf_info["ospfsite"].append(ospf_ele_info)
if ospf_ele_info["processId"] == self.ospf:
self.ospf_info["ospfsite"].append(ospf_ele_info)
def get_proposed(self):
"""get proposed info"""