From f7eb70acf30258f7f3124f3426197e0256c5599e Mon Sep 17 00:00:00 2001 From: nlebreto Date: Mon, 25 Nov 2013 11:50:07 +0100 Subject: [PATCH] adding provisioning feature --- sfa/client/bonfire.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/sfa/client/bonfire.py b/sfa/client/bonfire.py index 0b34ce51..96ec1727 100644 --- a/sfa/client/bonfire.py +++ b/sfa/client/bonfire.py @@ -6,6 +6,30 @@ import xml.etree.ElementTree as ET # helping functions # ########################################################## # + +def create_fed4fire_exp(name, groups, description, walltime, slice_id, exp_owner): + # create experiement with tag fed4fire + xmldescription='' + name + '' + groups + '' + description + '' + walltime + 'ready' + slice_id + '' + exp_owner + '' + postexp("https://api.integration.bonfire.grid5000.fr/experiments", xmldescription) + +def postexp(url, xmldescription): + headers = {'content-type': 'application/vnd.bonfire+xml'} + r = requests.post(url, data=xmldescription, headers=headers, verify=False, auth=('nlebreto', 'GDRU_23tc$')) + +def stop_vm(testbed, num_compute): + # compute bonfire to stopped state + url = "https://api.integration.bonfire.grid5000.fr/" + "locations/" + testbed + "/computes/" + num_compute + xmldescription = 'stopped' + headers = {'content-type': 'application/vnd.bonfire+xml'} + requests.put(url, data=xmldescription, headers=headers, verify=False, auth=('nlebreto', 'GDRU_23tc$')) + +def provisioning(num_experiment): + # experiment bonfire to running status + url = "https://api.integration.bonfire.grid5000.fr/experiments/" + num_experiment + xmldescription = 'running' + headers = {'content-type': 'application/vnd.bonfire+xml'} + requests.put(url, data=xmldescription, headers=headers, verify=False, auth=('nlebreto', 'GDRU_23tc$')) + def callcurl(url): r = requests.get(url, verify=False, auth=('nlebreto', 'GDRU_23tc$')) if r.status_code == 200: @@ -52,10 +76,25 @@ def jfedfeat(bonfires, pageurl): bonfires.append("") def remove_needless_txt(txt): + txt=str(txt) txt=txt.replace("\n","\n") txt=txt.replace("\n","\n") return txt +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) + hash = {} + hash["url"] = url + for name in xmlreduit: + if name.tag == "{http://api.bonfire-project.eu/doc/schemas/occi}groups": + hash["name"] = name.text + for context in name: + if context.tag == "{http://api.bonfire-project.eu/doc/schemas/occi}authorized_keys": + hash["keys"] = context.text + return hash + # parameters # ########################################################## # locations = ["fr-inria", "be-ibbt", "uk-epcc"] @@ -75,7 +114,7 @@ def bonsources(): bonfires.append(manag_exp) bonfires.append("") jfedfeat(bonfires, "http://frontend.bonfire.grid5000.fr/one-status.xml") -# jfedfeat(bonfires, "http://bonfire.epcc.ed.ac.uk/logs/one-status.xml") + jfedfeat(bonfires, "http://bonfire.epcc.ed.ac.uk/one-status.xml") jfedfeat(bonfires, "http://bonfire.psnc.pl/one-status.xml") jfedfeat(bonfires, "http://nebulosus.rus.uni-stuttgart.de/one-status.xml") bonfires.append("") -- 2.43.0