From 13da78a3a067fa976585ce56b85362df82211a61 Mon Sep 17 00:00:00 2001
From: Yasin <mohammed-yasin.rahman@lip6.fr>
Date: Tue, 16 Sep 2014 15:46:27 +0200
Subject: [PATCH] manual delegation doc added to the portal

---
 portal/manualdelegationview.py          |  23 ++++++
 portal/templates/manual-delegation.html | 103 ++++++++++++++++++++++++
 portal/urls.py                          |   2 +
 3 files changed, 128 insertions(+)
 create mode 100644 portal/manualdelegationview.py
 create mode 100644 portal/templates/manual-delegation.html

diff --git a/portal/manualdelegationview.py b/portal/manualdelegationview.py
new file mode 100644
index 00000000..3560a92e
--- /dev/null
+++ b/portal/manualdelegationview.py
@@ -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))
+
diff --git a/portal/templates/manual-delegation.html b/portal/templates/manual-delegation.html
new file mode 100644
index 00000000..fe9b1bb5
--- /dev/null
+++ b/portal/templates/manual-delegation.html
@@ -0,0 +1,103 @@
+{% 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</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 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>
+		<br>
+		[sface]
+	</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 = [OneLab portal's username]  e.g., 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 %}
+
diff --git a/portal/urls.py b/portal/urls.py
index 8bcdaf24..907267c4 100644
--- a/portal/urls.py
+++ b/portal/urls.py
@@ -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
-- 
2.47.0