CLOUDSTACK-514: Added protocol and path support to cloudmonkey.

This is the second half of making cloudmonkey and marvin more
flexible in environments that may have https enabled and / or
a different path for the cloudstack API.

Signed-off-by: Chip Childers <chip.childers@gmail.com>
This commit is contained in:
Chip Childers 2012-11-19 14:24:10 -05:00
parent 4e0063106b
commit 311ef69a77
2 changed files with 8 additions and 3 deletions

View File

@ -81,8 +81,9 @@ class CloudStackShell(cmd.Cmd):
for key in self.config_fields.keys():
setattr(self, key, self.config_fields[key])
config = self.write_config()
print("Set your apikey, secretkey, host, port, prompt, color,"
" log_file, history_file using the set command!")
print("Set your apikey, secretkey, host, port, prompt,"
" protocol, path, color, log_file and history_file"
" using the set command!")
for key in self.config_fields.keys():
try:
@ -195,10 +196,13 @@ class CloudStackShell(cmd.Cmd):
def make_request(self, command, requests={}, isAsync=False):
conn = cloudConnection(self.host, port=int(self.port),
apiKey=self.apikey, securityKey=self.secretkey,
asyncTimeout=self.timeout, logging=logger)
asyncTimeout=self.timeout, logging=logger,
protocol=self.protocol, path=self.path)
response = None
try:
self.print_shell("Starting call")
response = conn.make_request_with_auth(command, requests)
self.print_shell("Ending call")
except cloudstackAPIException, e:
self.print_shell("API Error:", e)
except HTTPError, e:

View File

@ -30,6 +30,7 @@ except ImportError, e:
# Add config key:value
config_file = os.path.expanduser('~/.cloudmonkey_config')
config_fields = {'host': 'localhost', 'port': '8080',
'protocol': 'http', 'path': '/client/api',
'apikey': '', 'secretkey': '',
'timeout': '3600', 'asyncblock': 'true',
'prompt': '🐵 cloudmonkey>', 'color': 'true',