From 0a26758da05efa5ba758dc620bc81d19da5a53d4 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Fri, 16 Mar 2012 12:09:42 +1100 Subject: [PATCH] Catch errors better when creating the stack Signed-off-by: Angus Salkeld --- heat/api/v1/stacks.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/heat/api/v1/stacks.py b/heat/api/v1/stacks.py index 3eb1a4712b..483119dba0 100644 --- a/heat/api/v1/stacks.py +++ b/heat/api/v1/stacks.py @@ -121,9 +121,12 @@ class Json2CapeXml: # if there is no config then no services. pass - filename = '/var/run/%s.xml' % name - open(filename, 'w').write(doc.serialize(None, 1)) - doc.freeDoc() + try: + filename = '/var/run/%s.xml' % name + open(filename, 'w').write(doc.serialize(None, 1)) + doc.freeDoc() + except IOError as e: + logger.error('couldn\'t write to /var/run/ error %s' % e) def insert_package_and_services(self, r, new_script): @@ -259,7 +262,11 @@ def systemctl(method, name, instance=None): else: service = '%s@%s.service' % (name, instance) - result = m(service, 'replace') + try: + result = m(service, 'replace') + except dbus.DBusException as e: + logger.error('couldn\'t %s %s error: %s' % (method, name, e)) + return None return result