summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore18
-rw-r--r--heatclient/v1/shell.py21
-rw-r--r--heatclient/v1/stacks.py7
-rw-r--r--heatclient/versioninfo2
-rw-r--r--tests/v1/__init__.py0
-rw-r--r--tests/v1/test_shell.py31
6 files changed, 71 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index fd26426..b0fba10 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,20 @@
+.coverage
+.venv
+*,cover
+cover
+*.pyc
+.idea
+*.swp
+*~
+AUTHORS
build
dist
+python_glanceclient.egg-info
+ChangeLog
+run_tests.err.log
+.tox
+doc/source/api
+*.egg
+glanceclient/versioninfo
python_heatclient.egg-info
-*.log \ No newline at end of file
+*.log
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py
index 5b75478..e2de04a 100644
--- a/heatclient/v1/shell.py
+++ b/heatclient/v1/shell.py
@@ -21,6 +21,18 @@ import sys
from heatclient.common import utils
+def format_parameters(params):
+ '''
+ Reformat parameters into dict of format expected by the API
+ '''
+ parameters = {}
+ if params:
+ for count, p in enumerate(params.split(';'), 1):
+ (n, v) = p.split('=')
+ parameters[n] = v
+ return parameters
+
+
@utils.arg('-u', '--template-url', metavar='<URL>',
help='URL of template.')
@utils.arg('-f', '--template-file', metavar='<FILE>',
@@ -35,8 +47,15 @@ from heatclient.common import utils
def do_create(hc, args):
'''Create the stack'''
# Filter out None values
- fields = dict(filter(lambda x: x[1] is not None, vars(args).items()))
+ fields = {'stackname': args.name,
+ 'timeoutmins': args.create_timeout,
+ 'parameters': format_parameters(args.parameters)}
print fields
+ if args.template_file:
+ fields['template'] = open(args.template_file).read()
+ elif args.template_url:
+ fields['template_url'] = args.template_url
+
stack = hc.stacks.create(**fields)
utils.print_dict(stack)
diff --git a/heatclient/v1/stacks.py b/heatclient/v1/stacks.py
index 7af9ffe..9d24f98 100644
--- a/heatclient/v1/stacks.py
+++ b/heatclient/v1/stacks.py
@@ -88,11 +88,8 @@ class StackManager(base.Manager):
def create(self, **kwargs):
"""Create a stack"""
- template_data = None
- hdrs = {}
-
- resp, body_iter = self.api.raw_request(
- 'POST', '/stacks', headers=hdrs, body=template_data)
+ resp, body_iter = self.api.json_request(
+ 'POST', '/stacks', body=kwargs)
body = json.loads(''.join([c for c in body_iter]))
return Stack(self, body)
diff --git a/heatclient/versioninfo b/heatclient/versioninfo
index 3731c9b..e16a3aa 100644
--- a/heatclient/versioninfo
+++ b/heatclient/versioninfo
@@ -1 +1 @@
-0.0.6.7cbfd72
+0.0.8.622719c
diff --git a/tests/v1/__init__.py b/tests/v1/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/v1/__init__.py
diff --git a/tests/v1/test_shell.py b/tests/v1/test_shell.py
new file mode 100644
index 0000000..d0aa63a
--- /dev/null
+++ b/tests/v1/test_shell.py
@@ -0,0 +1,31 @@
+# Copyright 2012 OpenStack LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+import unittest
+import heatclient.v1.shell as shell
+
+
+class shellTest(unittest.TestCase):
+
+ def test_format_parameters(self):
+ p = shell.format_parameters('InstanceType=m1.large;DBUsername=wp;'
+ 'DBPassword=verybadpassword;KeyName=heat_key;'
+ 'LinuxDistribution=F17')
+ self.assertEqual({'InstanceType': 'm1.large',
+ 'DBUsername': 'wp',
+ 'DBPassword': 'verybadpassword',
+ 'KeyName': 'heat_key',
+ 'LinuxDistribution': 'F17'
+ }, p)
+ self.assertEqual({}, shell.format_parameters(None))