From 246776227c130935075056a6c7401b6d6d77c1c5 Mon Sep 17 00:00:00 2001 From: nlebreto Date: Thu, 6 Mar 2014 17:44:35 +0100 Subject: [PATCH] r1.9 adding bonfire driver --- sfa/bonfire/bonfire.py | 6 +-- sfa/bonfire/bonfiredriver.py | 96 ++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 sfa/bonfire/bonfiredriver.py diff --git a/sfa/bonfire/bonfire.py b/sfa/bonfire/bonfire.py index 0818e21a..9f3a9571 100644 --- a/sfa/bonfire/bonfire.py +++ b/sfa/bonfire/bonfire.py @@ -34,7 +34,7 @@ import time # python -c 'import bonfire; print bonfire.allocate("nlebreto", "nlebreto", "tdes", "125", "topdomain.dummy.nicolas")' # 3) provisioning: changing the status to running status for the experiment 2911 -# python -c 'import bonfire; print bonfire.provisioning("2911")' +# python -c 'import bonfire; print bonfire.provisioning("2911","running")' # 4) bonfire create virtual machine with these specific features 1) fr-inria storages n°1805 network 2 ip public 2) uk-epcc storages n°1364 network 0 bonfire wan # python -c 'import bonfire; print bonfire.create_vm("fr-inria", "56910", "rester", "nlebreto")' @@ -164,9 +164,9 @@ def stop_vm(testbed, num_compute): # provisioning : set a bonfire's experiment to running # changing the status to running status -def provisioning(num_experiment): +def provisioning(num_experiment, status): url = "https://api.integration.bonfire.grid5000.fr/experiments/" + num_experiment - xmldescription = 'running' + xmldescription = ''+ status + '' headers = {'content-type': 'application/vnd.bonfire+xml'} h = bonfire_authenticate() r = requests.post(url, data=xmldescription, headers=headers, verify=False, auth=(h["user"], h["user_pass"])) diff --git a/sfa/bonfire/bonfiredriver.py b/sfa/bonfire/bonfiredriver.py new file mode 100644 index 00000000..394127c3 --- /dev/null +++ b/sfa/bonfire/bonfiredriver.py @@ -0,0 +1,96 @@ +import bonfire +from sfa.managers.driver import Driver + +# an attempt to do a sfawrap plugin document + +class Bonfiredriver(Driver): + + def __init__ (self, config): + # this is the hrn attached to the running server + self.config = config + + def augment_records_with_testbed_info (self, sfa_records): + return sfa_records + + def register (self, sfa_record, hrn, pub_key) : + return -1 + + def remove (self, sfa_record): + return True + + def update (self, old_sfa_record, new_sfa_record, hrn, new_key): + return True + + def update_relation (self, subject_type, target_type, relation_name, subject_id, link_ids): + pass + + ######################################## + ########## aggregate oriented + ######################################## + + def __parameter__ (self, action): + options={} + if action == "allocate": + options['user_name'] = input("Enter your name: ") + options['groups'] = input("Enter your group: ") + options['description'] = input("Enter a description: ") + options['walltime'] = input("Enter a walltime: ") + options['Vslice_name'] = input("Enter a slice name: ") + elif action == "provision" or action == "delete": + options['number'] = input("Enter a number (experiment): ") + options['status'] = input("Enter a status (running delete): ") + elif action == "create": + options['groups'] = input("Enter your group: ") + options['description'] = input("Enter a description: ") + options['number'] = input("Enter a number (experiment): ") + options['testbed'] = input("Enter a testbed (fr-inria or uk-epcc): ") + + def testbed_name (self): return "Bonfire" + + def aggregate_version (self): return {} + + def list_resources (self, version=None, options={}): + rspec = bonfire.bonsources() + hash ={'geni_rspec': rspec, 'geni_urn':'None','geni_slivers':[{'geni_sliver_urn':'None','geni_expires':'None','geni_allocation_status':'None','geni_operational_status':'None'}]} + return hash + + def describe (self, urns, version, options={}): + return "dummy Driver.describe needs to be redefined" + + def allocate (self, urn=None, rspec_string=None, expiration=None, options={}): + #options= {"user_name":"nlebreto","groups":"nlebreto","description":"exp","walltime":"125","slice_name":"topdomain.dummy.nicolas"} + if bool(options): + sendallocate = bonfire.allocate(options['user_name'],options['groups'],options['description'],options['walltime'],options['slice_name']) + return "allocate done" + else: + return "options not well defined for allocate" + + def provision(self, urns=None, options={}): + if bool(options): + bonfire.provisioning(options['number'],options['status']) + return "provision done" + else: + return "dummy Driver.provision needs to be redefined" + + def perform_operational_action (self, urns=None, action=None, options={}): + if bool(options): + bonfire.create_vm(options['testbed'],options['number'],options['description'],options['groups']) + return "create vm" + else: + return "dummy Driver.perform_operational_action needs to be redefined" + + def status (self, urns, options={}): + return "dummy Driver.status needs to be redefined" + + def renew (self, urns, expiration_time, options={}): + return "dummy Driver.renew needs to be redefined" + + def delete(self, urns, options={}): + if bool(options): + bonfire.provisioning(options['number'],options['status']) + return "provision done" + else: + return "dummy Driver.delete needs to be redefined" + + def shutdown (self, xrn, options={}): + return False -- 2.43.0