1
# Copyright 2014-2015 Canonical Limited.
3
# This file is part of charm-helpers.
5
# charm-helpers is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License version 3 as
7
# published by the Free Software Foundation.
9
# charm-helpers is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public License
15
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
18
from collections import OrderedDict
19
from charmhelpers.contrib.amulet.deployment import (
24
class OpenStackAmuletDeployment(AmuletDeployment):
25
"""OpenStack amulet deployment.
27
This class inherits from AmuletDeployment and has additional support
28
that is specifically for use by OpenStack charms.
31
def __init__(self, series=None, openstack=None, source=None, stable=True):
32
"""Initialize the deployment environment."""
33
super(OpenStackAmuletDeployment, self).__init__(series)
34
self.openstack = openstack
37
# Note(coreycb): this needs to be changed when new next branches come
39
self.current_next = "trusty"
41
def _determine_branch_locations(self, other_services):
42
"""Determine the branch locations for the other services.
44
Determine if the local branch being tested is derived from its
45
stable or next (dev) branch, and based on this, use the corresonding
46
stable or next branches for the other_services."""
47
base_charms = ['mysql', 'mongodb', 'nrpe']
49
if self.series in ['precise', 'trusty']:
50
base_series = self.series
52
base_series = self.current_next
55
for svc in other_services:
56
temp = 'lp:charms/{}/{}'
57
svc['location'] = temp.format(base_series,
60
for svc in other_services:
61
if svc['name'] in base_charms:
62
temp = 'lp:charms/{}/{}'
63
svc['location'] = temp.format(base_series,
66
temp = 'lp:~openstack-charmers/charms/{}/{}/next'
67
svc['location'] = temp.format(self.current_next,
71
def _add_services(self, this_service, other_services):
72
"""Add services to the deployment and set openstack-origin/source."""
73
other_services = self._determine_branch_locations(other_services)
75
super(OpenStackAmuletDeployment, self)._add_services(this_service,
78
services = other_services
79
services.append(this_service)
80
use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
81
'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', 'nrpe']
88
if svc['name'] not in use_source + ignore:
89
config = {'openstack-origin': self.openstack}
90
self.d.configure(svc['name'], config)
94
if svc['name'] in use_source and svc['name'] not in ignore:
95
config = {'source': self.source}
96
self.d.configure(svc['name'], config)
98
def _configure_services(self, configs):
99
"""Configure all of the services."""
100
for service, config in six.iteritems(configs):
101
self.d.configure(service, config)
103
def _get_openstack_release(self):
104
"""Get openstack release.
106
Return an integer representing the enum value of the openstack
109
# Must be ordered by OpenStack release (not by Ubuntu release):
110
(self.precise_essex, self.precise_folsom, self.precise_grizzly,
111
self.precise_havana, self.precise_icehouse,
112
self.trusty_icehouse, self.trusty_juno, self.utopic_juno,
113
self.trusty_kilo, self.vivid_kilo, self.trusty_liberty,
114
self.wily_liberty) = range(12)
117
('precise', None): self.precise_essex,
118
('precise', 'cloud:precise-folsom'): self.precise_folsom,
119
('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
120
('precise', 'cloud:precise-havana'): self.precise_havana,
121
('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
122
('trusty', None): self.trusty_icehouse,
123
('trusty', 'cloud:trusty-juno'): self.trusty_juno,
124
('trusty', 'cloud:trusty-kilo'): self.trusty_kilo,
125
('trusty', 'cloud:trusty-liberty'): self.trusty_liberty,
126
('utopic', None): self.utopic_juno,
127
('vivid', None): self.vivid_kilo,
128
('wily', None): self.wily_liberty}
129
return releases[(self.series, self.openstack)]
131
def _get_openstack_release_string(self):
132
"""Get openstack release string.
134
Return a string representing the openstack release.
136
releases = OrderedDict([
137
('precise', 'essex'),
138
('quantal', 'folsom'),
139
('raring', 'grizzly'),
141
('trusty', 'icehouse'),
147
os_origin = self.openstack.split(':')[1]
148
return os_origin.split('%s-' % self.series)[1].split('/')[0]
150
return releases[self.series]
152
def get_ceph_expected_pools(self, radosgw=False):
153
"""Return a list of expected ceph pools in a ceph + cinder + glance
154
test scenario, based on OpenStack release and whether ceph radosgw
155
is flagged as present or not."""
157
if self._get_openstack_release() >= self.trusty_kilo: