]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Get simple rpc.call working
authorAngus Salkeld <asalkeld@redhat.com>
Fri, 30 Mar 2012 02:02:28 +0000 (13:02 +1100)
committerAngus Salkeld <asalkeld@redhat.com>
Fri, 30 Mar 2012 02:02:28 +0000 (13:02 +1100)
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/api/v1/stacks.py
heat/common/utils.py
heat/engine/manager.py

index 1b1a3b4a451f01707ac2c5f03380ddb7b4c0819e..bfff3a78c0a30cc9439fa952a1cd9f43465f98ba 100644 (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:
index 998a90f1cf1a74cb821ec0695a273d1d133fbcc0..901ad703b8930b8b0957a75eba457b908c897627 100644 (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:
index a45453459defd3bde1bc94159d5d6fd39a767376..92fd3224e073cc8fcc78ad6b8db79b42b495c9c9 100644 (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}