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 charmhelpers.contrib.amulet.deployment import (
23
class OpenStackAmuletDeployment(AmuletDeployment):
24
"""OpenStack amulet deployment.
26
This class inherits from AmuletDeployment and has additional support
27
that is specifically for use by OpenStack charms.
30
def __init__(self, series=None, openstack=None, source=None, stable=True):
31
"""Initialize the deployment environment."""
32
super(OpenStackAmuletDeployment, self).__init__(series)
33
self.openstack = openstack
36
# Note(coreycb): this needs to be changed when new next branches come
38
self.current_next = "trusty"
40
def _determine_branch_locations(self, other_services):
41
"""Determine the branch locations for the other services.
43
Determine if the local branch being tested is derived from its
44
stable or next (dev) branch, and based on this, use the corresonding
45
stable or next branches for the other_services."""
46
base_charms = ['mysql', 'mongodb', 'rabbitmq-server']
49
for svc in other_services:
51
svc['location'] = temp.format(svc['name'])
53
for svc in other_services:
54
if svc['name'] in base_charms:
56
svc['location'] = temp.format(svc['name'])
58
temp = 'lp:~openstack-charmers/charms/{}/{}/next'
59
svc['location'] = temp.format(self.current_next,
63
def _add_services(self, this_service, other_services):
64
"""Add services to the deployment and set openstack-origin/source."""
65
other_services = self._determine_branch_locations(other_services)
67
super(OpenStackAmuletDeployment, self)._add_services(this_service,
70
services = other_services
71
services.append(this_service)
72
use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
73
'ceph-osd', 'ceph-radosgw']
77
if svc['name'] not in use_source:
78
config = {'openstack-origin': self.openstack}
79
self.d.configure(svc['name'], config)
83
if svc['name'] in use_source:
84
config = {'source': self.source}
85
self.d.configure(svc['name'], config)
87
def _configure_services(self, configs):
88
"""Configure all of the services."""
89
for service, config in six.iteritems(configs):
90
self.d.configure(service, config)
92
def _get_openstack_release(self):
93
"""Get openstack release.
95
Return an integer representing the enum value of the openstack
98
(self.precise_essex, self.precise_folsom, self.precise_grizzly,
99
self.precise_havana, self.precise_icehouse,
100
self.trusty_icehouse) = range(6)
102
('precise', None): self.precise_essex,
103
('precise', 'cloud:precise-folsom'): self.precise_folsom,
104
('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
105
('precise', 'cloud:precise-havana'): self.precise_havana,
106
('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
107
('trusty', None): self.trusty_icehouse}
108
return releases[(self.series, self.openstack)]