@@ -27,9 +27,9 @@ def update_jms_ecs(jms_url,headers,new_node_dict,node_id,cloud,account,ecs_info,
2727 ecs_url = f"{ jms_url } /api/v1/assets/assets/"
2828 reget_ecs_list = requests .request ("GET" , f'{ ecs_url } ?node={ node_id } ' , headers = headers ).json ()
2929 try :
30- jms_ecs_dict = {i [ 'ip' ] :{'name' :i [ 'hostname' ] ,'id' :i ['id' ],'comment' :i ['comment' ],'node' :i ['nodes_display' ][0 ]} for i in reget_ecs_list }
30+ jms_ecs_dict = {i . get ( 'ip' , i . get ( 'address' , 'IPNOTFOUND' )) :{'name' :i . get ( 'hostname' , i . get ( 'name' , 'NAMENOTFOUND' )) ,'id' :i ['id' ],'comment' :i ['comment' ],'node' :i ['nodes_display' ][0 ]} for i in reget_ecs_list }
3131 except :
32- jms_ecs_dict = {i [ 'ip' ] :{'name' :i [ 'hostname' ] ,'id' :i ['id' ],'comment' :i ['comment' ],'node' :i ['nodes' ][0 ]} for i in reget_ecs_list }
32+ jms_ecs_dict = {i . get ( 'ip' , i . get ( 'address' , 'IPNOTFOUND' )) :{'name' :i . get ( 'hostname' , i . get ( 'name' , 'NAMENOTFOUND' )) ,'id' :i ['id' ],'comment' :i ['comment' ],'node' :i ['nodes' ][0 ]} for i in reget_ecs_list }
3333
3434 ecs_list = consul_manager .get_instances (f'{ cloud } _{ account } _ecs' )['instances' ]
3535 ecs_ip_dict = {i ['address' ]:i ['meta' ][0 ]['name' ] for i in ecs_list }
@@ -59,6 +59,8 @@ def update_jms_ecs(jms_url,headers,new_node_dict,node_id,cloud,account,ecs_info,
5959 payload = {
6060 "ip" : ip ,
6161 "hostname" : iname ,
62+ "address" : ip ,
63+ "name" : iname ,
6264 "protocols" : protocols ,
6365 "platform" : platform ,
6466 "is_active" : True ,
@@ -88,11 +90,11 @@ def del_jms_repip(jms_url,headers,node_id,ecs_ip_dict):
8890 rep_jmsecs_list = []
8991 new_jms_list = requests .request ("GET" , f'{ ecs_url } ?node={ node_id } ' , headers = headers ).json ()
9092 for i in new_jms_list :
91- if i [ 'ip' ] not in temp_jmsecs_dict :
92- temp_jmsecs_dict [i [ 'ip' ]] = {'name' :i [ 'hostname' ], ' id' :i ['id' ],'ip' :i [ 'ip' ] }
93+ if i . get ( 'ip' , i . get ( 'address' , 'IPNOTFOUND' )) not in temp_jmsecs_dict :
94+ temp_jmsecs_dict [i . get ( 'ip' , i . get ( 'address' , 'IPNOTFOUND' ))] = {'name' :i . get ( 'hostname' , i . get ( 'name' , 'NAMENOTFOUND' )), ' id' :i ['id' ],'ip' :i . get ( 'ip' , i . get ( 'address' , 'IPNOTFOUND' )) }
9395 else :
94- rep_jmsecs_list .append (temp_jmsecs_dict [i [ 'ip' ] ])
95- rep_jmsecs_list .append ({'name' :i [ 'hostname' ], ' id' :i ['id' ],'ip' :i [ 'ip' ] })
96+ rep_jmsecs_list .append (temp_jmsecs_dict [i . get ( 'ip' , i . get ( 'address' , 'IPNOTFOUND' )) ])
97+ rep_jmsecs_list .append ({'name' :i . get ( 'hostname' , i . get ( 'name' , 'NAMENOTFOUND' )), ' id' :i ['id' ],'ip' :i . get ( 'ip' , i . get ( 'address' , 'IPNOTFOUND' )) })
9698
9799 for j in rep_jmsecs_list :
98100 if j ['name' ] != ecs_ip_dict .get (j ['ip' ]):
0 commit comments