From: Loic Baron Date: Tue, 7 Feb 2017 06:23:19 +0000 (+0100) Subject: Merge branch 'onelab' of git://git.onelab.eu/myslice into onelab X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=8a8188314dfa86c57180b88c1c76ce89ef7c0ed2;hp=ac4d50c6fff1af8a06fdccbad916cd8d4d2200d1 Merge branch 'onelab' of git://git.onelab.eu/myslice into onelab --- diff --git a/activity/__init__.py b/activity/__init__.py index be5779d9..d5b76fdb 100644 --- a/activity/__init__.py +++ b/activity/__init__.py @@ -67,12 +67,12 @@ def logWrite(request, action, message, objects = None): "facility" : None, "testbed" : None, } - + if objects is not None: for o in objects : if (o in log) : log[o] = objects[o] - + try : result = urllib2.urlopen(server, urllib.urlencode(log)) logger.info("===============>> activity: {} <{}> {}".format(action, request.user,message)) @@ -87,6 +87,7 @@ def logWrite(request, action, message, objects = None): logger.error(e.strerror) dbfile = ''.join([os.path.dirname(os.path.abspath(__file__)), "/errors.db"]) + logger.error("===============>> activity: database path: " + dbfile) conn = None try: conn = lite.connect(dbfile) @@ -127,6 +128,7 @@ def sign(secret, message): def logCheck(): """Checking local database for logs adn sending it to monitoring server""" dbfile = ''.join([os.path.dirname(os.path.abspath(__file__)), "/errors.db"]) + logger.error("[activity] database path: " + dbfile) conn = None #trying to connect local db adn pull unsent logs diff --git a/manifoldapi/manifoldapi.py b/manifoldapi/manifoldapi.py index de258b79..aab968b4 100644 --- a/manifoldapi/manifoldapi.py +++ b/manifoldapi/manifoldapi.py @@ -115,7 +115,7 @@ def _execute_query(url, request, query, manifold_api_session_auth): def execute_query(request, query): - logger.debug("EXECUTE QUERY: request - {}".format(request.session.items())) + #logger.debug("EXECUTE QUERY: request - {}".format(request.session.items())) if not 'manifold' in request.session or not 'auth' in request.session['manifold']: #manifold_api_session_auth = SessionCache().get_auth(request) diff --git a/manifoldapi/manifoldproxy.py b/manifoldapi/manifoldproxy.py index 636e2dbd..458c084a 100644 --- a/manifoldapi/manifoldproxy.py +++ b/manifoldapi/manifoldproxy.py @@ -8,8 +8,8 @@ from django.http import HttpResponse, HttpResponseForbidden #from manifoldapi.manifoldquery import ManifoldQuery from manifold.core.query import Query from manifold.core.result_value import ResultValue -from manifoldapi.manifoldapi import ManifoldAPI -from manifoldapi.manifoldresult import ManifoldException +from manifoldapi import ManifoldAPI +from manifoldresult import ManifoldException # from unfold.sessioncache import SessionCache diff --git a/manifoldapi/static/js/manifold.js b/manifoldapi/static/js/manifold.js index b8bd502d..305231e0 100644 --- a/manifoldapi/static/js/manifold.js +++ b/manifoldapi/static/js/manifold.js @@ -1715,7 +1715,7 @@ case TYPE_LIST_OF_VALUES: // // +) If a reservable node is added to the slice, then it should have a corresponding lease // XXX Not always a resource - var is_reservable = (record.exclusive == true); + var is_reservable = (record.exclusive == 'true' || record.exclusive == true); if (is_reservable) { // var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS); diff --git a/myslice/settings.py b/myslice/settings.py index b01b5653..d18ca924 100644 --- a/myslice/settings.py +++ b/myslice/settings.py @@ -375,4 +375,5 @@ SLA_COLLECTOR_PASSWORD = "password" # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' - +# test +ALLOWED_HOSTS = '*onelab.eu' diff --git a/myslice/urls.py b/myslice/urls.py index 59397e5b..6b1c9fa6 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -25,6 +25,7 @@ from settings import auxiliaries, INSTALLED_APPS from unfold.loginrequired import LoginRequiredView import portal.about +import portal.certificate import portal.institution import portal.registrationview import portal.accountview @@ -135,6 +136,7 @@ urls = [ # url(r'^register/?$', portal.registrationview.RegistrationView.as_view(), name='registration'), url(r'^account/?$', portal.accountview.AccountView.as_view(), name='account'), + url(r'^get_cert/?$', portal.certificate.CertificateView.as_view(), name='certificate'), url(r'^account/account_process/?$', portal.accountview.account_process), url(r'^contact/?$', portal.contactview.ContactView.as_view(), name='contact'), url(r'^terms/?$', portal.termsview.TermsView.as_view(), name='terms'), diff --git a/plugins/filter_status/static/js/filter_status.js b/plugins/filter_status/static/js/filter_status.js index 7a301005..676d3ee1 100644 --- a/plugins/filter_status/static/js/filter_status.js +++ b/plugins/filter_status/static/js/filter_status.js @@ -121,6 +121,9 @@ filter_status = this.dataset['status']; self.select_tab(filter_status); + // manifoldapi/static/js/manifold.js + // See this.apply_filters + // ... and communicate the appropriate filters to the manager // NOTE: we use the manifold namespace for internal filters if (self.prev_filter_status) { diff --git a/plugins/querytable/static/js/querytable.js b/plugins/querytable/static/js/querytable.js index 76934e79..c22dbd2c 100644 --- a/plugins/querytable/static/js/querytable.js +++ b/plugins/querytable/static/js/querytable.js @@ -90,7 +90,7 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; sPaginationType: 'bootstrap', // Handle the null values & the error : Datatables warning Requested unknown parameter // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2 - aoColumnDefs: [{sDefaultContent: '', aTargets: [ '_all' ]}], + aoColumnDefs: [{sDefaultContent: '', aTargets: [ '_all' ], "sType": "mysort"}], // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty // sScrollX: '100%', /* Horizontal scrolling */ bProcessing: true, /* Loading */ @@ -669,6 +669,66 @@ QUERYTABLE_BGCOLOR_REMOVED = 2; return result=$('td:eq('+iColumn+') input', tr).prop('checked') ? '1' : '0'; }); }; + + // use sType: "mysort" for any columns you wish to use these routines + // http://datatables.net/forums/discussion/7546/alpha-numeric-sort + jQuery.fn.dataTableExt.oSort['mysort-asc'] = function(a,b) { + var r = new RegExp("<([a-zA-Z]+).*?>(.*?)"); + if (r.exec(a) != null){ + a = r.exec(a)[2]; + } + if (r.exec(b) != null){ + b = r.exec(b)[2]; + } + a = a.replace(/[^A-Za-z0-9]/, ""); + b = b.replace(/[^A-Za-z0-9]/, ""); + var re = new RegExp("^([a-zA-Z]*)(.*)"); + var x = re.exec(a); + var y = re.exec(b); + + // you might want to force the first portion to lowercase + // for case insensitive matching + // x[1] = x[1].toLowerCase(); + // y[1] = y[1].toLowerCase(); + + if (x[1] > y[1]) return 1; + if (x[1] < y[1]) return -1; + + // if you want to force the 2nd part to only be numeric: + x[2] = parseInt(x[2]); + y[2] = parseInt(y[2]); + + return ((x[2] < y[2]) ? -1 : ((x[2] > y[2]) ? 1 : 0)); + }; + + jQuery.fn.dataTableExt.oSort['mysort-desc'] = function(a,b) { + var r = new RegExp("<([a-zA-Z]+).*?>(.*?)"); + if (r.exec(a) != null){ + a = r.exec(a)[2]; + } + if (r.exec(b) != null){ + b = r.exec(b)[2]; + } + a = a.replace(/[^A-Za-z0-9]/, ""); + b = b.replace(/[^A-Za-z0-9]/, ""); + var re = new RegExp("^([a-zA-Z]*)(.*)"); + var x = re.exec(a); + var y = re.exec(b); + + // you might want to force the first portion to lowercase + // for case insensitive matching + // x[1] = x[1].toLowerCase(); + // y[1] = y[1].toLowerCase(); + + if (x[1] > y[1]) return -1; + if (x[1] < y[1]) return 1; + + // if you want to force the 2nd part to only be numeric: + x[2] = parseInt(x[2]); + y[2] = parseInt(y[2]); + + return ((x[2] < y[2]) ? 1 : ((x[2] > y[2]) ? -1 : 0)); + }; diff --git a/portal/actions.py b/portal/actions.py index e0dc131f..f0bea38f 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -4,6 +4,7 @@ from manifoldapi.manifoldapi import execute_query,execute_admin_query from portal.models import PendingUser, PendingSlice, PendingAuthority, PendingProject, PendingJoin from unfold.page import Page +import hashlib import json from django.contrib.auth.models import User @@ -1285,7 +1286,8 @@ def create_pending_user(wsgi_request, request, user_detail): msg.send() # saves the user to django auth_user table [needed for password reset] - user = User.objects.create_user(request['email'].split('@')[-1], request['email'], request['password']) + # Django username must be less than 30 char so we use a hash + user = User.objects.create_user(hashlib.sha1(request['email']).hexdigest(), request['email'], request['password']) # Creating a manifold user user_id = manifold_add_user(wsgi_request, request) diff --git a/portal/certificate.py b/portal/certificate.py new file mode 100644 index 00000000..7aa4cd96 --- /dev/null +++ b/portal/certificate.py @@ -0,0 +1,54 @@ +# this somehow is not used anymore - should it not be ? +from django.core.context_processors import csrf +from django.http import HttpResponseRedirect +from django.contrib.auth import authenticate, login, logout +from django.template import RequestContext +from django.shortcuts import render_to_response +from django.shortcuts import render + +from unfold.loginrequired import LoginRequiredAutoLogoutView + +from manifoldapi.manifoldresult import ManifoldResult +from ui.topmenu import topmenu_items, the_user +from myslice.configengine import ConfigEngine + +from myslice.theme import ThemeView + +from portal.actions import get_jfed_identity + +class CertificateView (LoginRequiredAutoLogoutView, ThemeView): + template_name = 'certificate.html' + + # expose this so we can mention the backend URL on the welcome page + def default_env (self): + return { + 'MANIFOLD_URL':ConfigEngine().manifold_url(), + } + + def post (self,request): + env = self.default_env() + env['theme'] = self.theme + return render_to_response(self.template, env, context_instance=RequestContext(request)) + + def get (self, request, state=None): + env = self.default_env() + + if request.user.is_authenticated(): + env['person'] = self.request.user + else: + env['person'] = None + + env['theme'] = self.theme + + env['username'] = the_user(request) + env['topmenu_items'] = topmenu_items(None, request) + if state: + env['state'] = state + elif not env['username']: + env['state'] = None + # use one or two columns for the layout - not logged in users will see the login prompt + #env['layout_1_or_2'] = "layout-unfold2.html" if not env['username'] else "layout-unfold1.html" + + env['certificate'] = get_jfed_identity(request) + return render_to_response(self.template, env, context_instance=RequestContext(request)) + diff --git a/portal/emailactivationview.py b/portal/emailactivationview.py index 602ae91b..02f56ddb 100644 --- a/portal/emailactivationview.py +++ b/portal/emailactivationview.py @@ -66,7 +66,8 @@ class ActivateEmailView(FreeAccessView, ThemeView): if key == "hash_code": hash_code=value - if PendingUser.objects.filter(email_hash__iexact = hash_code).filter(status__iexact = 'False'): + #if PendingUser.objects.filter(email_hash__iexact = hash_code).filter(status__iexact = 'False'): + if PendingUser.objects.filter(email_hash__iexact = hash_code): activation = 'success' pending_users = PendingUser.objects.filter(email_hash__iexact = hash_code) pending_user = pending_users[0] diff --git a/portal/static/img/bg-smartfire.png b/portal/static/img/bg-smartfire.png index f5340fc4..70899312 100644 Binary files a/portal/static/img/bg-smartfire.png and b/portal/static/img/bg-smartfire.png differ diff --git a/portal/templates/_footer.html b/portal/templates/_footer.html index be7462e9..c5099599 100644 --- a/portal/templates/_footer.html +++ b/portal/templates/_footer.html @@ -12,7 +12,7 @@ Copyrights © 2015 UPMC Sorbonne Universités. All rights reserved.
- powered by     + powered by    
diff --git a/portal/templates/activate_user.html b/portal/templates/activate_user.html index 1ae1cda4..3ab9c2c1 100644 --- a/portal/templates/activate_user.html +++ b/portal/templates/activate_user.html @@ -1,4 +1,4 @@ - +

