Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Mon, 29 Sep 2014 09:53:31 +0000 (11:53 +0200)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Mon, 29 Sep 2014 09:53:31 +0000 (11:53 +0200)
15 files changed:
portal/actions.py
portal/contactview.py
portal/homeview.py
portal/manualdelegationview.py [new file with mode: 0644]
portal/templates/about.html
portal/templates/activate_user.txt
portal/templates/contact.html
portal/templates/fed4fire/fed4fire_about.html
portal/templates/join_view.html
portal/templates/manual-delegation.html [new file with mode: 0644]
portal/templates/onelab/onelab_about.html
portal/templates/onelab/onelab_account-view.html
portal/templates/onelab/onelab_home-view.html
portal/templates/onelab/onelab_registration_view.html
portal/urls.py

index aed65fe..da5fe56 100644 (file)
@@ -46,7 +46,7 @@ def authority_get_pi_emails(request, authority_hrn):
         #default_email = default_email.replace('\n', '')
         #return default_email
         # the above doesn't work
-        return ['support@myslice.info']
+        return ['support@onelab.eu']
     else:
         pi_user_hrns = [ hrn for x in pi_users for hrn in x['pi_users'] ]
         query = Query.get('user').filter_by('user_hrn', 'included', pi_user_hrns).select('user_email')
@@ -783,6 +783,42 @@ def sfa_create_user(wsgi_request, request, namespace = None, as_admin = False):
 
     return results
 
+def iotlab_create_user (wsgi_request, request, namespace = None, as_admin=False):
+   
+    import requests
+    import time
+    from requests.auth import HTTPBasicAuth
+    
+    URL_REST = 'https://devgrenoble.senslab.info/rest/admin/users'
+    LOGIN_ADMIN = "auge"
+    PASSWORD_ADMIN = "k,mfg1+Q"
+
+    auth = HTTPBasicAuth(LOGIN_ADMIN,PASSWORD_ADMIN)
+    headers = {'content-type': 'application/json'}
+
+    for user in PendingUser.objects.raw('SELECT * FROM portal_pendinguser WHERE email = %s', [request['email']]):
+        password= user.password
+
+
+    iotlab_user_params = {
+        "type"          : "SA",
+        "login"         : request['email'],
+        "password"      : password,
+        "firstName"     : request['first_name'],
+        "lastName"      : request['last_name'],
+        "email"         : request['email'],
+        "structure"     : request['authority_hrn'],
+        "city"          : "N/A",
+        "country"       : "N/A",
+        "sshPublicKey"  : [request['public_key']],
+        "motivations"   : "SFA federation",
+    }    
+   
+    iotlab_user_params1 = json.dumps(iotlab_user_params)
+    r=requests.post(url=URL_REST, data=iotlab_user_params1, headers=headers, auth=auth)
+    print 'Create iotlab user : ', r.status_code, r.text
+    return r.text
+
 def create_user(wsgi_request, request, namespace = None, as_admin = False):
     # XXX This has to be stored centrally
     USER_STATUS_ENABLED = 2
@@ -799,6 +835,10 @@ def create_user(wsgi_request, request, namespace = None, as_admin = False):
     # Add reference accounts for platforms
     manifold_add_reference_user_accounts(wsgi_request, request)
 
+    # Add the user to iotlab portal if theme is set to onelab
+    if theme.theme == 'onelab':
+        iotlab_create_user (wsgi_request, request)
+
 def create_pending_user(wsgi_request, request, user_detail):
     """
     """
@@ -826,7 +866,6 @@ def create_pending_user(wsgi_request, request, user_detail):
     theme.template_name = 'activate_user_email_subject.txt'
     subject = render_to_string(theme.template, request)
     subject = subject.replace('\n', '')
-    #sender = 'support@myslice.info'
     theme.template_name = 'email_default_sender.txt'
     sender =  render_to_string(theme.template, request)
     sender = sender.replace('\n', '')
