incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chipchild...@apache.org
Subject git commit: CLOUDSTACK-514: Adding https and api path support to Marvin.
Date Mon, 19 Nov 2012 17:08:43 GMT
Updated Branches:
  refs/heads/master 79e5a3a3a -> 2ee9253c7


CLOUDSTACK-514: Adding https and api path support to Marvin.

This is the first part of fixing CLOUDSTACK-514, and is hopefully
backward compatible with previous use of Marvin.  I added two new
parameters to the cloudstackConnection module, protocol and path.
Both have been defaulted to the previously *assumed* values.

Signed-off-by: Chip Childers <chip.childers@gmail.com>


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

Branch: refs/heads/master
Commit: 2ee9253c78152d517f8448f66a779c6e3777b19c
Parents: 79e5a3a
Author: Chip Childers <chip.childers@gmail.com>
Authored: Mon Nov 19 12:06:18 2012 -0500
Committer: Chip Childers <chip.childers@gmail.com>
Committed: Mon Nov 19 12:06:18 2012 -0500

----------------------------------------------------------------------
 tools/marvin/marvin/cloudstackConnection.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2ee9253c/tools/marvin/marvin/cloudstackConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py
index bd8a5b2..c805213 100644
--- a/tools/marvin/marvin/cloudstackConnection.py
+++ b/tools/marvin/marvin/cloudstackConnection.py
@@ -31,12 +31,17 @@ from cloudstackAPI import *
 import jsonHelper
 
 class cloudConnection(object):
-    def __init__(self, mgtSvr, port=8096, apiKey = None, securityKey = None, asyncTimeout=3600,
logging=None):
+    def __init__(self, mgtSvr, port=8096, apiKey = None, securityKey = None, asyncTimeout=3600,
logging=None, protocol='http', path='/client/api'):
         self.apiKey = apiKey
         self.securityKey = securityKey
         self.mgtSvr = mgtSvr
         self.port = port
         self.logging = logging
+        if protocol != 'http' and protocol != 'https':
+            raise ValueError("Protocol must be 'http' or 'https'.")
+        else:
+            self.protocol=protocol
+        self.path = path
         if port == 8096:
             self.auth = False
         else:
@@ -52,7 +57,7 @@ class cloudConnection(object):
             pass
     
     def __copy__(self):
-        return cloudConnection(self.mgtSvr, self.port, self.apiKey, self.securityKey, self.asyncTimeout,
self.logging)
+        return cloudConnection(self.mgtSvr, self.port, self.apiKey, self.securityKey, self.asyncTimeout,
self.logging, self.protocol, self.path)
     
     def make_request_with_auth(self, command, requests={}):
         requests["command"] = command
@@ -68,7 +73,7 @@ class cloudConnection(object):
         requestUrl += "&signature=%s"%sig
 
         try:
-            self.connection = urllib2.urlopen("http://%s:%d/client/api?%s"%(self.mgtSvr,
self.port, requestUrl))
+            self.connection = urllib2.urlopen("%s://%s:%d%s?%s"%(self.protocol, self.mgtSvr,
self.port, self.path, requestUrl))
             if self.logging is not None:
                 self.logging.debug("sending GET request: %s"%requestUrl)
             response = self.connection.read()
@@ -100,7 +105,7 @@ class cloudConnection(object):
         requests = zip(requests.keys(), requests.values())
         requestUrl = "&".join(["=".join([request[0], urllib.quote_plus(str(request[1]))])
for request in requests])
 
-        self.connection = urllib2.urlopen("http://%s:%d/client/api?%s"%(self.mgtSvr, self.port,
requestUrl))
+        self.connection = urllib2.urlopen("%s://%s:%d%s?%s"%(self.protocol, self.mgtSvr,
self.port, self.path, requestUrl))
         if self.logging is not None:
             self.logging.debug("sending GET request without auth: %s"%requestUrl)
         response = self.connection.read()


Mime
View raw message