Ejemplo n.º 1
0
def init_overlay_table():
	# Initialize the video cache table first
	# init_cache_table()
	

	# Delete all objects in the table
	existing_srvs = Server.objects.all()
	if existing_srvs.count() > 0:
		existing_srvs.delete()
	cache_srv_ips = get_cache_agents()
	print(cache_srv_ips)
	if not cache_srv_ips:
		return False
	hostname = get_host_name()
	print("Obtained cache_srv_ips are", cache_srv_ips)
	print("Current host name is :", hostname)
	for srv in cache_srv_ips.keys():
		srv_id = int(re.findall(r'\d+', srv)[0])
		srv_name = srv
		srv_ip = cache_srv_ips[srv]
		srv_rtt = getMnRTT(srv_ip, 5)
		srv_sqs = 4.00
		srv_load = 0
		srv_bw = 0.00
		isLocal = (srv == hostname)
		if isLocal:
			srv_rtt = 0.0
			srv_sqs = 5.00
		cur_srv = Server(id=srv_id, name=srv_name, ip=srv_ip, isLocal=isLocal, rtt=srv_rtt, ave_sqs=srv_sqs, exp_sqs=srv_sqs, load=srv_load, bw=srv_bw)
		cur_srv.save()
		print(srv_name, " is saved in the database!")
	
	# Initialize the qoe table
	initializeQoE()
	return True
Ejemplo n.º 2
0
def add_srv(node_name):
	if not Server.objects.filter(name=node_name).exists():
		hostname = get_host_name()
		srv_id = int(re.findall(r'\d+', node_name)[0])
		srv_name = node_name
		srv_ip = get_node_ip(node_name)
		srv_rtt = getMnRTT(srv_ip, 5)
		ave_sqs = 4.00
		exp_sqs = 4.00
		srv_load = 0
		srv_bw = 0.00
		isLocal = (node_name == hostname)
		if isLocal:
			srv_rtt = 0.0
			ave_sqs = 5.00
			exp_sqs = 5.00
		cur_srv = Server(id=srv_id, name=srv_name, ip=srv_ip, isLocal=isLocal, rtt=srv_rtt, qoe=srv_qoe, load=srv_load, bw=srv_bw)
		cur_srv.save()
	print(node_name, " is saved in the database!")