def run_spf_avoid_color(graph_nodes,src_node,dst_node,color_exc_inc,color,metric): src_node_id =dboperations.Query_node_id(src_node) dst_node_id =dboperations.Query_node_id(dst_node) return spf(graph_nodes,src_node_id,dst_node_id,metric,color=color,color_exc_inc=color_exc_inc)
def run_spf(graph_nodes,src_node,dst_node,metric): src_node_id =dboperations.Query_node_id(src_node) dst_node_id =dboperations.Query_node_id(dst_node) return spf(graph_nodes,src_node_id,dst_node_id,metric)
def run_spf_avoid_node(graph_nodes,src_node,dst_node,avoid_node,metric): src_node_id =dboperations.Query_node_id(src_node) dst_node_id =dboperations.Query_node_id(dst_node) avoid_node_id = dboperations.Query_node_id(avoid_node) return spf(graph_nodes,src_node_id,dst_node_id,metric,avoid_node=avoid_node_id)
def pcep_interface(path_list,graph_nodes,sr_te): server_port = "50000" #server_port = "50001" #server_context=zmq.Context() #server_socket = self.server_context.socket(zmq.REP) #server_socket.bind("tcp://*:%s" % self.server_port) client_context=zmq.Context() client_socket=client_context.socket(zmq.REQ) client_socket.connect("tcp://localhost:%s" %server_port) #print ("Path List",path_list) PCEP_MSG = {} ERO_LIST = [] SR_ERO_LIST = [] LSPA_Object = {"Hold_Priority":6,"Setup_Priority": 6,"FRR_Desired": 0} EndPointObject = {"Tunnel_Source":dboperations.Query_node_ip(path_list[0]),"Tunnel_Destination":dboperations.Query_node_ip(path_list[-1])} SR_TE=sr_te ''' for node in path_list[1:]: node_ip,node_sid = dboperations.Query_node_ip_sid(node) SR_ERO_LIST.append({node_ip:node_sid}) ERO_LIST.append({node_ip:0}) ''' for i in range(0,len(path_list)-1): edgeNodeA = dboperations.Query_node_id(path_list[i]) edgeNodeB = dboperations.Query_node_id(path_list[i+1]) attrAB = graph_nodes.get_edge_data(edgeNodeA,edgeNodeB) remote_ip = attrAB[(edgeNodeA,edgeNodeB)].get('remote_ip',0) adj_sid = attrAB[(edgeNodeA,edgeNodeB)].get('adj_sid_label',0) SR_ERO_LIST.append({remote_ip:adj_sid}) ERO_LIST.append({remote_ip:0}) try: Node_Tunnel_Tracker.head_ends[path_list[0]] tunnel_id= (next(Node_Tunnel_Tracker.head_ends[path_list[0]].gen_stat)) except KeyError: Node_Tunnel_Tracker.create(path_list[0]) Node_Tunnel_Tracker.head_ends[path_list[0]].gen_stat = Node_Tunnel_Tracker.head_ends[path_list[0]].tunnel_nu() tunnel_id= (next(Node_Tunnel_Tracker.head_ends[path_list[0]].gen_stat)) except e: print ("Exception Occured %s" %str(e)) #TunnelName = 'auto'+'_'+path_list[0]+"_"+str(tunnel_id) TunnelName = str(str(path_list[0])+"_"+str(tunnel_id)) PCEP_MSG['TunnelName'] = TunnelName PCEP_MSG['SR-TE'] = SR_TE PCEP_MSG['EndPointObject']=EndPointObject PCEP_MSG['LSPA_Object'] = LSPA_Object PCEP_MSG['SR_ERO_LIST']=SR_ERO_LIST PCEP_MSG['ERO_LIST']=ERO_LIST print("ERO LIST: ",PCEP_MSG['ERO_LIST']) json_obj = json.dumps(PCEP_MSG) parsed_result= parse_pce_pcep_msg(json_obj) headend_ip = dboperations.Query_node_ip(path_list[0]) #print ("Parsed Results for Headend",headend_ip,parsed_result) headend_ip_long=headend_ip final_msg = (headend_ip,parsed_result) serialize_parsed_result=pickle.dumps(final_msg,3) publish_to_pcep(headend_ip_long,final_msg)