Merge "Move notification related code to separate package"
This commit is contained in:
commit
6ff71e5e6a
@ -23,8 +23,8 @@ It is used via a single directive in the .rst file
|
||||
from sphinx.util.compat import Directive
|
||||
from docutils import nodes
|
||||
|
||||
from nova.notifications.objects import base as notification
|
||||
from nova.objects import base
|
||||
from nova.objects import notification
|
||||
|
||||
|
||||
def full_name(cls):
|
||||
|
27
nova/notifications/__init__.py
Normal file
27
nova/notifications/__init__.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright (c) 2016 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# Note(gibi): Importing publicly called functions so the caller code does not
|
||||
# need to be changed after we moved these function inside the package
|
||||
# Todo(gibi): remove these imports after legacy notifications using these are
|
||||
# transformed to versioned notifications
|
||||
from nova.notifications.base import audit_period_bounds # noqa
|
||||
from nova.notifications.base import bandwidth_usage # noqa
|
||||
from nova.notifications.base import image_meta # noqa
|
||||
from nova.notifications.base import info_from_instance # noqa
|
||||
from nova.notifications.base import notify_decorator # noqa
|
||||
from nova.notifications.base import send_api_fault # noqa
|
||||
from nova.notifications.base import send_update # noqa
|
||||
from nova.notifications.base import send_update_with_states # noqa
|
0
nova/notifications/objects/__init__.py
Normal file
0
nova/notifications/objects/__init__.py
Normal file
@ -56,7 +56,6 @@ def register_all():
|
||||
__import__('nova.objects.monitor_metric')
|
||||
__import__('nova.objects.network')
|
||||
__import__('nova.objects.network_request')
|
||||
__import__('nova.objects.notification')
|
||||
__import__('nova.objects.numa')
|
||||
__import__('nova.objects.pci_device')
|
||||
__import__('nova.objects.pci_device_pool')
|
||||
|
@ -19,10 +19,10 @@ from nova import availability_zones
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.i18n import _LW
|
||||
from nova.notifications.objects import base as notification
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
from nova.objects import notification
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
0
nova/tests/unit/notifications/__init__.py
Normal file
0
nova/tests/unit/notifications/__init__.py
Normal file
0
nova/tests/unit/notifications/objects/__init__.py
Normal file
0
nova/tests/unit/notifications/objects/__init__.py
Normal file
@ -15,10 +15,10 @@
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from nova.notifications.objects import base as notification
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
from nova.objects import notification
|
||||
from nova import test
|
||||
|
||||
|
@ -32,10 +32,10 @@ import six
|
||||
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.notifications.objects import base as notification
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
from nova.objects import notification
|
||||
from nova.objects import virt_device_metadata
|
||||
from nova import test
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
|
@ -26,7 +26,7 @@ from nova.compute import task_states
|
||||
from nova.compute import vm_states
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import notifications
|
||||
from nova.notifications import base as notifications
|
||||
from nova import objects
|
||||
from nova.objects import base as obj_base
|
||||
from nova import test
|
||||
@ -417,7 +417,8 @@ class NotificationsTestCase(test.TestCase):
|
||||
|
||||
def sending_no_state_change(context, instance, **kwargs):
|
||||
called[0] = True
|
||||
self.stub_out('nova.notifications._send_instance_update_notification',
|
||||
self.stub_out('nova.notifications.base.'
|
||||
'_send_instance_update_notification',
|
||||
sending_no_state_change)
|
||||
notifications.send_update(self.context, self.instance, self.instance)
|
||||
self.assertTrue(called[0])
|
||||
@ -425,7 +426,8 @@ class NotificationsTestCase(test.TestCase):
|
||||
def test_fail_sending_update(self):
|
||||
def fail_sending(context, instance, **kwargs):
|
||||
raise Exception('failed to notify')
|
||||
self.stub_out('nova.notifications._send_instance_update_notification',
|
||||
self.stub_out('nova.notifications.base.'
|
||||
'_send_instance_update_notification',
|
||||
fail_sending)
|
||||
|
||||
notifications.send_update(self.context, self.instance, self.instance)
|
||||
|
Loading…
Reference in New Issue
Block a user