Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
 def __init__(self):
     self.ip_solve = ip_distribution.ip_distribution()
     self.mongo = mongodb.mongo_opreate()
Ejemplo n.º 5
0
 def __init__(self):
     self.ip_solve = ip_distribution.ip_distribution(types=False)
     self.mongo = mongodb.mongo_opreate()
Ejemplo n.º 6
0
		return post_id




	'''
	@功能:读取操作
	'''
	def display_tpl(self,table):
		data=self.client.ovs[table]
		return [post for post in data.find({})]

	def display_tpl_condition(self,table,condition):
		data=self.client.ovs[table]
		return [post for post in data.find(condition)]



	def del_tpl(self,table,condition):
		data=self.client.ovs[table]
		data.delete_many(condition)

		

if __name__ == '__main__':
	mongo=mongo_opreate()
	list_ovs,list_relation=resolve_xml_ovs.get_xml_ovs()
	test=ip_distribution.ip_distribution()
	lists=test.distribution_ovs("10.0.0.0",list_ovs)
	print mongo.save_ovs_link(list_relation)
Ejemplo n.º 7
0
            return data_list

    def save_tpl_dic(self, data_dic, table):
        data = self.client.ovs[table]
        post_id = data.insert_one(data_dic).inserted_id
        return post_id

    '''
	@功能:读取操作
	'''

    def display_tpl(self, table):
        data = self.client.ovs[table]
        return [post for post in data.find({})]

    def display_tpl_condition(self, table, condition):
        data = self.client.ovs[table]
        return [post for post in data.find(condition)]

    def del_tpl(self, table, condition):
        data = self.client.ovs[table]
        data.delete_many(condition)


if __name__ == '__main__':
    mongo = mongo_opreate()
    list_ovs, list_relation = resolve_xml_ovs.get_xml_ovs()
    test = ip_distribution.ip_distribution()
    lists = test.distribution_ovs("10.0.0.0", list_ovs)
    print mongo.save_ovs_link(list_relation)