def process_ignite(info): logger.debug("POAP Start") logger.debug("Info passed" + str(info)) # init result object result = {} result, match_response = match_info(result,info) # id is got from searched in Rules DB; remove this when that function is added #cfg_id = 3 file_name = build_config(match_response["CFG_ID"], match_response["FABRIC_ID"], match_response["SWITCH_ID"]) if file_name == None: result["err_msg"] = "Error in Config ID = " + str(match_response["CFG_ID"]) return result insert_deployed_fabric_stats(match_response, info["system_id"], file_name) result["status"] = True result["config_filename"] = file_name result["imagename"] = "6.1.2.I3.2" result["imageserver"] = "172.31.216.138" result["config_username"] = "******" result["config_password"] = "******" result["config_file_loc"] = os.getcwd() + "/repo/" logger.debug("Config file = " + file_name) logger.debug("POAP End") #clear_repo(result["config_file_loc"]) return result
def process_poap(info): logger.debug("POAP Start") logger.debug("Info passed" + str(info)) # init result object result = {} result["status"] = False result["err_msg"] = "" result["filename"] = "" # generate_collection_value(6,1,"arun") # first search in fabric specific ruledb match_response = match_fabric_rules(info) # if not found, search in global discovery ruledb cfg_id = match_response["CFG_ID"] fabric_id = match_response["FABRIC_ID"] switch_name = match_response["SWITCH_ID"] if cfg_id == INVALID: logger.error("No match in Fabric RuleDB") cfg_id = match_discovery_rules(info) if cfg_id == 0: logger.error("No match in Discovery RuleDB") result["err_msg"] = "Did not find matching rule" return result fabric_id = -1 switch_name = info['system_id'] logger.info("Matched Config ID =" + str(cfg_id)) # id is got from searched in Rules DB; remove this when that function is added #cfg_id = 3 file_name = build_config(cfg_id, fabric_id, switch_name) if file_name == None: result["err_msg"] = "Error in Config ID = " + str(cfg_id) return result result["status"] = True result["config_filename"] = file_name result["imagename"] = "6.1.2.I3.2" result["imageserver"] = "172.31.216.138" result["config_username"] = "******" result["config_password"] = "******" result["config_file_loc"] = os.getcwd() + "/repo/" logger.debug("Config file = " + file_name) logger.debug("POAP End") clear_repo(result["config_file_loc"]) return result
def process_ignite(info): logger.debug("POAP Start") logger.debug("Info passed" + str(info)) # init result object result = {} result, match_response = match_info(result, info) # id is got from searched in Rules DB; remove this when that function is added #cfg_id = 3 file_name = build_config(match_response["CFG_ID"], match_response["FABRIC_ID"], match_response["SWITCH_ID"]) if file_name == None: result["err_msg"] = "Error in Config ID = " + str( match_response["CFG_ID"]) return result insert_deployed_fabric_stats(match_response, info["system_id"], file_name) result["status"] = True result["config_filename"] = file_name result["imagename"] = "6.1.2.I3.2" result["imageserver"] = "172.31.216.138" result["config_username"] = "******" result["config_password"] = "******" result["config_file_loc"] = os.getcwd() + "/repo/" logger.debug("Config file = " + file_name) logger.debug("POAP End") #clear_repo(result["config_file_loc"]) return result
def process_ignite(info): logger.debug("POAP Start") logger.debug("Info passed" + str(info)) # init result object result = {} result, match_response = match_info(result,info) # id is got from searched in Rules DB; remove this when that function is added #cfg_id = 3 file_name = build_config(match_response["CFG_ID"], match_response["FABRIC_ID"], match_response["SWITCH_ID"]) if file_name == None: result["err_msg"] = "Error in Config ID = " + str(match_response["CFG_ID"]) return result insert_deployed_fabric_stats(match_response, info["system_id"], file_name) image_name = '' imageserver_ip = '' image_username = '' image_password = '' access_protocol = '' # Getting default values from json for img in image_obejcts: if img['image_profile_name'] == 'default_image': image_name = img['image'] imageserver_ip = img['imageserver_ip'] image_username = img['username'] image_password = img['password'] access_protocol = img['access_protocol'] # For Valid Fabric if match_response["FABRIC_ID"] != INVALID: fabric_obj = Fabric.objects.get(id = match_response["FABRIC_ID"]) img_detail = json.loads(fabric_obj.image_details) switch = match_response["SWITCH_ID"] topo_id = fabric_obj.topology.id topology_obj = Topology.objects.get(id=topo_id) topology = json.loads(topology_obj.topology_json) image = ' ' type = swtType(switch,topology, fabric_obj.name, match_response["REPLICA_NUM"]) image = img_detail[type] try: for detail in image_obejcts: if detail['image_profile_name'] == image: image_name = detail['image'] imageserver_ip = detail['imageserver_ip'] image_username = detail['username'] image_password = detail['password'] access_protocol = detail['access_protocol'] except: logger.error('Failed to read image details') # If anything fails, Providing Default(worst case) if image_name =='' or imageserver_ip=='' or image_username=='' or image_password=='' or access_protocol=='': image_name = "6.1.2.I3.2" imageserver_ip = "172.31.216.138" image_username = "******" image_password = "******" access_protocol = "scp" result = fillResult(result,file_name,image_name,imageserver_ip,image_username,image_password,access_protocol) #clear_repo(result["config_file_loc"]) return result
def process_ignite(info): logger.debug("POAP Start") logger.debug("Info passed" + str(info)) # init result object result = {} result, match_response = match_info(result, info) # id is got from searched in Rules DB; remove this when that function is added #cfg_id = 3 file_name = build_config(match_response["CFG_ID"], match_response["FABRIC_ID"], match_response["SWITCH_ID"]) if file_name == None: result["err_msg"] = "Error in Config ID = " + str( match_response["CFG_ID"]) return result insert_deployed_fabric_stats(match_response, info["system_id"], file_name) image_name = '' imageserver_ip = '' image_username = '' image_password = '' access_protocol = '' # Getting default values from json for img in image_objects: if img['image_profile_name'] == 'default_image': image_name = img['image'] imageserver_ip = img['imageserver_ip'] image_username = img['username'] image_password = img['password'] access_protocol = img['access_protocol'] # For Valid Fabric if match_response["FABRIC_ID"] != INVALID: fabric_obj = Fabric.objects.get(id=match_response["FABRIC_ID"]) img_detail = json.loads(fabric_obj.image_details) if bool(img_detail): switch = match_response["SWITCH_ID"] topo_id = fabric_obj.topology.id topology_obj = Topology.objects.get(id=topo_id) topology = json.loads(topology_obj.topology_json) image = ' ' type = swtType(switch, topology, fabric_obj.name, match_response["REPLICA_NUM"]) if type != INVALID: image = img_detail[type] try: for detail in image_objects: if detail['image_profile_name'] == image: image_name = detail['image'] imageserver_ip = detail['imageserver_ip'] image_username = detail['username'] image_password = detail['password'] access_protocol = detail['access_protocol'] except: logger.error('Failed to read image details') # If anything fails, Providing Default(worst case) if image_name == '' or imageserver_ip == '' or image_username == '' or image_password == '' or access_protocol == '': image_name = DEFAULT_SWITCH_IMAGE_NAME imageserver_ip = "172.31.216.138" image_username = "******" image_password = "******" access_protocol = "scp" result = fillResult(result, file_name, image_name, imageserver_ip, image_username, image_password, access_protocol) #clear_repo(result["config_file_loc"]) return result