|
19 | 19 |
|
20 | 20 | import fixtures |
21 | 21 | import netaddr |
| 22 | +from neutron_lib.callbacks import priority_group |
22 | 23 | from neutron_lib import constants |
23 | 24 | from neutron_lib.services.logapi import constants as log_const |
24 | 25 | from neutron_lib.utils import helpers |
|
27 | 28 | from oslo_utils import timeutils |
28 | 29 |
|
29 | 30 |
|
30 | | -# NOTE(yamahata): from neutron-lib 1.9.1, callback priority was added and |
31 | | -# priority_group module was added for constants of priority. |
32 | | -# test the existence of the module of priority_group to check if |
33 | | -# callback priority is supported or not. |
34 | | -_CALLBACK_PRIORITY_SUPPORTED = True |
| 31 | +# NOTE(ykarel): from neutron-lib 3.9.0, cancellable flag was added |
| 32 | +# test the existence of the is_cancellable_event function to check if |
| 33 | +# cancellable flag is supported or not. This compatibility check can |
| 34 | +# be removed once neutron-lib >= 3.9.0 in requirements.txt. |
| 35 | +_CANCELLABLE_FLAG_SUPPORTED = True |
35 | 36 | try: |
36 | | - from neutron_lib.callbacks import priority_group # noqa |
| 37 | + from neutron_lib.callbacks.events import is_cancellable_event # noqa |
37 | 38 | except ImportError: |
38 | | - _CALLBACK_PRIORITY_SUPPORTED = False |
| 39 | + _CANCELLABLE_FLAG_SUPPORTED = False |
39 | 40 |
|
40 | 41 | LAST_RANDOM_PORT_RANGE_GENERATED = 1 |
41 | 42 |
|
@@ -146,12 +147,14 @@ def make_mock_plugin_json_encodable(plugin_instance_mock): |
146 | 147 |
|
147 | 148 |
|
148 | 149 | def get_subscribe_args(*args): |
149 | | - # NOTE(yamahata): from neutron-lib 1.9.1, callback priority was added. |
150 | | - # old signature: (callback, resource, event) |
151 | | - # new signature: (callback, resource, event, priority=PRIORITY_DEFAULT) |
152 | | - if len(args) == 3 and _CALLBACK_PRIORITY_SUPPORTED: |
153 | | - args = list(args) # don't modify original list |
154 | | - args.append(priority_group.PRIORITY_DEFAULT) |
| 150 | + args = list(args) # don't modify original list |
| 151 | + args.append(priority_group.PRIORITY_DEFAULT) |
| 152 | + # NOTE(ykarel): from neutron-lib 3.9.0, cancellable flag was added. |
| 153 | + # old signature: (callback, resource, event, priority=PRIORITY_DEFAULT) |
| 154 | + # new signature: (callback, resource, event, priority=PRIORITY_DEFAULT, |
| 155 | + # cancellable=False) |
| 156 | + if len(args) == 4 and _CANCELLABLE_FLAG_SUPPORTED: |
| 157 | + args.append(False) |
155 | 158 | return args |
156 | 159 |
|
157 | 160 |
|
|
0 commit comments