1
from bzrlib.branch import Branch
1
4
from charmhelpers.contrib.amulet.deployment import (
6
9
class OpenStackAmuletDeployment(AmuletDeployment):
7
"""This class inherits from AmuletDeployment and has additional support
8
that is specifically for use by OpenStack charms."""
10
"""OpenStack amulet deployment.
12
This class inherits from AmuletDeployment and has additional support
13
that is specifically for use by OpenStack charms.
10
16
def __init__(self, series=None, openstack=None, source=None):
11
17
"""Initialize the deployment environment."""
13
19
self.openstack = openstack
14
20
self.source = source
22
def _is_dev_branch(self):
23
"""Determine if branch being tested is a dev (i.e. next) branch."""
24
branch = Branch.open(os.getcwd())
25
parent = branch.get_parent()
26
pattern = re.compile("^.*/next/$")
27
if (pattern.match(parent)):
32
def _determine_branch_locations(self, other_services):
33
"""Determine the branch locations for the other services.
35
If the branch being tested is a dev branch, then determine the
36
development branch locations for the other services. Otherwise,
37
the default charm store branches will be used."""
39
if self._is_dev_branch():
41
for svc in other_services:
42
if svc[name] in ['mysql', 'mongodb', 'rabbitmq-server']:
43
location = 'lp:charms/{}'.format(svc[name])
45
temp = 'lp:~openstack-charmers/charms/trusty/{}/next'
46
location = temp.format(svc[name])
47
updated_services.append(svc + (location,))
48
other_services = updated_services
16
51
def _add_services(self, this_service, other_services):
17
"""Add services to the deployment and set openstack-origin."""
52
"""Add services to the deployment and set openstack-origin/source."""
54
other_services = self._determine_branch_locations(other_services)
18
55
super(OpenStackAmuletDeployment, self)._add_services(this_service,
21
57
services = other_services
22
58
services.append(this_service)
23
59
use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
40
76
self.d.configure(service, config)
42
78
def _get_openstack_release(self):
43
"""Return an integer representing the enum value of the openstack
45
self.precise_essex, self.precise_folsom, self.precise_grizzly, \
46
self.precise_havana, self.precise_icehouse, \
47
self.trusty_icehouse = range(6)
79
"""Get openstack release.
81
Return an integer representing the enum value of the openstack
84
(self.precise_essex, self.precise_folsom, self.precise_grizzly,
85
self.precise_havana, self.precise_icehouse,
86
self.trusty_icehouse) = range(6)
49
88
('precise', None): self.precise_essex,
50
89
('precise', 'cloud:precise-folsom'): self.precise_folsom,