Created new class NovaException. 37/37637/1
authorspisarski <s.pisarski@cablelabs.com>
Mon, 17 Jul 2017 15:28:24 +0000 (09:28 -0600)
committerspisarski <s.pisarski@cablelabs.com>
Mon, 17 Jul 2017 15:28:24 +0000 (09:28 -0600)
Raising NovaException in nova_utils.py instead of Exception.

Change-Id: I9564e43352114df18bccc794a5cd57e20880085f
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
snaps/openstack/utils/nova_utils.py

index 1ced4d7..038b3b1 100644 (file)
@@ -79,9 +79,8 @@ def create_server(nova, neutron, glance, instance_settings, image_settings,
 
     flavor = get_flavor_by_name(nova, instance_settings.flavor)
     if not flavor:
-        raise Exception(
-            'Flavor not found with name - %s',
-            instance_settings.flavor)
+        raise NovaException(
+            'Flavor not found with name - %s', instance_settings.flavor)
 
     image = glance_utils.get_image(glance, image_settings.name)
     if image:
@@ -99,7 +98,7 @@ def create_server(nova, neutron, glance, instance_settings, image_settings,
         return VmInst(name=server.name, inst_id=server.id,
                       networks=server.networks)
     else:
-        raise Exception(
+        raise NovaException(
             'Cannot create instance, image cannot be located with name %s',
             image_settings.name)
 
@@ -430,3 +429,9 @@ def add_floating_ip_to_server(nova, vm, floating_ip, ip_addr):
     """
     vm = get_latest_server_os_object(nova, vm)
     vm.add_floating_ip(floating_ip.ip, ip_addr)
+
+
+class NovaException(Exception):
+    """
+    Exception when calls to the Keystone client cannot be served properly
+    """