index 2b9edb4..19cc1b9 100644 (file)
@@ -43,7 +43,6 @@ class ContactView (FreeAccessView, ThemeView):
             ## we don't need it cz the new ticketing systems sends a confirmation email ###
             #if cc_myself:
             #    recipients.append(email)
-            #recipients = ['support@myslice.info']
             theme.template_name = 'contact_support_email.html'
             html_content = render_to_string(theme.template, form.cleaned_data)
         
index 7af4776..b023652 100644 (file)
@@ -69,6 +69,10 @@ class HomeView (FreeAccessView, ThemeView):
                     activity.user.login(self.request)
                     
                     ## check user is pi or not
+                    platform_details = {}
+                    account_details = {}
+                    acc_auth_cred = {}
+                    acc_user_cred = {}
                     platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
                     account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
                     platform_details = execute_query(self.request, platform_query)
@@ -80,13 +84,22 @@ class HomeView (FreeAccessView, ThemeView):
                                     account_config = json.loads(account_detail['config'])
                                     if 'myslice' in platform_detail['platform']:
                                         acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+                                        acc_user_cred = account_config.get('delegated_user_credential','N/A')
                     # assigning values
                     if acc_auth_cred=={} or acc_auth_cred=='N/A':
                         pi = "is_not_pi"
                     else:
                         pi = "is_pi"
 
-                    env['pi'] = pi                
+                    # check if the user has creds or not
+                    if acc_user_cred == {} or acc_user_cred == 'N/A':
+                        user_cred = 'no_creds'
+                    else:
+                        user_cred = 'has_creds'
+
+
+                    env['pi'] = pi
+                    env['user_cred'] = user_cred                
                 else: 
                     env['person'] = None
                 return render_to_response(self.template,env, context_instance=RequestContext(request))
@@ -109,7 +122,12 @@ class HomeView (FreeAccessView, ThemeView):
         env = self.default_env()
         acc_auth_cred={}
         if request.user.is_authenticated():
+           
             ## check user is pi or not
+            platform_details = {}
+            account_details = {}
+            acc_auth_cred = {}
+            acc_user_cred = {}
             platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
             account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
             # XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page
@@ -123,13 +141,22 @@ class HomeView (FreeAccessView, ThemeView):
                                 account_config = json.loads(account_detail['config'])
                                 if 'myslice' in platform_detail['platform']:
                                     acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+                                    acc_user_cred = account_config.get('delegated_user_credential','N/A')
             # assigning values
             if acc_auth_cred=={} or acc_auth_cred=='N/A':
                 pi = "is_not_pi"
             else:
                 pi = "is_pi"
 
-            env['pi'] = pi     
+            # check if the user has creds or not
+            if acc_user_cred == {} or acc_user_cred == 'N/A':
+                user_cred = 'no_creds'
+            else:
+                user_cred = 'has_creds'
+           
+
+            env['pi'] = pi
+            env['user_cred'] = user_cred                
             env['person'] = self.request.user
         else: 
             env['person'] = None
diff --git a/portal/manualdelegationview.py b/portal/manualdelegationview.py
new file mode 100644 (file)
index 0000000..3560a92
--- /dev/null
@@ -0,0 +1,23 @@
+# 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 FreeAccessView
+
+from manifoldapi.manifoldresult import ManifoldResult
+from ui.topmenu import topmenu_items, the_user
+from myslice.configengine import ConfigEngine
+
+from myslice.theme import ThemeView
+
+class ManualDelegationView (FreeAccessView, ThemeView):
+    template_name = 'manual-delegation.html'
+
+    def get (self, request, state=None):
+        
+        return render_to_response(self.template, { 'theme' : self.theme }, context_instance=RequestContext(request))
+
index 1ccc720..ab8be3a 100644 (file)
@@ -68,7 +68,7 @@
                                        <p> More Info: <a href="http://myslice.info/" target="_blank">http://myslice.info/</a></p>
                                        <p> Code: <a href="http://git.onelab.eu/?p=myslice.git;a=summary" target="_blank">Git Repository</a> (read only)</p> 
                                        <p> 
-                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@myslice.info">support@myslice.info</a>.
+                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@onelab.eu">support@onelab.eu</a>.
                                        </p>
 
 
index ac31ec2..fd7278f 100644 (file)
@@ -18,7 +18,7 @@ You may now log in to the portal using your email address and the password that
        2. A manager from your organization validates your request. Upon confirmation of your signup request, we will send an email to the managers at your organization with a validation request.
 
 We look forward to welcoming you to OneLab. 
-Please don't hesitate to contact us at support@myslice.info with any additional questions that you might have.
+Please don't hesitate to contact us at support@onelab.eu with any additional questions that you might have.
 
 
 
index fdb5d0d..98e2c0b 100644 (file)
@@ -18,7 +18,7 @@
        <p>Please check our <a href="/portal/support/">FAQ</a> section. Most of the basic problems are explained there.</p>
        <p>
        If you haven't find your answes in the FAQ, please contact us by filling the form below.<br />
-       You can also <a href="mailto:support@myslice.info">e-mail</a> us directly.
+       You can also <a href="mailto:support@onelab.eu">e-mail</a> us directly.
        </p>
        </div>
 </div>
index 5af90c8..91998cb 100644 (file)
@@ -68,7 +68,7 @@
                                        <p> More Info: <a href="http://myslice.info/" target="_blank">http://myslice.info/</a></p>
                                        <p> Code: <a href="http://git.onelab.eu/?p=myslice.git;a=summary" target="_blank">Git Repository</a> (read only)</p> 
                                        <p> 
-                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@myslice.info">support@myslice.info</a>.
+                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@onelab.eu">support@onelab.eu</a>.
                                        </p>
 
 
index 57d8034..89d06ba 100644 (file)
        </div>
 </div>
        <div class="form-group" >
-               <p></p>
+               <input type="checkbox" name="agreement" value="agreement" required />&nbsp;&nbsp; I agree to the
+<a href="/terms" target="_blank">terms and conditions.</a>
+
+               <br><br>
                <button type="submit" class="btn btn-onelab">Submit</button>
        </div>
 </form>
