]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Handle missing config file
authorZane Bitter <zbitter@redhat.com>
Wed, 11 Apr 2012 12:03:37 +0000 (14:03 +0200)
committerZane Bitter <zbitter@redhat.com>
Wed, 11 Apr 2012 12:03:37 +0000 (14:03 +0200)
Report a more useful error when no config file can be found.

Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/common/config.py

index 0bdb418b1204d79d93bbdf73b690613f96476c8c..6d33d056ea9e833c025c8027134d7496e05d5118 100644 (file)
@@ -288,9 +288,12 @@ def _get_deployment_config_file(conf):
     _register_paste_deploy_opts(conf)
     config_file = conf.paste_deploy.config_file
     if not config_file:
-        # Assume paste config is in a paste.ini file corresponding
-        # to the last config file
-        path = conf.config_file[-1].replace(".conf", "-paste.ini")
+        if conf.config_file:
+            # Assume paste config is in a paste.ini file corresponding
+            # to the last config file
+            path = os.path.splitext(conf.config_file[-1])[0] + "-paste.ini"
+        else:
+            return None
     else:
         path = config_file
     return os.path.abspath(path)
@@ -317,6 +320,8 @@ def load_paste_app(conf, app_name=None):
     app_name += _get_deployment_flavor(conf)
 
     conf_file = _get_deployment_config_file(conf)
+    if conf_file is None:
+        raise RuntimeError("Unable to locate config file")
 
     try:
         # Setup logging early