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/>.
18
19
from collections import OrderedDict
19
20
from charmhelpers.contrib.amulet.deployment import (
44
45
Determine if the local branch being tested is derived from its
45
46
stable or next (dev) branch, and based on this, use the corresonding
46
47
stable or next branches for the other_services."""
47
base_charms = ['mysql', 'mongodb']
49
# Charms outside the lp:~openstack-charmers namespace
50
base_charms = ['mysql', 'mongodb', 'nrpe']
52
# Force these charms to current series even when using an older series.
53
# ie. Use trusty/nrpe even when series is precise, as the P charm
54
# does not possess the necessary external master config and hooks.
55
force_series_current = ['nrpe']
49
57
if self.series in ['precise', 'trusty']:
50
58
base_series = self.series
52
60
base_series = self.current_next
55
for svc in other_services:
62
for svc in other_services:
63
if svc['name'] in force_series_current:
64
base_series = self.current_next
65
# If a location has been explicitly set, use it
66
if svc.get('location'):
56
69
temp = 'lp:charms/{}/{}'
57
70
svc['location'] = temp.format(base_series,
60
for svc in other_services:
61
73
if svc['name'] in base_charms:
62
74
temp = 'lp:charms/{}/{}'
63
75
svc['location'] = temp.format(base_series,
66
78
temp = 'lp:~openstack-charmers/charms/{}/{}/next'
67
79
svc['location'] = temp.format(self.current_next,
69
82
return other_services
71
84
def _add_services(self, this_service, other_services):
78
91
services = other_services
79
92
services.append(this_service)
94
# Charms which should use the source config option
80
95
use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
81
96
'ceph-osd', 'ceph-radosgw']
82
# Most OpenStack subordinate charms do not expose an origin option
83
# as that is controlled by the principle.
84
ignore = ['cinder-ceph', 'hacluster', 'neutron-openvswitch']
98
# Charms which can not use openstack-origin, ie. many subordinates
99
no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe']
86
101
if self.openstack:
87
102
for svc in services:
88
if svc['name'] not in use_source + ignore:
103
if svc['name'] not in use_source + no_origin:
89
104
config = {'openstack-origin': self.openstack}
90
105
self.d.configure(svc['name'], config)
93
108
for svc in services:
94
if svc['name'] in use_source and svc['name'] not in ignore:
109
if svc['name'] in use_source and svc['name'] not in no_origin:
95
110
config = {'source': self.source}
96
111
self.d.configure(svc['name'], config)
100
115
for service, config in six.iteritems(configs):
101
116
self.d.configure(service, config)
118
def _auto_wait_for_status(self, message=None, exclude_services=None,
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.
124
Examples of message usage:
126
Wait for all unit status to CONTAIN any case of 'ready' or 'ok':
127
message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE)
129
Wait for all units to reach this status (exact match):
130
message = 'Unit is ready'
132
Wait for all units to reach any one of these (exact match):
133
message = re.compile('Unit is ready|OK|Ready')
135
Wait for at least one unit to reach this status (exact match):
138
See Amulet's sentry.wait_for_messages() for message usage detail.
139
https://github.com/juju/amulet/blob/master/amulet/sentry.py
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.
148
message = re.compile('.*ready.*', re.IGNORECASE)
150
if not exclude_services:
151
exclude_services = []
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)
103
157
def _get_openstack_release(self):
104
158
"""Get openstack release.