diff --git a/portal/templates/manual-delegation.html b/portal/templates/manual-delegation.html
new file mode 100644 (file)
index 0000000..1463b51
--- /dev/null
@@ -0,0 +1,102 @@
+{% extends "layout.html" %}
+
+{% block content %}
+
+<div class="col-md-8">
+       <br>
+       <h2>Manual Delegation</h2>
+       <h3>Install SFA</h3>
+       
+       <p>
+               In order to delegate your credentials to the OneLab portal, you need to install SFA tools.<br>
+       </p>
+       <p>
+               <strong>[Requirement: python 2.7 or higher]</strong>
+       </p>
+       <h4>For Mac and Linux</h4>
+       <p class="command">
+               $ sudo easy_install pip<br>
+               $ sudo pip install sfa
+       </p>
+       <h4>For Windows</h4>
+       <p>Please download <a target="_blank" href="https://bootstrap.pypa.io/get-pip.py">get-pip.py</a></p>
+       <p class="command">
+               $ python get-pip.py<br>
+               $ pip install sfa
+       </p>
+
+       <p>
+       To get more information about pip, please visit: <a target="_blank" href="https://pip.pypa.io/en/latest/installing.html">https://pip.pypa.io/en/latest/installing.html</a>
+       </p>
+       <p>
+       More details about SFA is available at the following address:
+       <a target="_blank" href="http://svn.planet-lab.org/wiki/SFATutorialInstall#installingthroughpipfromPyPI">Installing SFA</a>
+       </p>
+       
+       <h3>Configuring SFA</h3>
+       
+       <p>
+               Once SFA tools are successfully installed, you need to configure the SFA client aka SFI
+       </p>
+       <p class="command">
+               $ mkdir ~/.sfi <br>
+               $ cd ~/.sfi <br>
+               $ cp ~/.ssh/id_rsa ~/.sfi/user-hrn.pkey
+       </p>
+       
+       <p>
+               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 <b><i>'onelab.upmc.mohammed-yasin_rahman'.</i></b></p>
+       <p>
+               In this example, a user-hrn is built using the root authority i.e, <b><i>'onelab'</i></b> followed by a <b>'.'</b> then the sub authority i.e., <b><i>'upmc'</i></b>
+               followed by a <b>'.'</b> and then the last fragment in the hrn is made of the local part of your email adress i.e., <b><i>'mohammed-yasin_rahman'</i></b> 
+               (with dots replaced with underscores).
+       </p>
+
+       <p>
+               Next, you will setup your ~/.sfi/sfi_config. The following represents the sfi_config file for a OneLab user:
+       </p>
+       
+       <p class="command">
+               [sfi]<br>
+               auth = onelab.upmc<br>
+               user = onelab.upmc.mohammed-yasin_rahman<br>
+               registry = http://portal.onelab.eu:12345/<br>
+               sm = http://sfa3.planet-lab.eu:12346/<br>
+       </p>
+
+       <p>
+               Here again, <b><i>'user'</i></b> is your user-hrn, and <b><i>'auth'</i></b> is the authority that you belong to, in most cases you should just drop the last part of your hrn.
+       </p>
+       <p>
+               Add the the following to sfi_config for delegating credentials to OneLab portal:
+       </p>    
+       <p class="command">
+               [myslice]<br>
+               <br>
+               backend  = http://portal.onelab.eu:7080<br>
+               delegate = onelab.myslice<br>
+               platform = myslice<br>
+               username = mohammed-yasin.rahman@lip6.fr
+       </p>
+       <p>
+               Test the SFA layer:
+       </p>
+       <p class="command">
+               $ sfi.py version
+       </p>
+       <p>
+               And finally delegate your credentials to the portal
+       </p>
+       <p class="command">
+               $ sfi.py myslice
+       </p>
+       <p>
+       The complete tutorial is available at the following address:
+       <a target="_blank" href="http://trac.myslice.info/wiki/InstallSfa">http://trac.myslice.info/wiki/InstallSfa</a>
+       </p>
+       
+       <br />
+       
+</div>
+{% endblock %}
+
index bd71256..b1b6c29 100644 (file)
@@ -64,7 +64,7 @@
                                        <p> More Info: <a href="http://myslice.info/" target="_blank">http://myslice.info/</a></p>
                                        <p> Code: <a href="http://git.onelab.eu/?p=myslice.git;a=summary" target="_blank">Git Repository</a> (read only)</p> 
                                        <p> 
-                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@myslice.info">support@myslice.info</a>.
+                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@onelab.eu">support@onelab.eu</a>.
                                        </p>
 
 
@@ -82,4 +82,4 @@
        </div>
    </div>
 </div>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
index 57acd89..199444a 100644 (file)
@@ -7,6 +7,10 @@
                         Account &nbsp;>&nbsp; <a href="/account">{{ person.email }}</a>
                 </div>
        </div>
+        {%if 'no_creds'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
+{%endif%}
+
 </div>
 {% if messages %}
 <ul class="messages">
                <div class="col-md-12">
                <h3>Credentials <small>Delegated to Principal Account</small></h3>
                        <table class="table">
-                                        {%if 'no_creds'  in user_cred %}
-                                               <p><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
-                                       {%endif%}       
                                        <caption><b>Delegated User Credential</b></caption> 
                            <tr class="odd"> 
                                <th>Expiration Date</th>
                                        <p>You may get this message for several reasons.</p>
                                        <h3>Account Delegation: Automatic</h3>
                                        <ul>
+                                               <li>If your account is not yet validated</li>
                                                <li>If you press the "Clear Credentials" button</li>
                                                <li>If you "Generate a new key pair"</li>
                                                <li>If a new slice is added to your account</li>
                                        <p>In all the above mentioned cases, it is sufficient to refresh the page or go back to home page. The portal will regenrate your credentials.
                                         In some cases it may take more time than usual. If nothing works, then please logout and login again to the portal.</p>
                                        <h3>Account Delegation: Manual</h3>
+                                               <p>First of all your account needs to be validated by the manager of your organization.</p>
                                                <p>As you have uploaded your own public key, the portal can no longer generate your credentials automatically.</p>
                                                <p>In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to
-                                               <a href="http://trac.myslice.info/wiki/InstallSfa" target="_blank">delegate your credentials to the portal.</a>
+                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a>
                                        </p>
                                        <h5>Contact support</h5>
                                        <p>If you don't have the above mentioned cases and still have this message, please  <a href="/contact/" target="_blank">contact us</a>.</p>
index 89716f7..b3394d6 100644 (file)
@@ -6,7 +6,45 @@
 {% widget '_widget-news.html' %}
 </div> -->
 {% if username %}
+<!-- Modal- No credentials -->
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">No credentials are delegated to the portal</h4>
+                    </div>
+                    <div class="modal-body">
+                                       <p>You may get this message for several reasons.</p>
+                                       <h3>Account Delegation: Automatic</h3>
+                                       <ul>
+                                               <li>If your account is not yet validated</li>
+                                               <li>If you press the "Clear Credentials" button</li>
+                                               <li>If you "Generate a new key pair"</li>
+                                               <li>If a new slice is added to your account</li>
+                                       </ul>
+                                       <p>In all the above mentioned cases, it is sufficient to refresh the page or go back to home page. The portal will regenrate your credentials.
+                                        In some cases it may take more time than usual. If nothing works, then please logout and login again to the portal.</p>
+                                       <h3>Account Delegation: Manual</h3>
+                                               <p>First of all your account needs to be validated by the manager of your organization.</p>
+                                               <p>As you have uploaded your own public key, the portal can no longer generate your credentials automatically.</p>
+                                               <p>In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to
+                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a>
+                                       </p>
+                                       <h5>Contact support</h5>
+                                       <p>If you don't have the above mentioned cases and still have this message, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
 <div class="container dashboard">
+          {%if 'no_creds'  in user_cred %}
+      <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
+  {%endif%}
+
        <div class="row">
                {%if 'is_pi'  in pi %}
                <div class="col-md-3">
index fddf6ab..b9a61a5 100644 (file)
@@ -83,7 +83,7 @@
                <br />
                        <div class="alert alert-danger" id="pkey_del_msg">
                                In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to 
-                               <a href="http://trac.myslice.info/wiki/InstallSfa" target="_blank">delegate your credentials to the portal.</a>
+                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a>
                        </div>
            </div>
        </div>
index 8bcdaf2..907267c 100644 (file)
@@ -44,6 +44,7 @@ from portal.validationview          import ValidatePendingView
 #from portal.experimentview         import ExperimentView
 from portal.termsview               import TermsView
 from portal.univbrisview            import UnivbrisView
+from portal.manualdelegationview    import ManualDelegationView
 
 from portal.servicedirectory         import ServiceDirectoryView
 
@@ -94,6 +95,7 @@ urlpatterns = patterns('',
     # Slice request
     url(r'^slice_request/?$', SliceRequestView.as_view(), name='slice_request'),
     url(r'^terms/?$', TermsView.as_view(), name='terms'),
+    url(r'^manual_delegation/?$', ManualDelegationView.as_view(), name='manual_delegation'),
     # Validate pending requests
     url(r'^validate/?$', ValidatePendingView.as_view()),
     # http://stackoverflow.com/questions/2360179/django-urls-how-to-pass-a-list-of-items-via-clean-urls