It is intended as backend service for a rest interface.\r
\r
The json input must work together with the templates to form a valid template\r
- or agreement for Xifi (be careful!)\r
+ or agreement for fed4fire (be careful!)\r
\r
-This (very simple) service is coupled to the way xifi is interpreting\r
+This (very simple) service is coupled to the way fed4fire is interpreting\r
ws-agreement.\r
\r
\r
from sla.slaclient import restclient\r
from sla.slaclient.templates.fed4fire.django.factory import Factory as TemplateFactory\r
import sla.slaclient.templates.fed4fire as fed4fire\r
-from time import localtime, strftime\r
+#from time import localtime, strftime\r
import uuid\r
+import dateutil.parser\r
+\r
+\r
class ServiceContext(object):\r
- def __init__(self, restfactory = None, templatefactory=None):\r
+ def __init__(self, restfactory=None, templatefactory=None):\r
"""\r
:type restfactory: restclient.Factory\r
"""\r
\r
client_agreements = context.restfactory.agreements()\r
return client_agreements.create(slaagreement)\r
- \r
+\r
\r
def createagreementsimplified(template_id, user, expiration_time):\r
- context = ServiceContext(\r
- restclient.Factory(),\r
- TemplateFactory()\r
- )\r
- \r
- agreement = {\r
- "agreement_id": str(uuid.uuid4()),\r
- "template_id": template_id,\r
- "expiration_time": expiration_time,\r
- "consumer": user,\r
- }\r
- \r
- json_data = json.dumps(agreement)\r
-\r
- return createagreement(json_data, context)\r
- \r
+ context = ServiceContext(\r
+ restclient.Factory(),\r
+ TemplateFactory()\r
+ )\r
+\r
+ print "Expiration time: ", expiration_time\r
+\r
+ time = dateutil.parser.parse(expiration_time)\r
+ print "ISO FORMAT: ", time.strftime('%Y-%m-%dT%H:%M:%S%Z')\r
+\r
+ agreement = {\r
+ "agreement_id": str(uuid.uuid4()),\r
+ "template_id": template_id,\r
+ "expiration_time": time.strftime('%Y-%m-%dT%H:%M:%S%Z'),\r
+ "consumer": user,\r
+ }\r
+\r
+ json_data = json.dumps(agreement)\r
+\r
+ return createagreement(json_data, context)\r
+\r
+\r
def main():\r
- createagreementsimplified("iMindsServiceWiLab2", "virtualwall", "2014-04-34T23:12:12")\r
+ createagreementsimplified("iMindsServiceWiLab2",\r
+ "virtualwall",\r
+ "2014-04-34T23:12:12")\r
\r
\r
if __name__ == "__main__":\r
main()\r
- \r
- \r