~ubuntu-branches/ubuntu/raring/quantum/raring

« back to all changes in this revision

Viewing changes to quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-09-21 13:01:18 UTC
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20120921130118-6x31znohp1psfc74
Tags: upstream-2012.2~rc2
ImportĀ upstreamĀ versionĀ 2012.2~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
from quantum.api.v2 import attributes
42
42
from quantum.common import constants
43
43
from quantum.common import exceptions as exception
 
44
from quantum.common import topics
44
45
from quantum.db import api as db
45
46
from quantum.db import db_base_plugin_v2
 
47
from quantum.db import dhcp_rpc_base
46
48
from quantum.db import models_v2
47
49
from quantum.openstack.common import cfg
 
50
from quantum.openstack.common import context
 
51
from quantum.openstack.common import rpc
 
52
from quantum.openstack.common.rpc import dispatcher
48
53
 
49
54
 
50
55
CONFIG_FILE = "nvp.ini"
94
99
    return db_options, nvp_options, clusters_options
95
100
 
96
101
 
 
102
class NVPRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
 
103
 
 
104
    # Set RPC API version to 1.0 by default.
 
105
    RPC_API_VERSION = '1.0'
 
106
 
 
107
    def __init__(self, rpc_context):
 
108
        self.rpc_context = rpc_context
 
109
 
 
110
    def create_rpc_dispatcher(self):
 
111
        '''Get the rpc dispatcher for this manager.
 
112
 
 
113
        If a manager would like to set an rpc API version, or support more than
 
114
        one class as the target of rpc messages, override this method.
 
115
        '''
 
116
        return dispatcher.RpcDispatcher([self])
 
117
 
 
118
 
97
119
class NVPCluster(object):
98
120
    """Encapsulates controller connection and api_client for a cluster.
99
121
 
268
290
            'base': models_v2.model_base.BASEV2,
269
291
        }
270
292
        db.configure_db(options)
 
293
        self.setup_rpc()
 
294
 
 
295
    def setup_rpc(self):
 
296
        # RPC support for dhcp
 
297
        self.topic = topics.PLUGIN
 
298
        self.rpc_context = context.RequestContext('quantum', 'quantum',
 
299
                                                  is_admin=False)
 
300
        self.conn = rpc.create_connection(new=True)
 
301
        self.callbacks = NVPRpcCallbacks(self.rpc_context)
 
302
        self.dispatcher = self.callbacks.create_rpc_dispatcher()
 
303
        self.conn.create_consumer(self.topic, self.dispatcher,
 
304
                                  fanout=False)
 
305
        # Consume from all consumers in a thread
 
306
        self.conn.consume_in_thread()
271
307
 
272
308
    @property
273
309
    def cluster(self):