from urllib2 import urlopen
from urlparse import urlparse, urlunparse
+
def to_boolean(b):
val = b.lower().strip() if isinstance(b, basestring) else b
return val in [True, 'true', 'yes', '1', 1]
else:
self._monitor_services(handler, service_entries)
+
class MetadataServerConnectionError(Exception):
pass
+
class Metadata(object):
_metadata = None
_init_key = "AWS::CloudFormation::Init"
self._is_local_metadata = True
self._metadata = None
-
def metadata_server_url(self):
"""
Return the url to the metadata server.
**kwargs)
self.register_cli_opts(rpc_opts)
+
class HeatMetadataConfigOpts(cfg.CommonConfigOpts):
def __init__(self, default_config_files=None, **kwargs):
config_files = cfg.find_config_files(project='heat',
def get_maker(engine, autocommit=True, expire_on_commit=False):
"""Return a SQLAlchemy sessionmaker using the given engine."""
- return sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker(bind=engine,
+ ses = sqlalchemy.orm.sessionmaker(bind=engine,
autocommit=autocommit,
- expire_on_commit=expire_on_commit))
+ expire_on_commit=expire_on_commit)
+ return sqlalchemy.orm.scoped_session(ses)
def _get_sql_connection():
mime_blob.attach(msg)
msg = MIMEText(userdata, _subtype='x-shellscript')
- msg.add_header('Content-Disposition', 'attachment', filename='startup')
+ msg.add_header('Content-Disposition', 'attachment',
+ filename='startup')
mime_blob.attach(msg)
self.mime_string = mime_blob.as_string()
try:
res = self.resources[r].validate()
if res:
+ err_str = 'Malformed Query Response [%s]' % (res)
response = {'ValidateTemplateResult': {
- 'Description': 'Malformed Query Response [%s]' % res,
- 'Parameters': []}}
+ 'Description': err_str,
+ 'Parameters': []}}
return response
except Exception as ex:
logger.exception('validate')
response.content_type = 'application/json'
return response
+
def json_error(http_status, message):
"""Create a JSON error response."""
body = {'error': message}
return json_response(http_status, body)
+
class MetadataController:
def __init__(self, options):
self.options = options
if resources:
return resources
else:
- return json_error(404, 'The stack "%s" does not exist.' % stack_name)
+ return json_error(404,
+ 'The stack "%s" does not exist.' % stack_name)
def get_resource(self, req, stack_name, resource_id):
con = context.get_admin_context()
'resource_id': resource_id}})
if error:
if error == 'stack':
- return json_error(404, 'The stack "%s" does not exist.' % stack_name)
+ return json_error(404,
+ 'The stack "%s" does not exist.' % stack_name)
else:
- return json_error(404, 'The resource "%s" does not exist.' % resource_id)
+ return json_error(404,
+ 'The resource "%s" does not exist.' % resource_id)
return metadata
def update_metadata(self, req, body, stack_name, resource_id):
'metadata': body}})
if error:
if error == 'stack':
- return json_error(404, 'The stack "%s" does not exist.' % stack_name)
+ return json_error(404,
+ 'The stack "%s" does not exist.' % stack_name)
else:
- return json_error(404, 'The resource "%s" does not exist.' % resource_id)
+ return json_error(404,
+ 'The resource "%s" does not exist.' % resource_id)
return json_response(201, {
'resource': resource_id,
'metadata': body,
})
+
def create_resource(options):
"""
Stacks resource factory method.
deserializer = wsgi.JSONRequestDeserializer()
serializer = wsgi.JSONResponseSerializer()
return wsgi.Resource(MetadataController(options), deserializer, serializer)
-