def add_link(request):
	url = request.get_full_path()
	params = url.split('?')[1]
	update_dict = urllib.parse.parse_qs(params)
	if 'src' in update_dict.keys():
		src_client = update_dict['src'][0]
		num_rsts = client.objects.filter(name=src_client).count()
		if num_rsts < 1:
			src_client_ip = socket.gethostbyaddr(src_client)[0]
			new_client = client(name=src_client, ip=src_client_ip)
			new_client.save()
		src_client_id = client.objects.filter(name=src_client)[0].id
		if 'pdst' in update_dict.keys():
			dst_client = update_dict['pdst'][0]
			num_rsts = client.objects.filter(name=dst_client).count()
			if num_rsts < 1:
				dst_client_ip = socket.gethostbyaddr(dst_client)[0]
				new_client = client(name=dst_client, ip=dst_client_ip)
				new_client.save()
			dst_client_id = client.objects.filter(name=dst_client)[0].id
			plink = link(src=src_client, src_id=src_client_id, dst=dst_client, dst_id=dst_client_id, link_type=0)
			plink.save()
		if 'vdst' in update_dict.keys():
			dst_client = update_dict['vdst'][0]
			num_rsts = client.objects.filter(name=dst_client).count()
			if num_rsts < 1:
				dst_client_ip = socket.gethostbyaddr(dst_client)[0]
				new_client = client(name=dst_client, ip=dst_client_ip)
				new_client.save()
			dst_client_id = client.objects.filter(name=dst_client)[0].id
			vlink = link(src=src_client, src_id=src_client_id, dst=dst_client, dst_id=dst_client_id, link_type=1)
			vlink.save()
		response = HttpResponse("Successfully add links for source client: " + src_client)
	else:
		response = HttpResponse("An monitor/edge? request needs to concatenate with src=src_name&pdst=pdst_name&vdst=vdst_name!!")
	return response
def add(request):
	client_ip = request.META['REMOTE_ADDR']
	url = request.get_full_path()
	if '?' in url:
		client_name = url.split('?')[1]
	else:
		client_name = request.META['REMOTE_HOST']
	num_results = client.objects.filter(ip=client_ip).count()
	if num_results > 0:
		cur_client = client.objects.filter(ip=client_ip)[0]
		cur_client.name = client_name
	else:
		cur_client = client(name=client_name, ip=client_ip)
	cur_client.save()
	# Return successfully added response
	response = HttpResponse("Successfully add/update client: " + client_name)
	return response