-# retrieve the url, the name and the key that will currently use by sfa
-def rsa_user_bonfire(testbed, num_compute):
- url = "https://api.integration.bonfire.grid5000.fr/" + "locations/" + testbed + "/computes/" + num_compute
- pagebonfirecompute = callcurl(url)
- xmlreduit = ET.fromstring(pagebonfirecompute)
+# authentification against bonfire's ldap using a virtual machine
+#def bonldap(mail):
+# ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, '/Fed4FIRE-SFA-Backend/puppet/modules/ca/ca.crt')
+ # using a certificate (client)
+# ldap.set_option(ldap.OPT_PROTOCOL_VERSION, 3)
+# ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
+# ld = ldap.initialize('ldaps://127.0.0.1:2636')
+ # connection with ldaps
+# basedn = "ou=People,dc=bonfire-project,dc=eu"
+# filter_test = "mail=" + mail
+# filter = filter_test
+ # search email in the ldap
+# results = ld.search_s(basedn, ldap.SCOPE_SUBTREE, filter)
+# if not results:
+# print ("error 401, you need to be register to the portal f4f")
+# return results
+
+# create a slice and attach a specific user to it
+def create_slice_attach_user(user_slice):
+ call = "sfa.py add -x {0}_slice -t slice -r {0}@dummy.net".format(user_slice)
+ callcreateslice = subprocess.Popen(call, shell=True)
+
+# remove slice or key
+def remove_slice(name):
+ cmdremove = "sfaadmin.py reg remove {0}".format(name)
+ removeaction = subprocess.Popen(cmdremove, shell=True)
+
+# show specific credential of a slice (see the content of a specific file /root/.sfi/*.slice.cred)
+def show_slice_credential(slice_name):
+ path = "/root/.sfi/{0}.slice.cred".format(slice_name)
+ tree = ET.parse(path)
+ root = tree.getroot()