X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sla%2Fslaclient%2Fservice%2Ffed4fire%2Ffed4fireservice.py;fp=sla%2Fslaclient%2Fservice%2Ffed4fire%2Ffed4fireservice.py;h=f11e8a1c8a9d700b788336bacb78526074b62abd;hb=f320a65ac7928a4a1c8315443880dce1d7afc997;hp=caecf26e6143286ae38c236d7c6f2f54325c3fb7;hpb=b6be4f9966a8ad3e05bd30155f723df55220128b;p=unfold.git diff --git a/sla/slaclient/service/fed4fire/fed4fireservice.py b/sla/slaclient/service/fed4fire/fed4fireservice.py index caecf26e..f11e8a1c 100755 --- a/sla/slaclient/service/fed4fire/fed4fireservice.py +++ b/sla/slaclient/service/fed4fire/fed4fireservice.py @@ -5,9 +5,9 @@ to sla manager. It is intended as backend service for a rest interface. The json input must work together with the templates to form a valid template - or agreement for Xifi (be careful!) + or agreement for fed4fire (be careful!) -This (very simple) service is coupled to the way xifi is interpreting +This (very simple) service is coupled to the way fed4fire is interpreting ws-agreement. @@ -18,10 +18,13 @@ from sla.slaclient import wsag_model from sla.slaclient import restclient from sla.slaclient.templates.fed4fire.django.factory import Factory as TemplateFactory import sla.slaclient.templates.fed4fire as fed4fire -from time import localtime, strftime +#from time import localtime, strftime import uuid +import dateutil.parser + + class ServiceContext(object): - def __init__(self, restfactory = None, templatefactory=None): + def __init__(self, restfactory=None, templatefactory=None): """ :type restfactory: restclient.Factory """ @@ -109,30 +112,36 @@ def createagreement(json_data, context): client_agreements = context.restfactory.agreements() return client_agreements.create(slaagreement) - + def createagreementsimplified(template_id, user, expiration_time): - context = ServiceContext( - restclient.Factory(), - TemplateFactory() - ) - - agreement = { - "agreement_id": str(uuid.uuid4()), - "template_id": template_id, - "expiration_time": expiration_time, - "consumer": user, - } - - json_data = json.dumps(agreement) - - return createagreement(json_data, context) - + context = ServiceContext( + restclient.Factory(), + TemplateFactory() + ) + + print "Expiration time: ", expiration_time + + time = dateutil.parser.parse(expiration_time) + print "ISO FORMAT: ", time.strftime('%Y-%m-%dT%H:%M:%S%Z') + + agreement = { + "agreement_id": str(uuid.uuid4()), + "template_id": template_id, + "expiration_time": time.strftime('%Y-%m-%dT%H:%M:%S%Z'), + "consumer": user, + } + + json_data = json.dumps(agreement) + + return createagreement(json_data, context) + + def main(): - createagreementsimplified("iMindsServiceWiLab2", "virtualwall", "2014-04-34T23:12:12") + createagreementsimplified("iMindsServiceWiLab2", + "virtualwall", + "2014-04-34T23:12:12") if __name__ == "__main__": main() - -