Get simple rpc.call working
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
8962ca3f84
commit
ac1ab674c8
|
@ -31,6 +31,8 @@ from webob.exc import (HTTPNotFound,
|
||||||
|
|
||||||
from heat.common import wsgi
|
from heat.common import wsgi
|
||||||
from heat.engine import client as engine
|
from heat.engine import client as engine
|
||||||
|
from heat import rpc
|
||||||
|
from heat import context
|
||||||
|
|
||||||
logger = logging.getLogger('heat.api.v1.stacks')
|
logger = logging.getLogger('heat.api.v1.stacks')
|
||||||
|
|
||||||
|
@ -103,8 +105,10 @@ class StackController(object):
|
||||||
"""
|
"""
|
||||||
Returns the following information for all 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:
|
try:
|
||||||
templ = self._get_template(req)
|
templ = self._get_template(req)
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
|
|
|
@ -93,6 +93,34 @@ def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
|
||||||
at = utcnow()
|
at = utcnow()
|
||||||
return at.strftime(fmt)
|
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():
|
def utcnow():
|
||||||
"""Overridable version of utils.utcnow."""
|
"""Overridable version of utils.utcnow."""
|
||||||
if utcnow.override_time:
|
if utcnow.override_time:
|
||||||
|
|
|
@ -60,6 +60,6 @@ class EngineManager(manager.Manager):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Load configuration options and connect to the hypervisor."""
|
"""Load configuration options and connect to the hypervisor."""
|
||||||
|
|
||||||
def create(self, template, stack_id):
|
def create_stack(self, context, stack_name):
|
||||||
pass
|
return {'state': 'woot -> %s' % stack_name}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue