~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/openstack/common/rpc/service.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2010 United States Government as represented by the
 
4
# Administrator of the National Aeronautics and Space Administration.
 
5
# All Rights Reserved.
 
6
# Copyright 2011 Red Hat, Inc.
 
7
#
 
8
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
9
#    not use this file except in compliance with the License. You may obtain
 
10
#    a copy of the License at
 
11
#
 
12
#         http://www.apache.org/licenses/LICENSE-2.0
 
13
#
 
14
#    Unless required by applicable law or agreed to in writing, software
 
15
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
16
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
17
#    License for the specific language governing permissions and limitations
 
18
#    under the License.
 
19
 
 
20
from nova.openstack.common.gettextutils import _
 
21
from nova.openstack.common import log as logging
 
22
from nova.openstack.common import rpc
 
23
from nova.openstack.common.rpc import dispatcher as rpc_dispatcher
 
24
from nova.openstack.common import service
 
25
 
 
26
 
 
27
LOG = logging.getLogger(__name__)
 
28
 
 
29
 
 
30
class Service(service.Service):
 
31
    """Service object for binaries running on hosts.
 
32
 
 
33
    A service enables rpc by listening to queues based on topic and host."""
 
34
    def __init__(self, host, topic, manager=None):
 
35
        super(Service, self).__init__()
 
36
        self.host = host
 
37
        self.topic = topic
 
38
        if manager is None:
 
39
            self.manager = self
 
40
        else:
 
41
            self.manager = manager
 
42
 
 
43
    def start(self):
 
44
        super(Service, self).start()
 
45
 
 
46
        self.conn = rpc.create_connection(new=True)
 
47
        LOG.debug(_("Creating Consumer connection for Service %s") %
 
48
                  self.topic)
 
49
 
 
50
        dispatcher = rpc_dispatcher.RpcDispatcher([self.manager])
 
51
 
 
52
        # Share this same connection for these Consumers
 
53
        self.conn.create_consumer(self.topic, dispatcher, fanout=False)
 
54
 
 
55
        node_topic = '%s.%s' % (self.topic, self.host)
 
56
        self.conn.create_consumer(node_topic, dispatcher, fanout=False)
 
57
 
 
58
        self.conn.create_consumer(self.topic, dispatcher, fanout=True)
 
59
 
 
60
        # Consume from all consumers in a thread
 
61
        self.conn.consume_in_thread()
 
62
 
 
63
    def stop(self):
 
64
        # Try to shut the connection down, but if we get any sort of
 
65
        # errors, go ahead and ignore them.. as we're shutting down anyway
 
66
        try:
 
67
            self.conn.close()
 
68
        except Exception:
 
69
            pass
 
70
        super(Service, self).stop()