We have received a user signup request for your email address at {{current_site}}

You have the following user details:

diff --git a/portal/templates/certificate.html b/portal/templates/certificate.html new file mode 100644 index 00000000..3016fc92 --- /dev/null +++ b/portal/templates/certificate.html @@ -0,0 +1,3 @@ +
+{{certificate}}
+
diff --git a/portal/templates/contact_support_email.html b/portal/templates/contact_support_email.html index 54c11903..cd7d56bb 100644 --- a/portal/templates/contact_support_email.html +++ b/portal/templates/contact_support_email.html @@ -1,4 +1,4 @@ - +

User details


diff --git a/portal/templates/onelab/onelab_home-view.html b/portal/templates/onelab/onelab_home-view.html new file mode 100644 index 00000000..c98ee918 --- /dev/null +++ b/portal/templates/onelab/onelab_home-view.html @@ -0,0 +1,151 @@ +{% extends "layout_base.html" %} +{% load portal_filters %} + +{% block content %} + +{% if username %} + +{% block head %} + +{% endblock head %} + +{% widget "_widget-no_credentials.html" %} +
+
+ +
+
+
+

+ EXPERIMENT +

+
+ Create/Join project +
+ +
+ Your projects and slices +   + +
Loading projects
+
+ {% include theme|add:"_jfed_button.html" %} +
+
+
+
+

