def list(api, request, show_all=False, organization=None): if not api.user: raise AuthError() toplist = api.topology_list(showAll=show_all, organization=organization) orgas = api.organization_list() for top in toplist: """top['attrs']['tutorial_enabled'] = ( top['attrs'].has_key('_tutorial_url') and not ( top['attrs']['_tutorial_disabled'] if top['attrs'].has_key( '_tutorial_disabled') else False) # old tutorials ) or ( top['attrs']['_tutorial_state']['enabled'] if ( top['attrs'].has_key('_tutorial_state') and top['attrs'][ '_tutorial_state'].has_key('enabled')) else top['attrs'].has_key( '_tutorial_state') # new tutorials ) """ top["tutorial_enabled"] = top.has_key("_tutorial_state") and top["_tutorial_state"].get("enabled", False) top["processed"] = { "timeout_critical": top["timeout"] - time.time() < serverInfo()["topology_timeout"]["warning"] } return render( request, "topology/list.html", {"top_list": toplist, "organization": organization, "orgas": orgas, "show_all": show_all}, )
def _display(api, request, info, tutorial_state): caps = api.capabilities() res = api.resource_list() sites = api.site_list() permission_list = api.topology_permissions() orgas = dict([(o["name"], o) for o in api.organization_list()]) for s in sites: orga = orgas[s['organization']] del s['organization'] s['organization'] = orga tut_data, tut_steps, initscript = None, None, None try: if tutorial_state['url']: tut_data, tut_steps, _, _, initscript = loadTutorial( tutorial_state['url']) except: pass res = render( request, "topology/info.html", { 'top': info, 'timeout_settings': serverInfo()["topology_timeout"], 'res_json': json.dumps(res), 'sites_json': json.dumps(sites), 'caps_json': json.dumps(caps), 'tutorial_info': { 'state': tutorial_state, 'steps': tut_steps, 'data': tut_data, 'initscript': initscript }, 'permission_list': permission_list, }) return res
def list(api, request, show_all=False, organization=None): if not api.user: raise AuthError() toplist = api.topology_list(showAll=show_all, organization=organization) orgas = api.organization_list() for top in toplist: top['attrs']['tutorial_enabled'] = ( top['attrs'].has_key('_tutorial_url') and not (top['attrs']['_tutorial_disabled'] if top['attrs']. has_key('_tutorial_disabled') else False) #old tutorials ) or (top['attrs']['_tutorial_state']['enabled'] if (top['attrs'].has_key('_tutorial_state') and top['attrs']['_tutorial_state'].has_key('enabled')) else top['attrs'].has_key('_tutorial_state') #new tutorials ) top['processed'] = { 'timeout_critical': top['timeout'] - time.time() < serverInfo()['topology_timeout']['warning'] } return render( request, "topology/list.html", { 'top_list': toplist, 'organization': organization, 'orgas': orgas, 'show_all': show_all })
def _display(api, request, info, tutorial_state): caps = api.capabilities() res = api.resource_list() sites = api.site_list() permission_list = api.topology_permissions() show_all=False organization=None toplist=api.topology_list(showAll=show_all, organization=organization) orgas = dict([(o["name"], o) for o in api.organization_list()]) for s in sites: orga = orgas[s['organization']] del s['organization'] s['organization'] = orga tut_data, tut_steps, initscript = None, None, None try: if tutorial_state['url']: tut_data, tut_steps, _, _, initscript = loadTutorial(tutorial_state['url']) except: pass res = render(request, "topology/info.html", { 'to_list':toplist, 'top': info, 'timeout_settings': serverInfo()["topology_timeout"], 'res_json': json.dumps(res), 'sites_json': json.dumps(sites), 'caps_json': json.dumps(caps), 'tutorial_info':{'state': tutorial_state, 'steps':tut_steps, 'data': tut_data, 'initscript': initscript}, 'permission_list':permission_list, }) return res
def list(api, request, show_all=False, organization=None): if not api.user: raise AuthError() toplist=api.topology_list(showAll=show_all, organization=organization) paginator = Paginator(toplist,20) page_num = request.GET.get('page') try: toplist = paginator.page(page_num) except PageNotAnInteger: toplist = paginator.page(1) except EmptyPage: toplist = paginator.page(paginator.num_page) orgas=api.organization_list() tut_in_top_list = False for top in toplist: tut_in_top_list_old = tut_in_top_list if top['attrs'].has_key('_tutorial_url'): top['attrs']['tutorial_url'] = top['attrs']['_tutorial_url'] tut_in_top_list = True if top['attrs'].has_key('_tutorial_disabled'): top['attrs']['tutorial_disabled'] = top['attrs']['_tutorial_disabled'] if top['attrs']['tutorial_disabled']: tut_in_top_list = tut_in_top_list_old top['processed'] = {'timeout_critical': top['timeout'] - time.time() < serverInfo()['topology_timeout']['warning']} return render(request, "topology/list.html", {'top_list': toplist, 'organization': organization, 'orgas': orgas, 'show_all': show_all, 'tut_in_top_list':tut_in_top_list})
def __init__(self, api, data=None): AccountForm.__init__(self, api, data) self.fields["password"].required = True del self.fields["flags"] del self.fields["origin"] del self.fields["send_mail"] self.fields['aup'].label = 'I accept the <a href="' + serverInfo( )['external_urls'][ 'aup'] + '" target="_blank">acceptable use policy</a>' self.helper.form_action = reverse(register) self.helper.layout = Layout('name', 'password', 'password2', 'organization', 'realname', 'email', '_reason', 'aup', Buttons.cancel_save)
def _display(api, request, info, tutorial_state): caps = api.capabilities() resources = api.resources_map() sites = api.site_list() permission_list = role_descriptions() orgas = dict([(o["name"], o) for o in api.organization_list()]) for s in sites: orga = orgas[s['organization']] del s['organization'] s['organization'] = orga tut_data, tut_steps, initscript = None, None, None try: if tutorial_state['url']: tut_data, tut_steps, _, _, initscript = loadTutorial( tutorial_state['url']) except: pass editor_size_scale = 2 if ("_big_editor" in info and info['_big_editor']) else 1 editor_size = { 'width': int(800 * editor_size_scale), 'height': int(600 * editor_size_scale) } editor_size['marginleft'] = int((800 - editor_size['width']) / 2) res = render( request, "topology/info.html", { 'top': info, 'timeout_settings': serverInfo()["topology_timeout"], 'res_json': json.dumps(resources), 'res_web_json': json.dumps(web_resources()), 'sites_json': json.dumps(sites), 'caps_json': json.dumps(caps), 'tutorial_info': { 'state': tutorial_state, 'steps': tut_steps, 'data': tut_data, 'initscript': initscript }, 'permission_list': permission_list, 'editor': { 'size': editor_size }, 'vm_element_config': TypeTechTrans.TECH_DICT, 'tech_names': TechName.ONSCREEN }) return res
def _display(api, request, info, tutorial_state): caps = api.capabilities() resources = api.resources_map() sites = api.site_list() permission_list = role_descriptions() orgas = dict([(o["name"], o) for o in api.organization_list()]) for s in sites: orga = orgas[s['organization']] del s['organization'] s['organization'] = orga tut_data, tut_steps, initscript = None, None, None try: if tutorial_state['url']: tut_data, tut_steps, _, _, initscript = loadTutorial(tutorial_state['url']) except: pass editor_size_scale = 2 if ("_big_editor" in info and info['_big_editor']) else 1 editor_size = { 'width': int(800 * editor_size_scale), 'height':int(600 * editor_size_scale) } editor_size['marginleft'] = int( (800-editor_size['width']) / 2 ) res = render(request, "topology/info.html", { 'top': info, 'timeout_settings': serverInfo()["topology_timeout"], 'res_json': json.dumps(resources), 'res_web_json': json.dumps(web_resources()), 'sites_json': json.dumps(sites), 'caps_json': json.dumps(caps), 'tutorial_info': { 'state': tutorial_state, 'steps':tut_steps, 'data': tut_data, 'initscript': initscript }, 'permission_list': permission_list, 'editor': { 'size': editor_size }, 'vm_element_config': TypeTechTrans.TECH_DICT, 'tech_names': TechName.ONSCREEN }) return res
def __init__(self, api, data=None): AccountForm.__init__(self, api, data) self.fields["password"].required = True del self.fields["flags"] del self.fields["origin"] del self.fields["send_mail"] self.fields['aup'].label = 'I accept the <a href="'+ serverInfo()['external_urls']['aup'] +'" target="_blank">acceptable use policy</a>' self.helper.form_action = reverse(register) self.helper.layout = Layout( 'name', 'password', 'password2', 'organization', 'realname', 'email', '_reason', 'aup', Buttons.cancel_save )
def _display(api, request, info, tutorial_state): caps = api.capabilities() resources = api.resources_map() sites = api.site_list() permission_list = role_descriptions() orgas = dict([(o["name"], o) for o in api.organization_list()]) for s in sites: orga = orgas[s["organization"]] del s["organization"] s["organization"] = orga tut_data, tut_steps, initscript = None, None, None try: if tutorial_state["url"]: tut_data, tut_steps, _, _, initscript = loadTutorial(tutorial_state["url"]) except: pass editor_size_scale = 2 if ("_big_editor" in info and info["_big_editor"]) else 1 editor_size = {"width": int(800 * editor_size_scale), "height": int(600 * editor_size_scale)} editor_size["marginleft"] = int((800 - editor_size["width"]) / 2) res = render( request, "topology/info.html", { "top": info, "timeout_settings": serverInfo()["topology_timeout"], "res_json": json.dumps(resources), "res_web_json": json.dumps(web_resources()), "sites_json": json.dumps(sites), "caps_json": json.dumps(caps), "tutorial_info": {"state": tutorial_state, "steps": tut_steps, "data": tut_data, "initscript": initscript}, "permission_list": permission_list, "editor": {"size": editor_size}, }, ) return res
def list(api, request, show_all=False, organization=None): if not api.user: raise AuthError() toplist = api.topology_list(showAll=show_all, organization=organization) orgas = api.organization_list() for top in toplist: """top['attrs']['tutorial_enabled'] = ( top['attrs'].has_key('_tutorial_url') and not ( top['attrs']['_tutorial_disabled'] if top['attrs'].has_key( '_tutorial_disabled') else False) # old tutorials ) or ( top['attrs']['_tutorial_state']['enabled'] if ( top['attrs'].has_key('_tutorial_state') and top['attrs'][ '_tutorial_state'].has_key('enabled')) else top['attrs'].has_key( '_tutorial_state') # new tutorials ) """ top["tutorial_enabled"] = top.has_key('_tutorial_state') and \ top['_tutorial_state'].get('enabled', False) top['processed'] = { 'timeout_critical': top['timeout'] - time.time() < serverInfo()['topology_timeout']['warning']} return render(request, "topology/list.html", {'top_list': toplist, 'organization': organization, 'orgas': orgas, 'show_all': show_all})
def help_url(): return serverInfo()["external_urls"]['help']
def add(api, request, tech=None): message_after = '<h2>Tracker URL</h2> The torrent tracker of this backend is: <pre><tt>' + serverInfo( )["TEMPLATE_TRACKER_URL"] + '</tt></pre>' if request.method == 'POST': form = AddTemplateForm(request.POST, request.FILES) if form.is_valid(): formData = form.cleaned_data creation_date = formData['creation_date'] f = request.FILES['torrentfile'] torrent_data = base64.b64encode(f.read()) attrs = { 'label': formData['label'], 'subtype': formData['subtype'], 'preference': formData['preference'], 'restricted': formData['restricted'], 'torrent_data': torrent_data, 'description': formData['description'], 'nlXTP_installed': formData['nlXTP_installed'], 'creation_date': dateToTimestamp(creation_date) if creation_date else None, 'icon': formData['icon'], 'show_as_common': formData['show_as_common'] } if formData['tech'] == "kvmqm": attrs['kblang'] = formData['kblang'] res = api.template_create(formData['tech'], formData['name'], attrs) return HttpResponseRedirect( reverse("tomato.template.info", kwargs={"res_id": res["id"]})) else: return render( request, "form.html", { 'form': form, "heading": "Add Template", 'message_after': message_after }) else: form = AddTemplateForm() if tech: form.fields['tech'].initial = tech return render( request, "form.html", { 'form': form, "heading": "Add Template", 'hide_errors': True, 'message_after': message_after })
def add(api, request, tech=None): message_after = '<h2>Tracker URL</h2> The torrent tracker of this backend is: <pre><tt>'+serverInfo()["TEMPLATE_TRACKER_URL"]+'</tt></pre>' if request.method == 'POST': form = AddTemplateForm(request.POST, request.FILES) if form.is_valid(): formData = form.cleaned_data creation_date = formData['creation_date'] f = request.FILES['torrentfile'] torrent_data = base64.b64encode(f.read()) attrs = { 'label':formData['label'], 'subtype':formData['subtype'], 'preference':formData['preference'], 'restricted': formData['restricted'], 'torrent_data':torrent_data, 'description':formData['description'], 'nlXTP_installed':formData['nlXTP_installed'], 'creation_date':dateToTimestamp(creation_date) if creation_date else None, 'icon':formData['icon'], 'show_as_common':formData['show_as_common']} if formData['tech'] == "kvmqm": attrs['kblang'] = formData['kblang'] res = api.template_create(formData['tech'], formData['name'], attrs) return HttpResponseRedirect(reverse("tomato.template.info", kwargs={"res_id": res["id"]})) else: return render(request, "form.html", {'form': form, "heading":"Add Template", 'message_after':message_after}) else: form = AddTemplateForm() if tech: form.fields['tech'].initial = tech return render(request, "form.html", {'form': form, "heading":"Add Template", 'hide_errors':True, 'message_after':message_after})