Esempio n. 1
0
def reset_password(api, request, id):
    if request.method == 'POST':
        form = ConfirmForm(request.POST)
        if form.is_valid():
            passwd = ''.join(
                random.choice(2 * string.ascii_lowercase +
                              string.ascii_uppercase + 2 * string.digits)
                for x in range(12))
            api.account_modify(id, {"password": passwd})
            api.account_mail(
                id,
                subject="Password reset",
                message=
                "Your password has been reset by an administrator to\n\n\t%s\n\nPlease login using that password and change it to something you can remember."
                % passwd,
                from_support=True)
            return HttpResponseRedirect(
                reverse("tomato.account.info", kwargs={"id": id}))
    form = ConfirmForm.build(
        reverse("tomato.account.reset_password", kwargs={"id": id}))
    return render(
        request, "form.html", {
            "heading":
            "Reset Password",
            "message_before":
            "Are you sure you want to reset the password of the account '" +
            id + "'?",
            'form':
            form
        })
Esempio n. 2
0
def reset_password(api, request, id):
	if request.method == 'POST':
		form = ConfirmForm(request.POST)
		if form.is_valid():
			passwd = ''.join(random.choice(2 * string.ascii_lowercase + string.ascii_uppercase + 2 * string.digits) for x in range(12))
			api.account_modify(id, {"password": passwd})
			api.account_send_notification(id, subject="Password reset", message="Your password has been reset by an administrator to\n\n\t%s\n\nPlease login using that password and change it to something you can remember." % passwd, from_support=True)
			return HttpResponseRedirect(reverse("tomato.account.info", kwargs={"id": id}))
	form = ConfirmForm.build(reverse("tomato.account.reset_password", kwargs={"id": id}))
	return render(request, "form.html", {"heading": "Reset Password", "message_before": "Are you sure you want to reset the password of the account '"+id+"'?", 'form': form})	
Esempio n. 3
0
def start(api, request):
	url = request.REQUEST["url"]
	session_id = request.session.get("id", uuid.uuid4())
	token = request.REQUEST.get("token")
	correct_token = security_token(url, session_id)
	if token != correct_token:
		request.session["id"] = session_id
		form = ConfirmForm.build(reverse("tomato.tutorial.start")+"?"+urllib.urlencode({"token": correct_token, "url": url}))
		return render(request, "form.html", {"heading": "Load tutorial", "message_before": "Are you sure you want to load the tutorial from the following URL? <pre>"+url+"</pre>", 'form': form})

	val = URLValidator()
	
	try: 
		val(url)
		data = json.load(urllib2.urlopen(url))
	except ValidationError:
		return render(request,"topology/tutorial_error.html",{"error_typ":"invalidurl", "error_msg":"Invalid url","url":url})
	except ValueError:
		return render(request,"topology/tutorial_error.html",{"error_typ":"invalidurl", "error_msg":"Invalid url","url":url})
	
	_, _, top_dict, data, _ = loadTutorial(url)
	top_dict['topology']['attrs']['_tutorial_state'] = {'enabled': True,
														'url': url,
													    'step': 0,
													    'data': data}
	top_id, _, _, _ = api.topology_import(top_dict)
	return redirect("tomato.topology.info", id=top_id)
Esempio n. 4
0
def deploy(api, request, id_=None):
    if request.method == 'POST':
        form = ConfirmForm(request.POST)
        if form.is_valid():
            api.scenario_deploy(id_)
            return HttpResponseRedirect(reverse("topology_list"))
    else:
        form = ConfirmForm.build(
            reverse("tomato.scenario.deploy", kwargs={"id_": id_}))
        response = api.scenario_info(id_)
        return render(
            request, "form.html", {
                "heading":
                "Deploy Scenario",
                "message_before":
                "Are you sure you want to deploy the scenario '" +
                response["name"] + "'?",
                "form":
                form
            })
Esempio n. 5
0
def start(api, request):
	url = request.REQUEST["url"]
	session_id = request.session.get("id", uuid.uuid4())
	token = request.REQUEST.get("token")
	correct_token = security_token(url, session_id)
	if token != correct_token:
		request.session["id"] = session_id
		form = ConfirmForm.build(reverse("tomato.tutorial.start")+"?"+urllib.urlencode({"token": correct_token, "url": url}))
		return render(request, "form.html", {"heading": _("Load tutorial"), "message_before": string_concat(_("Are you sure you want to load the tutorial from the following URL?"), "<pre>", url, "</pre>"), 'form': form})
	_, _, top_dict, data, _ = loadTutorial(url)
	top_dict['topology']['attrs']['_tutorial_state'] = {'enabled': True,
											'url': url,
											'step': 0,
											'data': data}
	top_id, _, _, _ = api.topology_import(top_dict)
	return redirect("tomato.topology.info", id=top_id)