~cbehrens/nova/rpc-refactor

« back to all changes in this revision

Viewing changes to nova/service.py

  • Committer: termie
  • Date: 2011-05-20 01:14:15 UTC
  • Revision ID: github@anarkystic.com-20110520011415-ho2jrdrox19te0o5
cleanup the code for merging

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
        if 'nova-compute' == self.binary:
89
89
            self.manager.update_available_resource(ctxt)
90
90
 
91
 
        conn1 = rpc.Connection.instance(new=True)
92
 
        logging.debug("Creating Consumer connection for Service %s" % \
93
 
                self.topic)
 
91
        self.conn = rpc.Connection.instance(new=True)
 
92
        logging.debug("Creating Consumer connection for Service %s" %
 
93
                      self.topic)
94
94
 
95
95
        # Share this same connection for these Consumers
96
96
        consumer_all = rpc.TopicAdapterConsumer(
97
 
                connection=conn1,
 
97
                connection=self.conn,
98
98
                topic=self.topic,
99
99
                proxy=self)
100
100
        consumer_node = rpc.TopicAdapterConsumer(
101
 
                connection=conn1,
 
101
                connection=self.conn,
102
102
                topic='%s.%s' % (self.topic, self.host),
103
103
                proxy=self)
104
104
        fanout = rpc.FanoutAdapterConsumer(
105
 
                connection=conn1,
 
105
                connection=self.conn,
106
106
                topic=self.topic,
107
107
                proxy=self)
108
108
 
109
 
        cset = rpc.ConsumerSet(conn1, [consumer_all,
110
 
                    consumer_node,
111
 
                    fanout])
 
109
        cset = rpc.ConsumerSet(self.conn, [consumer_all,
 
110
                                           consumer_node,
 
111
                                           fanout])
112
112
 
113
113
        # Wait forever, processing these consumers
114
114
        def _wait():
119
119
 
120
120
        self.csetthread = greenthread.spawn(_wait)
121
121
 
122
 
        #self.timers.append(consumer_all.attach_to_eventlet())
123
 
        #self.timers.append(consumer_node.attach_to_eventlet())
124
 
        #self.timers.append(fanout.attach_to_eventlet())
125
 
 
126
122
        if self.report_interval:
127
123
            pulse = utils.LoopingCall(self.report_state)
128
124
            pulse.start(interval=self.report_interval, now=False)
185
181
        except greenlet.GreenletExit:
186
182
            pass
187
183
        self.stop()
 
184
        rpc.ConnectionPool.put(self.conn)
188
185
        try:
189
186
            db.service_destroy(context.get_admin_context(), self.service_id)
190
187
        except exception.NotFound: