Add support for getting the template via url else we get RequestUriTooLong
The nutty cloudforms api passes the template in via parameters. TemplateUrl is better. try: ./bin/heat create my_stack --template-url=https://raw.github.com/asalkeld/heat/master/templates/WordPress_Single_Instance.template Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
97b6c95df0
commit
a5ea8a4c55
|
@ -13,7 +13,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
SUPPORTED_PARAMS = ('StackName', 'TemplateBody', 'NotificationARNs', 'Parameters',
|
SUPPORTED_PARAMS = ('StackName', 'TemplateBody', 'TemplateUrl','NotificationARNs', 'Parameters',
|
||||||
'Version', 'SignatureVersion', 'Timestamp', 'AWSAccessKeyId',
|
'Version', 'SignatureVersion', 'Timestamp', 'AWSAccessKeyId',
|
||||||
'Signature')
|
'Signature')
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import httplib
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
import urlparse
|
||||||
|
|
||||||
import webob
|
import webob
|
||||||
from webob.exc import (HTTPNotFound,
|
from webob.exc import (HTTPNotFound,
|
||||||
|
@ -91,10 +92,24 @@ class StackController(object):
|
||||||
|
|
||||||
def _get_template(self, req):
|
def _get_template(self, req):
|
||||||
if req.params.has_key('TemplateBody'):
|
if req.params.has_key('TemplateBody'):
|
||||||
|
logger.info('TemplateBody ...')
|
||||||
return req.params['TemplateBody']
|
return req.params['TemplateBody']
|
||||||
elif req.params.has_key('TemplateUrl'):
|
elif req.params.has_key('TemplateUrl'):
|
||||||
# TODO _do_request() ...
|
logger.info('TemplateUrl %s' % req.params['TemplateUrl'])
|
||||||
pass
|
url = urlparse.urlparse(req.params['TemplateUrl'])
|
||||||
|
if url.scheme == 'https':
|
||||||
|
conn = httplib.HTTPSConnection(url.netloc)
|
||||||
|
else:
|
||||||
|
conn = httplib.HTTPConnection(url.netloc)
|
||||||
|
conn.request("GET", url.path)
|
||||||
|
r1 = conn.getresponse()
|
||||||
|
logger.info('status %d' % r1.status)
|
||||||
|
if r1.status == 200:
|
||||||
|
data = r1.read()
|
||||||
|
conn.close()
|
||||||
|
else:
|
||||||
|
data = None
|
||||||
|
return data
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -111,12 +126,12 @@ class StackController(object):
|
||||||
"""
|
"""
|
||||||
if stack_db.has_key(req.params['StackName']):
|
if stack_db.has_key(req.params['StackName']):
|
||||||
msg = _("Stack already exists with that name.")
|
msg = _("Stack already exists with that name.")
|
||||||
return exc.HTTPConflict(msg)
|
return webob.exc.HTTPConflict(msg)
|
||||||
|
|
||||||
templ = self._get_template(req)
|
templ = self._get_template(req)
|
||||||
if templ is None:
|
if templ is None:
|
||||||
msg = _("TemplateBody or TemplateUrl were not given.")
|
msg = _("TemplateBody or TemplateUrl were not given.")
|
||||||
return exc.HTTPBadRequest(explanation=msg)
|
return webob.exc.HTTPBadRequest(explanation=msg)
|
||||||
|
|
||||||
stack = json.loads(templ)
|
stack = json.loads(templ)
|
||||||
my_id = '%s-%d' % (req.params['StackName'], self.stack_id)
|
my_id = '%s-%d' % (req.params['StackName'], self.stack_id)
|
||||||
|
@ -136,7 +151,7 @@ class StackController(object):
|
||||||
"""
|
"""
|
||||||
if not stack_db.has_key(req.params['StackName']):
|
if not stack_db.has_key(req.params['StackName']):
|
||||||
msg = _("Stack does not exist with that name.")
|
msg = _("Stack does not exist with that name.")
|
||||||
return exc.HTTPNotFound(msg)
|
return webob.exc.HTTPNotFound(msg)
|
||||||
|
|
||||||
stack = stack_db[req.params['StackName']]
|
stack = stack_db[req.params['StackName']]
|
||||||
my_id = stack['StackId']
|
my_id = stack['StackId']
|
||||||
|
|
Loading…
Reference in New Issue