summaryrefslogtreecommitdiff
path: root/nova/tests/unit/test_notifications.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Remove (almost) all references to 'instance_type'"Zuul2021-06-131-3/+3
|\
| * Remove (almost) all references to 'instance_type'Stephen Finucane2021-03-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | This continues on from I81fec10535034f3a81d46713a6eda813f90561cf and removes all other references to 'instance_type' where it's possible to do so. The only things left are DB columns, o.vo fields, some unversioned objects, and RPC API methods. If we want to remove these, we can but it's a lot more work. Change-Id: I264d6df1809d7283415e69a66a9153829b8df537 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | Use NotificationFixture for legacy notifications tooBalazs Gibizer2021-05-241-24/+23
| | | | | | | | Change-Id: Ic16c575c8f36e8a3c50b6e302b9fdf961cb3ed22
* | Create a fixture around fake_notifierBalazs Gibizer2021-05-241-29/+29
|/ | | | | | | | | | | The fake_notifier uses module globals and also needs careful stub and reset calls to work properly. This patch wraps the fake_notifier into a proper Fixture that automates the complexity. This is fairly rage patch but it does not change any logic just redirect calls from the fake_notifier to the new NotificationFixture Change-Id: I456f685f480b8de71014cf232a8f08c731605ad8
* virt: Remove 'get_all_bw_counters' APIStephen Finucane2020-11-241-24/+4
| | | | | | | | | This one is a little more involved because there are persistent objects and versioned notifications to worry about, neither of which we can remove right now. Change-Id: Ic7c330ee1cccdc44a2a555c16cb6090eecbf6ce1 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* nova-net: Remove dependency on nova-net from fake cacheStephen Finucane2020-01-081-3/+3
| | | | | | | | | There's more to be done here around making the cached objects look like something that would be generated by neutron, but this is good enough for now. Change-Id: I08aa4d581720b0f6cd1dabccc98dac210d1a1663 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* nova-net: Remove final references to nova-networkStephen Finucane2020-01-081-10/+1
| | | | | | | | | | | Strip out everything matching '(is|use)_neutron', except the tests for nova-network code and two other places that these tests rely on. Along the way, remove a whole load of apparently unnecessary mocking that clearly wasn't caught when we switched over the bulk of testing to use the neutron network driver. Change-Id: Ifa9c5c468400261a5e1f66b72c575845173a4f8f Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Remove deprecated 'default_flavor' config optionTakashi NATSUME2019-04-301-2/+1
| | | | | | | | | | | The deprecated 'default_flavor' option has been removed. The following methods in nova/compute/flavors.py have been removed because they are only used in unit tests. * get_default_flavor * get_flavor_by_name Change-Id: If1e461da382f707be2b5ba89f74f77269f0909dd
* Use uuidsentinel from oslo.utilsEric Fried2018-09-051-1/+2
| | | | | | | | | | | | oslo.utils release 3.37.0 [1] introduced uuidsentinel [2]. This change rips out nova's uuidsentinel and replaces it with the one from oslo.utils. [1] https://review.openstack.org/#/c/599754/ [2] https://review.openstack.org/#/c/594179/ Change-Id: I7f5f08691ca3f73073c66c29dddb996fb2c2b266 Depends-On: https://review.openstack.org/600041
* Improve NeutronFixture and remove unncessary stubbingBalazs Gibizer2018-08-021-3/+1
| | | | | | | | | | | | | | | | With a small improvement on NeutronFixture that allows creating more than two ports we can let our tests to exercise and therefore cover most of the neutronv2/api code as well. To do that this path removes a lot of fake_network.set_stub_network_methods() calls from the tests. The remaining calls are not that trivial to remove so those are left in for a later patch. The numa functional tests uses the libvirt fixture and during the guest config xml generation it tries to instantiate OVOs from os_vif. To make this work the libvirt fixture has to make sure that the os_vif.initialize() is called as that call registers the OVOs. Change-Id: I1dbccc2be6ba79bf267edac9208c80e187e6256a
* Add action initiator attribute to the instance payloadshuangyang.qian2018-07-031-0/+15
| | | | | | | | | | | | | | | The instance action notifications contain the user id and the project id of the owner of the instance. However an instance action might be initiated by another user. It could be another user from the same project or can be an admin from the admin project. To be able to distinguish between the user who initiated the instance action from the user owning the instance we need to add two new fields to the instance action notifications, action_initiator_user and action_initiator_project Change-Id: I649d8a27baa8840bc1bb567fef027c749c663432 Closes-bug: #1744658 Blueprint: add-action-initiator-to-instance-action-notifications
* Remove deprecated monkey_patch config optionsMatt Riedemann2018-05-161-21/+0
| | | | | | | | | | These were deprecated in Queens: Id793ac2c5cdc5dc473f95eac53b77617a1e389da And can now be removed. Change-Id: I27518d1154ec09c57700905bc58ae6a3ce1d8049
* Remove vestigial system_metadata param from info_from_instance()Matt Riedemann2018-04-231-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | The system_metadata argument to info_from_instance() was not used so it's removed in this change, along with all callers of that method, which goes quite a ways. Also, the docstring for the system_metadata argument to notify_usage_exists() is updated since it is passed in one specific place: rebuild with a new image. In that case, nova-api saves off the original instance system_metadata before resetting the system_metadata based on the new image to rebuild, which is then passed down through nova-conductor and nova-compute where it eventually gets used to override "image_meta" in the payload created in info_from_instance(). It's weird, yes, and essentially means that for legacy versioned notifications, the instance payload will always contain the image_meta for the instance before it's rebuilt with the new image, which is something we don't do for versioned notifications. Test test_local_delete_without_info_cache is removed since it's (1) weird in that it is doing mox-like stuff in a mock-based test and (2) the code it was meant to test from change Ie0bba032615d3da06cdd95b221beb37a9b8a377d no longer exists. Change-Id: Ia1820334dcaceca9d7fa874dd7c553fa1c5befec Closes-Bug: #1764390
* Remove dead code of api.fault notification sendingBalazs Gibizer2017-10-091-91/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on the description of the notify_on_api_faults config option [1] and the code that uses it [2] nova sends and api.fault notification if the nova-api service encounters an unhandle exception. There is a FaultWrapper class [3] added to the pipeline of the REST request which catches every exception and calls the notification sending. Based on some debugging in devstack this FaultWrapper never catches any exception. Every REST API method is decorated with expected_errors decorator [5] which as a last resort translate the unexpected exception to HTTPInternalServerError. In the wsgi stack the actual REST api call is guarded with ResourceExceptionHandler context manager [7] which translates HTTPException to a Fault [8]. Then Fault is catched and translated to the REST response [7]. This way the exception never propagates back to the FaultWrapper and therefore the api.fault notification is never emitted. Based on the git history of the expected_errors decorator this notification was never emitted for v2.1 API and as the v2.0 API now supported with the same codebase than v2.1 it is not emitted for v2.0 calls either. As nobody reported a bug I assume that nobody tried to use this notification for a very long time. Therefore instead of fixing this bug this patch propses to remove the dead code. See a bit more detailed description on the ML [9]. [1] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/conf/notifications.py#L49 [2] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/notifications/base.py#L84 [3] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/__init__.py#L78 [5] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/extensions.py#L325 [7] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/wsgi.py#L637 [8] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/wsgi.py#L418 [9] http://lists.openstack.org/pipermail/openstack-dev/2017-June/118639.html Change-Id: I608b6ebdc69d31eb2a11ac6479fa4f2e8c20f7d1 Closes-Bug: #1699115
* use unicode in tests to avoid SQLA warningSean Dague2017-09-181-2/+2
| | | | | | | This suppresses a warning from SQLA which is only popping up in the tests. Something we can and should avoid. Change-Id: I3d1cf3a5dd817e0896809145fcb8fdd25a3a5d78
* Merge "Change default for [notifications]/default_publisher_id to $host"Jenkins2017-08-291-0/+4
|\
| * Change default for [notifications]/default_publisher_id to $hostMatt Riedemann2017-08-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | The default used in code for CONF.notifications.default_publisher_id is CONF.host, which is a free-form StrOpt. In an upcoming change, the "my_ip" option is going to be changed from a StrOpt to an IPOpt, so we made the default value change for the default_publisher_id option before that. Change-Id: Ia85130f66bd5a60097e8967064559fd0962d06fd Closes-Bug: #1713150
* | Use enum value instead of string service nameBalazs Gibizer2017-07-251-3/+3
|/ | | | | | | | | | | | | In the nova notification code path the nova service / binary names are hardcoded. There is a possible confusion as the REST API uses 'nova-osapi_compute' while the notifications use 'nova-api' as the name of the nova compute service binary. To avoid possible mixing of the names a new enum is introduced in the notification code path with the valid values form notification perspective. Change-Id: Ia85a8b6c34a3efaf3ef509aab316294b9c0c2fd1 Closes-Bug: #1696152
* Make notification publisher_id consistentBalazs Gibizer2017-07-061-1/+1
| | | | | | | | | | The publisher_id of the versioned instance.update notification contains 'conductor' as the source of the notification but every other versioned notification use names like 'nova-compute', 'nova-api', 'nova-scheduler'. This patch fixes this inconsistency. Change-Id: I61c1d1676e74e367b4aeef6a6d3a7bb2ffacee23 Closes-Bug: #1702667
* Make all timestamps formats equalBalazs Gibizer2017-06-141-0/+9
| | | | | | | | | | | Prior to this patch notifications for instance uses different format for datetime fields This patch aligns that formating Co-Authored-By: Timofey Durakov <tdurakov@mirantis.com> Change-Id: I946a92601e4268bb224fc35b2052bca7436531f4 Closes-Bug: #1657428
* Send out notifications when instance tags changedKevin_Zheng2017-06-061-4/+4
| | | | | | | | | | | | | | | This patch adds notifications when instance tags changed, as tag is commonly used for searching and filtering, and projects like searchlight depends on the notifications. To avoid unnecessarily building a notification payload when notifications are disabled, this change also adds the if_notifications_enabled decorator to send_instance_update_notification. Change-Id: I03c8e8225e51fd80580772752c0b292987e34218 Implements: bp send-tag-notification
* Move null_safe funcs to module levelBalazs Gibizer2017-05-111-0/+15
| | | | | | | | | The null_safe_ functions needs to be used from more than one payload generator function therefore it needs to be moved to module level. Also this patch adds missing test coverage to these functions. Change-Id: Iedbb8db78793c963ef3039ff602e70e8c0aa4c0c
* add tags field to instance.update notificationSujitha2017-04-211-0/+10
| | | | | | | | | | Tags field is added to the InstanceUpdatePayload based on the tags field fo the related Instance object. Adding tags to instance.create notification will be handled in the bp tag-instances-when-boot. Implements: bp additional-notification-fields-for-searchlight Change-Id: Ifad6487de200767fc16d035ad830c77bba49154a
* conf: added notifications groupMaciej Szankin2017-01-031-10/+13
| | | | | | | | | | | Notifications related configuration options have been moved from the default group to the ``notifications`` group. Also, ``default_notification_level`` has been renamed to avoid naming redundancy. Blueprint centralize-config-options-ocata Change-Id: I09dc358fabc84f7bf37d40d48b0652a10d9b8903
* Make notifications module use flavor capacity attributesDan Smith2016-07-121-0/+18
| | | | | | | This makes the notifications module use instance.flavor.$resource instead of instance.$resource. Change-Id: Ic31589aea0a2948179f6b3fb9cb759da4e2a2e78
* Transform instance.update notificationBalazs Gibizer2016-06-301-29/+116
| | | | | Change-Id: I4e1ca357322bdbcb95e4803001f4a7dc1bd37f04 Implements: bp versioned-notification-transformation-newton
* Merge "Remove invalid test of config option default_notification_level"Jenkins2016-06-131-25/+0
|\
| * Remove invalid test of config option default_notification_levelChangBo Guo(gcb)2016-06-091-25/+0
| | | | | | | | | | | | | | | | | | Config option default_notification_level only accepts values in [DEBUG, INFO, WARN, ERROR, CRITICAL], other value will lead ValueError, so don't test invalid value in Nova. Change-Id: I5431dcfd4f3b41833695c2559e737ee0d2961e87 Related-Bug: #1517839
* | Stop using mox stubs in tests/unit/fake_notifierBalazs Gibizer2016-06-101-1/+1
| | | | | | | | | | | | | | | | | | Replace 'stubs.Set' with 'stub_out' in the following files. * nova/tests/unit/fake_notifier.py Change-Id: Ie161780e748e3e8f1959a99d6d69e3518ccc958e Implements: blueprint remove-mox-newton
* | Move notification related code to separate packageBalazs Gibizer2016-06-081-3/+5
|/ | | | | | | | | | | | | To be able to separate the versioned notification related object model from the nova internal object model a new nova.notification.object package is introduced. As nova had nova/notifications.py already in the tree the code from that file is moved into the new nova.notification package as a first step. Implements: bp versioned-notification-transformation-newton Change-Id: I315f548180c260c22a2ebcf7b7cb56d284b6e580
* Merge "Fix invalid uuid warnings"Jenkins2016-05-191-1/+2
|\
| * Fix invalid uuid warningssrushti2016-05-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, unit testcases emit FutureWarnings from oslo.versionedobjects about invalid uuids as documented here[1]. This commit changes these tests to use valid uuids so that when they are run these warnings are no longer emitted. [1] http://docs.openstack.org/developer/oslo.versionedobjects/api/fields.html#oslo_versionedobjects.fields.UUIDField Closes-Bug: #1557378 Change-Id: I21a60e916e183f7c0fc6193d4b7caa88ae3b6d56
* | Merge "Fixes bug with notify_decorator bad getattr default value"Jenkins2016-05-111-0/+25
|\ \ | |/ |/|
| * Fixes bug with notify_decorator bad getattr default valueAndrei V. Ostapenko2016-03-201-0/+25
| | | | | | | | | | | | | | | | | | getattr tries to get method from notifier by its name in config. If it fails, string 'info' is returned and called. This patch changes default value from string 'info' to method notifier.info Closes-bug: #1496197 Change-Id: Id005de79980db3c8ea7256b360a2b2c47bfdace7
* | remove the use of import_object_nsSean Dague2016-04-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function dates back to I5eee3389c7719d5f361532b0eddaa249233283a5 when it was introduced to make it easier to seamlessly load drivers from out of tree. This no long is something we want to do. Also, the way this works it means that it makes it really hard to debug when an import of a driver fails (as it's masked out). This is the only use of the function in all of OpenStack, it should just go away as an anti-pattern. Tests were updated to pass, and the compute_driver flag was removed from tests that passed even when they now had completely bogus values. Change-Id: I65a537292aa8eda9f3d89e408caa50c445f2050a
* | remove glance deprecated configSean Dague2016-03-311-0/+2
|/ | | | | | | | | | This removes the very old glance config options which were deprecated in I9054bcfb7f5a4a31f0bbfd770c00c767f3d165ba in favor of glance.api_servers config option. This is required to clear out any default glance servers so that we could pull from the service catalog as a default in the future. Change-Id: Ie2d767c4422ef339d6dcb826f3c8ba3c7cf79f85
* Remove unused CONF importsMichael Still2016-02-151-3/+0
| | | | | | | | | | | While reviewing config centralization patches I realized that we have a fair few files where we import cfg or setup CONF, but never actually use config variables. This patch cleans those up, but I am sure we'll add more as we move more flags around. Change-Id: I5851bbae2fa198a4e9be149a5836bea813848d89
* config options: Centralise 'virt.driver' optionsStephen Finucane2016-02-111-3/+2
| | | | | | | | | Add options from 'virt.driver'. These options are part of the 'DEFAULT' group but are included in the "nova.conf.virt" file in hope that they can eventually be moved to their own group. Change-Id: Icf6084c156c4990ac60c778c28a48ae5ab97273a Implements: bp centralize-config-options
* Merge "Use stub_out and mock to remove mox:part 3"Jenkins2016-01-151-4/+3
|\
| * Use stub_out and mock to remove mox:part 3jichenjc2016-01-131-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change replaces the use of stubs in a few files with stub_out, which was introduced in test.py. Also, remove mox usage in some of the files. unit/test_block_device.py unit/test_context.py unit/test_crypto.py unit/test_metadata.py unit/test_notifications.py Part of bp:remove-mox Change-Id: Ibb8a87b34d5f238e08469883361297757a467765
* | Replace stubs.Set with stub_out (fakes)Diana Clarke2016-01-131-2/+2
|/ | | | | | | | | | | | | | | | | | | | | As part of the ongoing effort to stop using mox, start replacing stubs.Set calls with stub_out. Limit the scope of this patch to the following fake functions: - fake_get_instance_nw_info - stub_nw_info - stub_out_instance_quota - stub_out_networking - stub_out_nw_api - stub_out_nw_api_get_instance_nw_info - set_stub_network_methods - stub_out_network_cleanup - unset_stub_network_methods Part of bp:remove-mox Change-Id: I70215fb25ef25422786b96d33c91d8f1d4760a23
* Remove Instance object flavor helper methods only used in testsHans Lindgren2015-12-031-2/+1
| | | | | | | | | These methods used to help with on-the-fly conversion of stored flavor info from it's old location in system metadata to instance extra. Since this is no longer required and since the only remaning uses are in tests, remove the methods and fix the tests as needed. Change-Id: Ia96106602be5cb256f78e3fe71e908627120657a
* Fix notify_decorator errorsEdwin Zhai2015-08-111-0/+24
| | | | | | | | | | | * getattr is built-in function, so should not be used as attribute. * When ctxt is None, rpc.get_notifier('api').info(ctxt, name, body) leads NoneType exception at context.to_dict(). So we need guarantee one valid context here. Closes-Bug: #1476931 Change-Id: I25953467aca641448d25b2d63352f756ec3655aa
* Handle InstanceNotFound when sending instance update notificationMatt Riedemann2015-06-111-0/+30
| | | | | | | | | | | | | | | | | When Tempest (or any automated client) is waiting for an instance to be ACTIVE but goes to ERROR state, it immediately fails a test and deletes the instance. The instance could be deleted by the time the instance update notification processing happens so there is a race where that could fail with InstanceNotFound. That will get traced to the conductor logs and we should try to keep the conductor logs as clean as possible from expected exceptions. This handles InstanceNotFound and just logs it at debug rather than trace out the exception. Closes-Bug: #1455640 Change-Id: Iaee147051afb59f7991f8dfef3bd3072c28f829d
* Be more forgiving to empty context in notificationDavanum Srinivas2015-03-311-0/+70
| | | | | | | | | | | | We seem to call rpc.get_notifier('api').error(None, 'api.fault', payload) in notifications.py, where the first parameter is context. This eventually calls context.to_dict() in nova/rpc.py, which breaks for a NoneType object. So we should pick the current context from oslo_context or switch to the admin context. Co-Authored-By: Pranesh Pandurangan <praneshpg@gmail.com> Closes-Bug: 1360911 Change-Id: Ic37e184a56377739cd7cda5ba4bde236990fef9e
* Merge "Ensure publisher_id is set correctly in notifications"Jenkins2015-02-101-0/+3
|\
| * Ensure publisher_id is set correctly in notificationsDavanum Srinivas2015-02-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | We need to pass the service parameter else the publisher_id is set to "None.node-1". There are many code paths that end up in get_noftifier, so let's just handle it there just like we default to CONF.host. Also the self.notifier in the resource_tracker was not being used, so get rid of it. Closes-Bug: #1416435 Change-Id: I8838b961e49496cc85913a04bd99f9845ff308c3
* | Switch to using oslo_* instead of oslo.*Davanum Srinivas2015-02-061-1/+1
|/ | | | | | | | | | | | | | | | | | | The oslo team is recommending everyone to switch to the non-namespaced versions of libraries. Updating the hacking rule to include a check to prevent oslo.* import from creeping back in. This commit includes: - using oslo_utils instead of oslo.utils - using oslo_serialization instead of oslo.serialization - using oslo_db instead of oslo.db - using oslo_i18n instead of oslo.i18n - using oslo_middleware instead of oslo.middleware - using oslo_config instead of oslo.config - using oslo_messaging instead of "from oslo import messaging" - using oslo_vmware instead of oslo.vmware Change-Id: I3e2eb147b321ce3e928817b62abcb7d023c5f13f
* Fix up some instance object creation issues in testsDan Smith2015-01-291-2/+3
| | | | | | | This cleans up a lot of cruft (and offenses) in tests around creating instance objects with flavors. Change-Id: Ibf8ccd5fe896a436649d11038948bd47cb304632
* Changed testcase 'test_send_on_vm_change' to test vm changeNuman Siddique2014-11-301-2/+2
| | | | | | | | | This patch changed the test case NotificationsTestCase.test_send_on_vm_change to test the vm change instead of the task change Change-Id: I244c5eca5b5b2a254b14126d92e020f072714ade Closes-bug: #1397247