diff options
| author | Rajaram Mallya <rajarammallya@gmail.com> | 2011-08-25 10:58:45 +0530 |
|---|---|---|
| committer | Rajaram Mallya <rajarammallya@gmail.com> | 2011-08-25 10:58:45 +0530 |
| commit | 0789e762583f3b306aa50c8c74c48256e731eb6c (patch) | |
| tree | 787f18347922471c028b2b529f88ab14c5654be5 /openstack/common | |
| parent | 77b761d6463fcec383c12bf8ee0df1ae1410c464 (diff) | |
| download | oslo-0789e762583f3b306aa50c8c74c48256e731eb6c.tar.gz oslo-0789e762583f3b306aa50c8c74c48256e731eb6c.tar.xz oslo-0789e762583f3b306aa50c8c74c48256e731eb6c.zip | |
Rajaram/Vinkesh | Removed references to Glance in code
Diffstat (limited to 'openstack/common')
| -rw-r--r-- | openstack/common/config.py | 30 | ||||
| -rw-r--r-- | openstack/common/exception.py | 8 | ||||
| -rw-r--r-- | openstack/common/utils.py | 9 |
3 files changed, 20 insertions, 27 deletions
diff --git a/openstack/common/config.py b/openstack/common/config.py index 758d128..7b069f3 100644 --- a/openstack/common/config.py +++ b/openstack/common/config.py @@ -65,7 +65,7 @@ def add_common_options(parser): :param parser: optparse.OptionParser """ help_text = "The following configuration options are common to "\ - "all glance programs." + "this app's programs." group = optparse.OptionGroup(parser, "Common Options", help_text) group.add_option('-v', '--verbose', default=False, dest="verbose", @@ -178,7 +178,7 @@ def setup_logging(options, conf): root_logger.addHandler(handler) -def find_config_file(app_name, options, args): +def find_config_file(app_name, options, args, app_config_dir_name=None): """ Return the first config file found for an application. @@ -187,13 +187,14 @@ def find_config_file(app_name, options, args): * If args[0] is a file, use that * Search for $app.conf in standard directories: * . - * ~.glance/ + * ~.app_config_dir_name/ * ~ - * /etc/glance + * /etc/app_config_dir_name * /etc :retval Full path to config file, or None if no config file found """ + app_config_dir_name = app_config_dir_name or app_name fix_path = lambda p: os.path.abspath(os.path.expanduser(p)) if options.get('config_file'): @@ -205,9 +206,9 @@ def find_config_file(app_name, options, args): # Handle standard directory search for $app_name.conf config_file_dirs = [fix_path(os.getcwd()), - fix_path(os.path.join('~', '.glance')), + fix_path(os.path.join('~', '.' + app_config_dir_name)), fix_path('~'), - '/etc/glance/', + os.path.join('/etc', app_config_dir_name), '/etc'] for cfg_dir in config_file_dirs: @@ -216,7 +217,7 @@ def find_config_file(app_name, options, args): return cfg_file -def load_paste_config(app_name, options, args): +def load_paste_config(app_name, options, args, app_config_dir_name=None): """ Looks for a config file to use for an app and returns the config file path and a configuration mapping from a paste config file. @@ -226,9 +227,9 @@ def load_paste_config(app_name, options, args): * If args[0] is a file, use that * Search for $app_name.conf in standard directories: * . - * ~.glance/ + * ~.app_config_dir_name/ * ~ - * /etc/glance + * /etc/app_config_dir_name * /etc :param app_name: Name of the application to load config for, or None. @@ -241,7 +242,7 @@ def load_paste_config(app_name, options, args): :raises RuntimeError when config file cannot be located or there was a problem loading the configuration file. """ - conf_file = find_config_file(app_name, options, args) + conf_file = find_config_file(app_name, options, args, app_config_dir_name) if not conf_file: raise RuntimeError("Unable to locate any configuration file. " "Cannot load application %s" % app_name) @@ -253,7 +254,7 @@ def load_paste_config(app_name, options, args): % (conf_file, e)) -def load_paste_app(app_name, options, args): +def load_paste_app(app_name, options, args, app_config_dir_name=None): """ Builds and returns a WSGI app from a paste config file. @@ -262,9 +263,9 @@ def load_paste_app(app_name, options, args): * If args[0] is a file, use that * Search for $app_name.conf in standard directories: * . - * ~.glance/ + * ~.app_config_dir_name/ * ~ - * /etc/glance + * /etc/app_config_dir_name * /etc :param app_name: Name of the application to load @@ -274,7 +275,8 @@ def load_paste_app(app_name, options, args): :raises RuntimeError when config file cannot be located or application cannot be loaded from config file """ - conf_file, conf = load_paste_config(app_name, options, args) + conf_file, conf = load_paste_config(app_name, options, + args, app_config_dir_name) try: # Setup logging early, supplying both the CLI options and the diff --git a/openstack/common/exception.py b/openstack/common/exception.py index ed6b039..cd382d6 100644 --- a/openstack/common/exception.py +++ b/openstack/common/exception.py @@ -20,8 +20,6 @@ Exceptions common to OpenStack projects """ import logging -import sys -import traceback class ProcessExecutionError(IOError): @@ -119,9 +117,9 @@ def wrap_exception(f): return _wrap -class GlanceException(Exception): +class AppBaseException(Exception): """ - Base Glance Exception + Base Exception To correctly use this class, inherit from it and define a 'message' property. That message will get printf'd @@ -141,5 +139,5 @@ class GlanceException(Exception): return self._error_string -class InvalidContentType(GlanceException): +class InvalidContentType(AppBaseException): message = "Invalid content type %(content_type)s" diff --git a/openstack/common/utils.py b/openstack/common/utils.py index 45c622e..0d2f89e 100644 --- a/openstack/common/utils.py +++ b/openstack/common/utils.py @@ -20,16 +20,9 @@ System-level utilities and helper functions. """ import datetime -import inspect -import logging -import os -import random -import subprocess -import socket import sys -from glance.common import exception -from glance.common.exception import ProcessExecutionError +from openstack.common import exception TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" |
