~lutostag/ubuntu/trusty/maas/1.5.2+packagefix

« back to all changes in this revision

Viewing changes to src/maasserver/views/rpc.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-03-28 10:43:53 UTC
  • mto: This revision was merged to the branch mainline in revision 57.
  • Revision ID: package-import@ubuntu.com-20140328104353-ekpolg0pm5xnvq2s
Tags: upstream-1.5+bzr2204
ImportĀ upstreamĀ versionĀ 1.5+bzr2204

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from django.http import HttpResponse
26
26
from maasserver import eventloop
27
 
from provisioningserver.utils import get_all_interface_addresses
28
27
 
29
28
 
30
29
def info(request):
34
33
    tuples on which the region has listening RPC endpoints.
35
34
    """
36
35
    try:
37
 
        rpc_service = eventloop.services.getServiceNamed("rpc")
 
36
        advertiser = eventloop.services.getServiceNamed("rpc-advertise")
38
37
    except KeyError:
39
 
        endpoints = {}  # No endpoints.
 
38
        # RPC advertising service has not been created, so we declare
 
39
        # that there are no endpoints *at all*.
 
40
        endpoints = {}
40
41
    else:
41
 
        port = rpc_service.getPort()
42
 
        addrs = get_all_interface_addresses()
43
 
        endpoints = {
44
 
            eventloop.loop.name: [
45
 
                (addr, port) for addr in addrs
46
 
            ],
47
 
        }
 
42
        if advertiser.running:
 
43
            endpoints = {}
 
44
            for name, addr, port in advertiser.dump():
 
45
                if name in endpoints:
 
46
                    endpoints[name].append((addr, port))
 
47
                else:
 
48
                    endpoints[name] = [(addr, port)]
 
49
        else:
 
50
            # RPC advertising service is not running, so we declare that
 
51
            # there are no endpoints *at all*.
 
52
            endpoints = {}
48
53
 
49
54
    # Each endpoint is an entry point into this event-loop.
50
55
    info = {"eventloops": endpoints}