~ubuntu-branches/ubuntu/utopic/maas/utopic

« back to all changes in this revision

Viewing changes to src/maasserver/clusterrpc/utils.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Jeroen Vermeulen, Andres Rodriguez, Jason Hobbs, Raphaël Badin, Louis Bouchard, Gavin Panella
  • Date: 2014-08-21 19:36:30 UTC
  • mfrom: (1.3.1)
  • Revision ID: package-import@ubuntu.com-20140821193630-kertpu5hd8yyss8h
Tags: 1.7.0~beta7+bzr3266-0ubuntu1
* New Upstream Snapshot, Beta 7 bzr3266

[ Jeroen Vermeulen ]
* debian/extras/99-maas-sudoers
  debian/maas-dhcp.postinst
  debian/rules
  - Add second DHCP server instance for IPv6.
* debian/maas-region-controller-min.install
  debian/maas-region-controller-min.lintian-overrides
  - Install deployment user-data: maas_configure_interfaces.py script.
* debian/maas-cluster-controller.links
  debian/maas-cluster-controller.install
  debian/maas-cluster-controller.postinst
  - Reflect Celery removal changes made in trunk r3067.
  - Don't install celeryconfig_cluster.py any longer. 
  - Don't install maas_local_celeryconfig_cluster.py any longer.
  - Don't symlink maas_local_celeryconfig_cluster.py from /etc to /usr.
  - Don't insert UUID into maas_local_celeryconfig_cluster.py.

[ Andres Rodriguez ]
* debian/maas-region-controller-min.postrm: Cleanup lefover files.
* debian/maas-dhcp.postrm: Clean leftover configs.
* Provide new maas-proxy package that replaces the usage of
  squid-deb-proxy:
  - debian/control: New maas-proxy package that replaces the usage
    of squid-deb-proxy; Drop depends on squid-deb-proxy.
  - Add upstrart job.
  - Ensure squid3 is stopped as maas-proxy uses a caching proxy.
* Remove Celery references to cluster controller:
  - Rename upstart job from maas-pserv to maas-cluster; rename
    maas-cluster-celery to maas-cluster-register. Ensure services
    are stopped on upgrade.
  - debian/maintscript: Cleanup config files.
  - Remove all references to the MAAS celery daemon and config
    files as we don't use it like that anymore
* Move some entries in debian/maintscript to
  debian/maas-cluster-controller.maintscript
* Remove usage of txlongpoll and rabbitmq-server. Handle upgrades
  to ensure these are removed correctly.

[ Jason Hobbs ]
* debian/maas-region-controller-min.install: Install
  maas-generate-winrm-cert script.

[ Raphaël Badin ]
* debian/extras/maas-region-admin: Bypass django-admin as it prints
  spurious messages to stdout (LP: #1365130).

[Louis Bouchard]
* debian/maas-cluster-controller.postinst:
  - Exclude /var/log/maas/rsyslog when changing ownership
    (LP: #1346703)

[Gavin Panella]
* debian/maas-cluster-controller.maas-clusterd.upstart:
  - Don't start-up the cluster controller unless a shared-secret has
    been installed.
* debian/maas-cluster-controller.maas-cluster-register.upstart: Drop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
__metaclass__ = type
15
15
__all__ = [
16
16
    'call_clusters',
 
17
    'get_error_message_for_exception',
17
18
    ]
18
19
 
19
20
 
25
26
from maasserver.models import NodeGroup
26
27
from maasserver.rpc import getClientFor
27
28
from maasserver.utils import async
28
 
from provisioningserver.rpc.exceptions import NoConnectionsAvailable
 
29
from provisioningserver.rpc.exceptions import (
 
30
    MultipleFailures,
 
31
    NoConnectionsAvailable,
 
32
    )
29
33
from twisted.python.failure import Failure
30
34
 
31
35
 
52
56
            client = getClientFor(ng.uuid)
53
57
        except NoConnectionsAvailable:
54
58
            logger.error(
55
 
                "Unable to get RPC connection for cluster '%s'", ng.name)
 
59
                "Unable to get RPC connection for cluster '%s' (%s)",
 
60
                ng.cluster_name, ng.uuid)
56
61
            if not ignore_errors:
57
62
                raise ClusterUnavailable(
58
 
                    "Unable to get RPC connection for cluster '%s'" % ng.name)
 
63
                    "Unable to get RPC connection for cluster '%s' (%s)"
 
64
                    % (ng.cluster_name, ng.uuid))
59
65
        else:
60
66
            call = partial(client, command)
61
67
            calls.append(call)
70
76
                    "Failure while communicating with cluster.")
71
77
        else:
72
78
            yield response
 
79
 
 
80
 
 
81
def get_error_message_for_exception(exception):
 
82
    """Return an error message for an exception.
 
83
 
 
84
    If `exception` is a NoConnectionsAvailable error,
 
85
    get_error_message_for_exception() will check to see if there's a
 
86
    UUID listed. If so, this is an error referring to a cluster.
 
87
    get_error_message_for_exception() will return an error message
 
88
    containing the cluster's name (as opposed to its UUID), which is
 
89
    more useful to users.
 
90
 
 
91
    If `exception` is an instance of `MultipleFailures` a single error
 
92
    message will be returned, explaining where to look for more
 
93
    information.
 
94
 
 
95
    Otherwise, if the exception has a message attached, return that.
 
96
    If not, create meaningful error message for the exception and
 
97
    return that instead.
 
98
    """
 
99
    # If we've gt a NoConnectionsAvailable error, check it for a UUID
 
100
    # field. If it's got one, we can report the cluster details more
 
101
    # helpfully.
 
102
    is_no_connections_error = isinstance(
 
103
        exception, NoConnectionsAvailable)
 
104
    has_uuid_field = getattr(exception, 'uuid', None) is not None
 
105
    if (is_no_connections_error and has_uuid_field):
 
106
        cluster = NodeGroup.objects.get_by_natural_key(
 
107
            exception.uuid)
 
108
        return (
 
109
            "Unable to connect to cluster '%s' (%s); no connections "
 
110
            "available." % (cluster.cluster_name, cluster.uuid))
 
111
 
 
112
    if isinstance(exception, MultipleFailures):
 
113
        return (
 
114
            "Multiple failures encountered. See /var/log/maas/maas-django.log "
 
115
            "on the region server for more information.")
 
116
 
 
117
    error_message = unicode(exception)
 
118
    if len(error_message) == 0:
 
119
        error_message = (
 
120
            "Unexpected exception: %s. See "
 
121
            "/var/log/maas/maas-django.log "
 
122
            "on the region server for more information." %
 
123
            exception.__class__.__name__)
 
124
    return error_message