+ ACCOUNT +

+ {% if person.last_name %} +

+ {{person.first_name}} {{person.last_name}} +

+ {% endif %} +

+ {{person.email}} +

+
+
+
+
+

+ MANAGEMENT +

+ + +
+
+
+
+
+
+

+ SUPPORT +

+

+ Contact +

+

+ Documentation & Tutorials +

+ {% include theme|add:"_dashboard_links.html" %} +
+
+
+
+
+{% else %} +
+
+
+ {% widget '_slogan.html' %} +
+
+ {% widget '_widget-login-user.html' %} +
+
+
+
+
+ + + +{% endif %} + + + + + + + + +{% if theme == 'onelab' %} +{% widget "_widget-monitor.html" %} +{% endif %} +{% endblock %} diff --git a/portal/templates/onelab/onelab_manual-delegation.html b/portal/templates/onelab/onelab_manual-delegation.html new file mode 100644 index 00000000..f0d479cd --- /dev/null +++ b/portal/templates/onelab/onelab_manual-delegation.html @@ -0,0 +1,102 @@ +{% extends "layout.html" %} + +{% block content %} + +
+
+

Manual Delegation

+

Install SFA

+ +

+ In order to delegate your credentials to the OneLab portal, you need to install SFA tools.
+

+

+ [Requirement: python 2.7 or higher] +

