~corey.bryant/charms/trusty/neutron-gateway/git-1531612

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/amulet/deployment.py

  • Committer: Liam Young
  • Date: 2015-10-20 08:50:45 UTC
  • mfrom: (151.2.4 neutron-gateway)
  • Revision ID: liam.young@canonical.com-20151020085045-4hesf82vqf5s3c7c
Tags: 15.10
[1chb1n, r=gnuoy] wait for workload status before testing; add service and relations to satisfy workload status. enable wily test

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# You should have received a copy of the GNU Lesser General Public License
15
15
# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
16
16
 
 
17
import re
17
18
import six
18
19
from collections import OrderedDict
19
20
from charmhelpers.contrib.amulet.deployment import (
114
115
        for service, config in six.iteritems(configs):
115
116
            self.d.configure(service, config)
116
117
 
 
118
    def _auto_wait_for_status(self, message=None, exclude_services=None,
 
119
                              timeout=1800):
 
120
        """Wait for all units to have a specific extended status, except
 
121
        for any defined as excluded.  Unless specified via message, any
 
122
        status containing any case of 'ready' will be considered a match.
 
123
 
 
124
        Examples of message usage:
 
125
 
 
126
          Wait for all unit status to CONTAIN any case of 'ready' or 'ok':
 
127
              message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE)
 
128
 
 
129
          Wait for all units to reach this status (exact match):
 
130
              message = 'Unit is ready'
 
131
 
 
132
          Wait for all units to reach any one of these (exact match):
 
133
              message = re.compile('Unit is ready|OK|Ready')
 
134
 
 
135
          Wait for at least one unit to reach this status (exact match):
 
136
              message = {'ready'}
 
137
 
 
138
        See Amulet's sentry.wait_for_messages() for message usage detail.
 
139
        https://github.com/juju/amulet/blob/master/amulet/sentry.py
 
140
 
 
141
        :param message: Expected status match
 
142
        :param exclude_services: List of juju service names to ignore
 
143
        :param timeout: Maximum time in seconds to wait for status match
 
144
        :returns: None.  Raises if timeout is hit.
 
145
        """
 
146
 
 
147
        if not message:
 
148
            message = re.compile('.*ready.*', re.IGNORECASE)
 
149
 
 
150
        if not exclude_services:
 
151
            exclude_services = []
 
152
 
 
153
        services = list(set(self.d.services.keys()) - set(exclude_services))
 
154
        service_messages = {service: message for service in services}
 
155
        self.d.sentry.wait_for_messages(service_messages, timeout=timeout)
 
156
 
117
157
    def _get_openstack_release(self):
118
158
        """Get openstack release.
119
159