From: Angus Salkeld Date: Fri, 16 Mar 2012 01:09:42 +0000 (+1100) Subject: Catch errors better when creating the stack X-Git-Tag: 2014.1~2200 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=0a26758da05efa5ba758dc620bc81d19da5a53d4;p=openstack-build%2Fheat-build.git Catch errors better when creating the stack Signed-off-by: Angus Salkeld --- diff --git a/heat/api/v1/stacks.py b/heat/api/v1/stacks.py index 3eb1a471..483119db 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