~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/rpc/__init__.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#    License for the specific language governing permissions and limitations
18
18
#    under the License.
19
19
 
20
 
from nova import flags
 
20
"""
 
21
A remote procedure call (rpc) abstraction.
 
22
 
 
23
For some wrappers that add message versioning to rpc, see:
 
24
    rpc.dispatcher
 
25
    rpc.proxy
 
26
"""
 
27
 
21
28
from nova.openstack.common import cfg
22
 
from nova import utils
23
 
 
24
 
 
25
 
rpc_backend_opt = cfg.StrOpt('rpc_backend',
26
 
        default='nova.rpc.impl_kombu',
27
 
        help="The messaging module to use, defaults to kombu.")
28
 
 
29
 
FLAGS = flags.FLAGS
30
 
FLAGS.register_opt(rpc_backend_opt)
 
29
from nova.openstack.common import importutils
 
30
 
 
31
 
 
32
rpc_opts = [
 
33
    cfg.StrOpt('rpc_backend',
 
34
               default='nova.rpc.impl_kombu',
 
35
               help="The messaging module to use, defaults to kombu."),
 
36
    cfg.IntOpt('rpc_thread_pool_size',
 
37
               default=64,
 
38
               help='Size of RPC thread pool'),
 
39
    cfg.IntOpt('rpc_conn_pool_size',
 
40
               default=30,
 
41
               help='Size of RPC connection pool'),
 
42
    cfg.IntOpt('rpc_response_timeout',
 
43
               default=60,
 
44
               help='Seconds to wait for a response from call or multicall'),
 
45
    cfg.ListOpt('allowed_rpc_exception_modules',
 
46
               default=['nova.exception'],
 
47
               help='Modules of exceptions that are permitted to be recreated'
 
48
                    'upon receiving exception data from an rpc call.'),
 
49
    ]
 
50
 
 
51
_CONF = None
 
52
 
 
53
 
 
54
def register_opts(conf):
 
55
    global _CONF
 
56
    _CONF = conf
 
57
    _CONF.register_opts(rpc_opts)
 
58
    _get_impl().register_opts(_CONF)
31
59
 
32
60
 
33
61
def create_connection(new=True):
43
71
 
44
72
    :returns: An instance of nova.rpc.common.Connection
45
73
    """
46
 
    return _get_impl().create_connection(new=new)
 
74
    return _get_impl().create_connection(_CONF, new=new)
47
75
 
48
76
 
49
77
def call(context, topic, msg, timeout=None):
65
93
    :raises: nova.rpc.common.Timeout if a complete response is not received
66
94
             before the timeout is reached.
67
95
    """
68
 
    return _get_impl().call(context, topic, msg, timeout)
 
96
    return _get_impl().call(_CONF, context, topic, msg, timeout)
69
97
 
70
98
 
71
99
def cast(context, topic, msg):
82
110
 
83
111
    :returns: None
84
112
    """
85
 
    return _get_impl().cast(context, topic, msg)
 
113
    return _get_impl().cast(_CONF, context, topic, msg)
86
114
 
87
115
 
88
116
def fanout_cast(context, topic, msg):
102
130
 
103
131
    :returns: None
104
132
    """
105
 
    return _get_impl().fanout_cast(context, topic, msg)
 
133
    return _get_impl().fanout_cast(_CONF, context, topic, msg)
106
134
 
107
135
 
108
136
def multicall(context, topic, msg, timeout=None):
131
159
    :raises: nova.rpc.common.Timeout if a complete response is not received
132
160
             before the timeout is reached.
133
161
    """
134
 
    return _get_impl().multicall(context, topic, msg, timeout)
 
162
    return _get_impl().multicall(_CONF, context, topic, msg, timeout)
135
163
 
136
164
 
137
165
def notify(context, topic, msg):
144
172
 
145
173
    :returns: None
146
174
    """
147
 
    return _get_impl().notify(context, topic, msg)
 
175
    return _get_impl().notify(_CONF, context, topic, msg)
148
176
 
149
177
 
150
178
def cleanup():
172
200
 
173
201
    :returns: None
174
202
    """
175
 
    return _get_impl().cast_to_server(context, server_params, topic, msg)
 
203
    return _get_impl().cast_to_server(_CONF, context, server_params, topic,
 
204
                                      msg)
176
205
 
177
206
 
178
207
def fanout_cast_to_server(context, server_params, topic, msg):
187
216
 
188
217
    :returns: None
189
218
    """
190
 
    return _get_impl().fanout_cast_to_server(context, server_params, topic,
191
 
            msg)
 
219
    return _get_impl().fanout_cast_to_server(_CONF, context, server_params,
 
220
                                             topic, msg)
192
221
 
193
222
 
194
223
_RPCIMPL = None
195
224
 
196
225
 
197
226
def _get_impl():
198
 
    """Delay import of rpc_backend until FLAGS are loaded."""
 
227
    """Delay import of rpc_backend until configuration is loaded."""
199
228
    global _RPCIMPL
200
229
    if _RPCIMPL is None:
201
 
        _RPCIMPL = utils.import_object(FLAGS.rpc_backend)
 
230
        _RPCIMPL = importutils.import_module(_CONF.rpc_backend)
202
231
    return _RPCIMPL