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

pull/57139/head
xuxiaowei0512 6 years ago committed by Nathaniel Case
parent 0137c4343b
commit b7f4e2a190

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

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

Loading…
Cancel
Save