def preprocess_request_data(request_data): ''' :param request_data: :return:business,ips 将request_data进行预处理,生成business和ips,business是必须的,ips可以为空 如果ips为空,就是全景图;如果ips不是空,则为收敛图 ''' business = '' ips = [] left_business = request_data['left_business'] if 'left_business' in request_data else None right_business = request_data['right_business'] if 'right_business' in request_data else None center_business = request_data['services_name'] if 'services_name' in request_data else None center_inst = request_data['center_inst'] if 'center_inst' in request_data else None try: center_ips = eval(request_data['center_ips']) except: center_ips = [] print '**',type(center_ips) if center_inst is None: if left_business is None and right_business is None: business = center_business elif left_business is None and right_business is not None: business = right_business elif left_business is not None and right_business is None: business = left_business else: if len(center_ips) == 0: if left_business is None and right_business is not None: business = right_business ips = model_ora.get_ip_accord_business_instance('target', center_business, right_business, center_inst) elif left_business is not None and right_business is None: business = left_business ips = model_ora.get_ip_accord_business_instance('source', center_business, left_business, center_inst) else: if left_business is None and right_business is not None: print '&&&&&&&&&&&&&' business = right_business ips = model_ora.get_ip_accord_business_instance_ips('target', center_business, right_business, center_inst, center_ips) print ips elif left_business is not None and right_business is None: business = left_business ips = model_ora.get_ip_accord_business_instance_ips('source', center_business, left_business, center_inst, center_ips) return business, ips
def preprocess_request_data(request_data): business = '' ips = [] left_business = request_data['left_business'] if 'left_business' in request_data else None right_business = request_data['right_business'] if 'right_business' in request_data else None center_business = request_data['services_name'] if 'services_name' in request_data else None center_inst = request_data['center_inst'] if 'center_inst' in request_data else None try: center_ips = eval(request_data['center_ips']) except: center_ips = [] print '______________________________' print 'left_business',left_business print 'right_business',right_business print 'center_ips',center_ips,type(center_ips) print 'center_business',center_business print 'center_inst',center_inst print '______________________________' if center_inst is None: if left_business is None and right_business is None: business = center_business elif left_business is None and right_business is not None: business = right_business elif left_business is not None and right_business is None: business = left_business else: if len(center_ips) == 0: if left_business is None and right_business is not None: business = right_business ips = model_ora.get_ip_accord_business_instance('target', center_business, right_business, center_inst) elif left_business is not None and right_business is None: business = left_business ips = model_ora.get_ip_accord_business_instance('source', center_business, left_business, center_inst) else: if left_business is None and right_business is not None: business = right_business ips = model_ora.get_ip_accord_business_instance_ips('target', center_business, right_business, center_inst, center_ips) elif left_business is not None and right_business is None: business = left_business ips = model_ora.get_ip_accord_business_instance_ips('source', center_business, left_business, center_inst, center_ips) return business, ips
}) elif request_type == 'business_ip': business_center, instance_center = None, None business = request_data['services_name'] relation_type = request_data['relation_type'] center_ips = request_data['center_ips'] if 'center_ips' in request_data else None if relation_type[1] == '1': direction = 'source' elif relation_type[1] == '2': direction = 'target' if relation_type[0] == '1': business_center = request_data['relation_name'] elif relation_type[0] == '2': instance_center = request_data['relation_name'] try: ip_list = model_ora.get_ip_accord_business_instance(direction, business_center, business, instance_center) ip_infos = [dict(zip(['ip_address', 'oop_name'], item)) for item in ip_list] response.update({ 'data': { 'ip_list': ip_infos }, 'result': 'success', 'services_name': business_center, 'message': 'OK' }) except Exception, e: print e.message response.update({ 'result': 'fail', 'services_name': business_center,