|
24 | 24 | import time
|
25 | 25 |
|
26 | 26 | import os_traits
|
| 27 | +from oslo_concurrency import lockutils |
27 | 28 | from oslo_log import log as logging
|
| 29 | +import oslo_messaging as messaging |
28 | 30 |
|
29 | 31 | from nova.compute import instance_actions
|
| 32 | +from nova.compute import rpcapi as compute_rpcapi |
30 | 33 | from nova.compute import utils as compute_utils
|
31 | 34 | import nova.conf
|
32 | 35 | from nova import context
|
33 | 36 | from nova.db import api as db
|
34 | 37 | import nova.image.glance
|
35 | 38 | from nova import objects
|
| 39 | +from nova.objects import base as objects_base |
| 40 | +from nova import rpc |
36 | 41 | from nova import test
|
37 | 42 | from nova.tests import fixtures as nova_fixtures
|
38 | 43 | from nova.tests.functional.api import client as api_client
|
@@ -72,6 +77,26 @@ def generate_new_element(items, prefix, numeric=False):
|
72 | 77 | LOG.debug("Random collision on %s", candidate)
|
73 | 78 |
|
74 | 79 |
|
| 80 | +class StubComputeRPCAPI(compute_rpcapi.ComputeAPI): |
| 81 | + """Stub ComputeAPI that allows us to pin the RPC version of a host. Used to |
| 82 | + simulate rolling upgrade situations where either source, dest or conductor |
| 83 | + are pinned. |
| 84 | + """ |
| 85 | + |
| 86 | + def __init__(self, version): |
| 87 | + self.version = version |
| 88 | + |
| 89 | + @property |
| 90 | + def router(self): |
| 91 | + with lockutils.lock('compute-rpcapi-router'): |
| 92 | + target = messaging.Target(topic='compute', version='5.0') |
| 93 | + version_cap = self.version |
| 94 | + serializer = objects_base.NovaObjectSerializer() |
| 95 | + rpc.get_client(target, version_cap, serializer) |
| 96 | + default_client = self.get_client(target, version_cap, serializer) |
| 97 | + return rpc.ClientRouter(default_client) |
| 98 | + |
| 99 | + |
75 | 100 | class InstanceHelperMixin(object):
|
76 | 101 |
|
77 | 102 | def _wait_for_server_parameter(
|
|
0 commit comments