consolidation of watcher
Change-Id: I9c82ef4d8a81af98afdfc34f5ad496bcade4af6a
This commit is contained in:
@@ -24,7 +24,7 @@ from watcher import version
|
||||
def parse_args(argv, default_config_files=None):
|
||||
rpc.set_defaults(control_exchange='watcher')
|
||||
cfg.CONF(argv[1:],
|
||||
project='watcher',
|
||||
project='python-watcher',
|
||||
version=version.version_info.release_string(),
|
||||
default_config_files=default_config_files)
|
||||
rpc.init(cfg.CONF)
|
||||
|
||||
@@ -29,7 +29,6 @@ from watcher.common.i18n import _
|
||||
from watcher.common.i18n import _LE
|
||||
from watcher.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
exc_log_opts = [
|
||||
@@ -227,6 +226,61 @@ class PatchError(Invalid):
|
||||
|
||||
# decision engine
|
||||
|
||||
|
||||
class BaseException(Exception):
|
||||
|
||||
def __init__(self, desc=""):
|
||||
if (not isinstance(desc, basestring)):
|
||||
raise IllegalArgumentException(
|
||||
"Description must be an instance of str")
|
||||
|
||||
desc = desc.strip()
|
||||
|
||||
self._desc = desc
|
||||
|
||||
def get_description(self):
|
||||
return self._desc
|
||||
|
||||
def get_message(self):
|
||||
return "An exception occurred without a description."
|
||||
|
||||
def __str__(self):
|
||||
return self.get_message()
|
||||
|
||||
|
||||
class IllegalArgumentException(BaseException):
|
||||
def __init__(self, desc):
|
||||
BaseException.__init__(self, desc)
|
||||
|
||||
if self._desc == "":
|
||||
raise IllegalArgumentException("Description cannot be empty")
|
||||
|
||||
def get_message(self):
|
||||
return self._desc
|
||||
|
||||
|
||||
class NoSuchMetric(BaseException):
|
||||
def __init__(self, desc):
|
||||
BaseException.__init__(self, desc)
|
||||
|
||||
if self._desc == "":
|
||||
raise NoSuchMetric("No such metric")
|
||||
|
||||
def get_message(self):
|
||||
return self._desc
|
||||
|
||||
|
||||
class NoDataFound(BaseException):
|
||||
def __init__(self, desc):
|
||||
BaseException.__init__(self, desc)
|
||||
|
||||
if self._desc == "":
|
||||
raise NoSuchMetric("no rows were returned")
|
||||
|
||||
def get_message(self):
|
||||
return self._desc
|
||||
|
||||
|
||||
class ClusterEmpty(WatcherException):
|
||||
message = _("The list of hypervisor(s) in the cluster is empty.'")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user