Get simple rpc.call working

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2012-03-30 13:02:28 +11:00
parent 8962ca3f84
commit ac1ab674c8
3 changed files with 35 additions and 3 deletions

View File

@ -31,6 +31,8 @@ from webob.exc import (HTTPNotFound,
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')
@ -103,8 +105,10 @@ class StackController(object):
"""
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:

View File

@ -93,6 +93,34 @@ def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
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:

View File

@ -60,6 +60,6 @@ class EngineManager(manager.Manager):
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}