+

For Mac and Linux

+

+ $ sudo easy_install pip
+ $ sudo pip install sfa +

+

For Windows

+

Please download get-pip.py

+

+ $ python get-pip.py
+ $ pip install sfa +

+ +

+ To get more information about pip, please visit: https://pip.pypa.io/en/latest/installing.html +

+

+ More details about SFA is available at the following address: + Installing SFA +

+ +

Configuring SFA

+ +

+ Once SFA tools are successfully installed, you need to configure the SFA client aka SFI +

+

+ $ mkdir ~/.sfi
+ $ cd ~/.sfi
+ $ cp ~/.ssh/id_rsa ~/.sfi/user-hrn.pkey +

+ +

+ Here, 'user-hrn' is your SFA hrn. If e.g., your OneLab account email is mohammed-yasin.rahman at upmc.fr, then your user-hrn is 'onelab.upmc.mohammed-yasin_rahman'.

+

+ In this example, a user-hrn is built using the root authority i.e, 'onelab' followed by a '.' then the sub authority i.e., 'upmc' + followed by a '.' and then the last fragment in the hrn is made of the local part of your email adress i.e., 'mohammed-yasin_rahman' + (with dots replaced with underscores). +

+ +

+ Next, you will setup your ~/.sfi/sfi_config. The following represents the sfi_config file for a OneLab user: +

