def demo_create(filename='ovs.xml'): #测试使用,正式版删除 # ip_start={ # "start":"10.0.0.0" # } mongo = mongodb.mongo_opreate() mongo.save_tpl_dic(ip_start, "ip_start") #建立对象 test = ip_distribution.ip_distribution() example = scheduler.scheduler() #获取列表 list_ovs, list_relation = resolve_xml_ovs.get_xml_ovs(filename) list_host = resolve_xml_ovs.get_xml_host_conf() list_ovs_new = test.distribution_ovs(list_ovs) operation, list_ovs_new_new, ovs_link = example.docker_scheduler( list_ovs_new, list_host, list_relation) #构建任务字典 task_list = { "id": srand(), "ovs_link": list_relation, "ovs_tube_link": ovs_link, "ovs_list": list_ovs_new_new, "host_list": list_host, "operate": operation, "state": "" } return task_list
def demo_create(filename='ovs.xml'): #测试使用,正式版删除 # ip_start={ # "start":"10.0.0.0" # } mongo=mongodb.mongo_opreate() mongo.save_tpl_dic(ip_start,"ip_start") #建立对象 test=ip_distribution.ip_distribution() example=scheduler.scheduler() #获取列表 list_ovs,list_relation=resolve_xml_ovs.get_xml_ovs(filename) list_host=resolve_xml_ovs.get_xml_host_conf() list_ovs_new=test.distribution_ovs(list_ovs) operation,list_ovs_new_new,ovs_link=example.docker_scheduler(list_ovs_new,list_host,list_relation) #构建任务字典 task_list={ "id":srand(), "ovs_link":list_relation, "ovs_tube_link":ovs_link, "ovs_list":list_ovs_new_new, "host_list":list_host, "operate":operation, "state":"" } return task_list
def demo_create(): #建立对象 test=ip_distribution.ip_distribution() example=scheduler.scheduler() #获取列表 list_ovs,list_relation=resolve_xml_ovs.get_xml_ovs() list_host=resolve_xml_ovs.get_xml_host_conf() list_ovs_new=test.distribution_ovs(list_ovs) operation,list_ovs_new_new,ovs_link=example.docker_scheduler(list_ovs_new,list_host,list_relation) #构建任务字典 task_list={ "id":srand(), "ovs_link":list_relation, "ovs_tube_link":ovs_link, "ovs_list":list_ovs_new_new, "host_list":list_host, "operate":operation, "state":"" } return task_list
# ovs["OVS_IP"]=start_ip_ovs # ovs["OVS_Start_Ip"]=start_ip_ovs # ovs["OVS_End_Ip"]=end_ip_ovs # ovs["OVS_Mask"]=mask_ovs # ovs["OVS_BroadCast"]=end_ip_ovs # else: # start_ip_ovs,end_ip_ovs,mask_ovs,next_ip=self.distribution_subnet(next_ip,10) # ovs["OVS_IP"]=start_ip_ovs # ovs["OVS_Start_Ip"]=start_ip_ovs # ovs["OVS_End_Ip"]=end_ip_ovs # ovs["OVS_Mask"]=mask_ovs # ovs["OVS_BroadCast"]=end_ip_ovs # list_result.append(ovs) # return list_result if __name__ == '__main__': ip_start={ "start":"10.0.0.0" } mongo=mongodb.mongo_opreate() mongo.save_tpl_dic(ip_start,"ip_start") test=ip_distribution() list_ovs,list_relation=resolve_xml_ovs.get_xml_ovs() print test.distribution_ovs(list_ovs)
''' def docker_scheduler(self, ovs_list, host_list, list_relation): create_list = [] ovs_lists = [] for ovs in ovs_list: create = { "host": host_list[0]["ip"], "version": host_list[0]["docker_version"], "create_num": ovs["OVS_Docker_Num"], #创建个数 'start_ip': ovs["OVS_Start_Ip"], 'end_ip': ovs["OVS_End_Ip"], 'mask': ovs["OVS_Mask"], "name_pro": ovs["OVS_ID"], #待创建容器前缀名 "image": ovs["OVS_Image"], #选择镜像名称或id "ovs_id": ovs["OVS_ID"], } ovs['OVS_HOST_IP'] = host_list[0]["ip"] create_list.append(create) ovs_lists.append(ovs) operation = {"type": "create", "operation": create_list} return operation, ovs_lists, [] if __name__ == '__main__': import resolve_xml_ovs example = scheduler() list_ovs, list_relation = resolve_xml_ovs.get_xml_ovs() list_host = resolve_xml_ovs.get_xml_host_conf() print example.docker_scheduler(list_ovs, list_host, list_relation)