diff --git a/watcher/common/exception.py b/watcher/common/exception.py index f962b3bbe..dcb489ec9 100644 --- a/watcher/common/exception.py +++ b/watcher/common/exception.py @@ -447,6 +447,11 @@ class InstanceNotFound(ComputeResourceNotFound): msg_fmt = _("The instance '%(name)s' could not be found") +class InstanceNotMapped(ComputeResourceNotFound): + msg_fmt = _("The mapped compute node for instance '%(uuid)s' " + "could not be found.") + + class ComputeNodeNotFound(ComputeResourceNotFound): msg_fmt = _("The compute node %(name)s could not be found") diff --git a/watcher/decision_engine/model/model_root.py b/watcher/decision_engine/model/model_root.py index ad85bdd9c..1845638de 100644 --- a/watcher/decision_engine/model/model_root.py +++ b/watcher/decision_engine/model/model_root.py @@ -170,7 +170,7 @@ class ModelRoot(nx.DiGraph, base.Model): node = self._get_by_uuid(node_uuid) if isinstance(node, element.ComputeNode): return node - raise exception.ComputeNodeNotFound(name=instance_uuid) + raise exception.InstanceNotMapped(uuid=instance_uuid) @lockutils.synchronized("model_root") def get_all_instances(self): @@ -211,7 +211,7 @@ class ModelRoot(nx.DiGraph, base.Model): key=lambda inst: inst.uuid): try: self.get_node_by_instance_uuid(instance.uuid) - except (exception.InstanceNotFound, exception.ComputeNodeNotFound): + except exception.ComputeResourceNotFound: root.append(instance.as_xml_element()) return etree.tostring(root, pretty_print=True).decode('utf-8') diff --git a/watcher/decision_engine/model/notification/nova.py b/watcher/decision_engine/model/notification/nova.py index a2254275e..5c885bd14 100644 --- a/watcher/decision_engine/model/notification/nova.py +++ b/watcher/decision_engine/model/notification/nova.py @@ -160,7 +160,7 @@ class NovaNotification(base.NotificationEndpoint): current_node = ( self.cluster_data_model.get_node_by_instance_uuid( instance.uuid)) - except exception.ComputeNodeNotFound as exc: + except exception.ComputeResourceNotFound as exc: LOG.exception(exc) # If we can't create the node, # we consider the instance as unmapped