+ +

+ [sfi]
+ auth = onelab.upmc
+ user = onelab.upmc.mohammed-yasin_rahman
+ registry = http://portal.onelab.eu:6080/
+ sm = http://sfa3.planet-lab.eu:12346/
+

+ +

+ Here again, 'user' is your user-hrn, and 'auth' is the authority that you belong to, in most cases you should just drop the last part of your hrn. +

+

+ Add the the following to sfi_config for delegating credentials to OneLab portal: +

+

+ [myslice]
+
+ backend = http://portal.onelab.eu:7080
+ delegate = onelab.myslice
+ platform = myslice
+ username = mohammed-yasin.rahman@lip6.fr +

+

+ Test the SFA layer: +

+

+ $ sfi.py version +

+

+ And finally delegate your credentials to the portal +

+

+ $ sfi.py myslice +

+

+ The complete tutorial is available at the following address: + http://trac.myslice.info/wiki/InstallSfa +

+ +
+ +
+{% endblock %} + diff --git a/portal/templates/servicedirectory.html b/portal/templates/servicedirectory.html index a4485af5..4a71ff35 100644 --- a/portal/templates/servicedirectory.html +++ b/portal/templates/servicedirectory.html @@ -95,18 +95,20 @@ loadedTabs = []; var imgsrc; + /* if(item.name.toLowerCase().indexOf("santander") >= 0){ - imgsrc = "smartsantander.png"; + imgsrc = "{{ STATIC_URL }}img/servicedirectory/smartsantander.png"; } else if(item.name.toLowerCase().indexOf("hadoop") >= 0){ - imgsrc = "hadoop.png"; + imgsrc = "{{ STATIC_URL }}img/servicedirectory/hadoop.png"; } else if(item.name.toLowerCase().indexOf("openstack") >= 0){ - imgsrc = "openstack.png"; + imgsrc = "{{ STATIC_URL }}img/servicedirectory/openstack.png"; } + */ var row = $('
').append( $('
').addClass("col-md-3 portfolio-item").append( $('').append( - $('').attr('src', "{{ STATIC_URL }}img/servicedirectory/" + imgsrc) + $('').attr('src', item.iconURL) ) ), $('
').addClass("col-md-6 portfolio-item").append( diff --git a/portal/templates/slice-resource-view.html b/portal/templates/slice-resource-view.html index cbd8d1bd..0a5d65ed 100644 --- a/portal/templates/slice-resource-view.html +++ b/portal/templates/slice-resource-view.html @@ -33,7 +33,7 @@ $(document).ready(function() {
- @@ -94,9 +94,9 @@ $(document).ready(function() {
{{scheduler}}
- +