from heat.common import wsgi
from heat.engine import client as engine
+from heat import rpc
+from heat import context
logger = logging.getLogger('heat.api.v1.stacks')
"""
Returns the following information for all stacks:
"""
- c = engine.get_engine_client(req.context)
+ con = context.get_admin_context()
+ return rpc.call(con, 'engine', {'method': 'create_stack',
+ 'args': {'stack_name': req.params['StackName']}})
try:
templ = self._get_template(req)
except socket.gaierror:
at = utcnow()
return at.strftime(fmt)
+def parse_strtime(timestr, fmt=PERFECT_TIME_FORMAT):
+ """Turn a formatted time back into a datetime."""
+ return datetime.datetime.strptime(timestr, fmt)
+
+
+def isotime(at=None):
+ """Stringify time in ISO 8601 format"""
+ if not at:
+ at = datetime.datetime.utcnow()
+ str = at.strftime(ISO_TIME_FORMAT)
+ tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
+ str += ('Z' if tz == 'UTC' else tz)
+ return str
+
+
+def parse_isotime(timestr):
+ """Turn an iso formatted time back into a datetime."""
+ try:
+ return iso8601.parse_date(timestr)
+ except (iso8601.ParseError, TypeError) as e:
+ raise ValueError(e.message)
+
+
+def normalize_time(timestamp):
+ """Normalize time in arbitrary timezone to UTC"""
+ offset = timestamp.utcoffset()
+ return timestamp.replace(tzinfo=None) - offset if offset else timestamp
+
def utcnow():
"""Overridable version of utils.utcnow."""
if utcnow.override_time:
def __init__(self, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
- def create(self, template, stack_id):
- pass
+ def create_stack(self, context, stack_name):
+ return {'state': 'woot -> %s' % stack_name}