cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: CLOUDSTACK-6202: add expiration time, make expires as a part of config
Date Thu, 17 Apr 2014 15:27:44 GMT
Repository: cloudstack-cloudmonkey
Updated Branches:
  refs/heads/master 2a53eaac6 -> a711367e4


CLOUDSTACK-6202: add expiration time, make expires as a part of config

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/commit/a711367e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/a711367e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/a711367e

Branch: refs/heads/master
Commit: a711367e4968ae1fca68e5293ad5e1622a269a37
Parents: 2a53eaa
Author: Yichi Lu <teegle@yahoo.com>
Authored: Tue Apr 15 16:58:48 2014 -0500
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Thu Apr 17 20:57:19 2014 +0530

----------------------------------------------------------------------
 cloudmonkey/cloudmonkey.py |  3 ++-
 cloudmonkey/config.py      |  1 +
 cloudmonkey/requester.py   | 11 +++++++----
 3 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/a711367e/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py
index b465bec..16a5e74 100644
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@ -254,7 +254,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
                                         self.asyncblock, logger,
                                         self.host, self.port,
                                         self.apikey, self.secretkey,
-                                        self.timeout, self.protocol, self.path)
+                                        self.timeout, self.protocol,
+                                        self.path, self.expires)
         if error is not None:
             self.monkeyprint(error)
         return response

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/a711367e/cloudmonkey/config.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/config.py b/cloudmonkey/config.py
index 2f91608..350655f 100644
--- a/cloudmonkey/config.py
+++ b/cloudmonkey/config.py
@@ -62,6 +62,7 @@ config_fields['server']['path'] = '/client/api'
 config_fields['server']['port'] = '8080'
 config_fields['server']['protocol'] = 'http'
 config_fields['server']['timeout'] = '3600'
+config_fields['server']['expires'] = '600'
 
 # user
 config_fields['user']['apikey'] = ''

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/a711367e/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --git a/cloudmonkey/requester.py b/cloudmonkey/requester.py
index b06e1fc..170437d 100644
--- a/cloudmonkey/requester.py
+++ b/cloudmonkey/requester.py
@@ -32,6 +32,7 @@ try:
     import types
     import urllib
     import urllib2
+    from datetime import datetime, timedelta
     from urllib2 import urlopen, HTTPError, URLError
 
 except ImportError, e:
@@ -44,9 +45,8 @@ def logger_debug(logger, message):
     if logger is not None:
         logger.debug(message)
 
-
 def make_request(command, args, logger, host, port,
-                 apikey, secretkey, protocol, path):
+                 apikey, secretkey, protocol, path, expires):
     response = None
     error = None
 
@@ -60,6 +60,9 @@ def make_request(command, args, logger, host, port,
     args["command"] = command
     args["apiKey"] = apikey
     args["response"] = "json"
+    args["signatureversion"] = "3"
+    expirationtime = datetime.utcnow() + timedelta(seconds=int(expires))
+    args["expires"] = expirationtime.strftime('%Y-%m-%dT%H:%M:%S+0000')
     request = zip(args.keys(), args.values())
     request.sort(key=lambda x: x[0].lower())
 
@@ -92,13 +95,13 @@ def make_request(command, args, logger, host, port,
 
 
 def monkeyrequest(command, args, isasync, asyncblock, logger, host, port,
-                  apikey, secretkey, timeout, protocol, path):
+                  apikey, secretkey, timeout, protocol, path, expires):
     response = None
     error = None
     logger_debug(logger, "======== START Request ========")
     logger_debug(logger, "Requesting command=%s, args=%s" % (command, args))
     response, error = make_request(command, args, logger, host, port,
-                                   apikey, secretkey, protocol, path)
+                                   apikey, secretkey, protocol, path, expires)
     logger_debug(logger, "======== END Request ========\n")
 
     if error is not None:


Mime
View raw message