cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chirad...@apache.org
Subject [07/11] git commit: Merge branch 'username_password_support'
Date Wed, 23 Apr 2014 23:59:19 GMT
Merge branch 'username_password_support'

Conflicts:
	cloudmonkey/cloudmonkey.py
	cloudmonkey/requester.py


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

Branch: refs/heads/master
Commit: 6b1f94bcbf3a536e9205d7046e51dcf0e4e4439a
Parents: a711367 b2353a7
Author: Chiradeep Vittal <chiradeep@apache.org>
Authored: Wed Apr 23 14:53:14 2014 -0700
Committer: Chiradeep Vittal <chiradeep@apache.org>
Committed: Wed Apr 23 14:53:14 2014 -0700

----------------------------------------------------------------------
 cloudmonkey/cloudmonkey.py |  37 ++++++++++---
 cloudmonkey/config.py      |   2 +
 cloudmonkey/requester.py   | 120 +++++++++++++++++++++++++++++++++++-----
 docs/source/index.rst      |   1 +
 setup.py                   |   1 +
 5 files changed, 140 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/6b1f94bc/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --cc cloudmonkey/cloudmonkey.py
index 16a5e74,8e1f46c..baf017d
--- a/cloudmonkey/cloudmonkey.py
+++ b/cloudmonkey/cloudmonkey.py
@@@ -253,9 -256,8 +256,8 @@@ class CloudMonkeyShell(cmd.Cmd, object)
          response, error = monkeyrequest(command, args, isasync,
                                          self.asyncblock, logger,
                                          self.host, self.port,
-                                         self.apikey, self.secretkey,
-                                         self.timeout, self.protocol,
-                                         self.path, self.expires)
+                                         self.credentials,
 -                                        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/6b1f94bc/cloudmonkey/config.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/6b1f94bc/cloudmonkey/requester.py
----------------------------------------------------------------------
diff --cc cloudmonkey/requester.py
index 170437d,043a906..b0035d6
--- a/cloudmonkey/requester.py
+++ b/cloudmonkey/requester.py
@@@ -21,19 -21,13 +21,14 @@@ try
      import base64
      import hashlib
      import hmac
-     import httplib
      import json
-     import os
-     import pdb
-     import re
-     import shlex
+     import requests
      import sys
      import time
-     import types
      import urllib
      import urllib2
 +    from datetime import datetime, timedelta
-     from urllib2 import urlopen, HTTPError, URLError
+     from urllib2 import HTTPError, URLError
  
  except ImportError, e:
      print "Import error in %s : %s" % (__name__, e)
@@@ -58,11 -140,17 +141,20 @@@ def make_request(command, args, logger
          args = {}
  
      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')
+ 
+     #try to use the apikey/secretkey method by default
+     #if not present, use the username/password method
+     if not credentials['apikey']:
+         url = "%s://%s:%s%s" % (protocol, host, port, path)
+         return make_request_with_password(command, args,
+                                           logger, url, credentials)
+ 
+     args['apikey'] = credentials['apikey']
+     secretkey = credentials['secretkey']
      request = zip(args.keys(), args.values())
      request.sort(key=lambda x: x[0].lower())
  


Mime
View raw message