~seyeongkim/charms/trusty/nova-compute/lp1417891

« back to all changes in this revision

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

  • Committer: james.page at ubuntu
  • Date: 2014-10-06 21:57:43 UTC
  • mfrom: (80.1.3 nova-compute)
  • Revision ID: james.page@ubuntu.com-20141006215743-auucleyomgjcjche
[coreycb,r=james-page] Fixup amulet tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from bzrlib.branch import Branch
2
 
import os
3
 
import re
4
1
from charmhelpers.contrib.amulet.deployment import (
5
2
    AmuletDeployment
6
3
)
13
10
       that is specifically for use by OpenStack charms.
14
11
       """
15
12
 
16
 
    def __init__(self, series=None, openstack=None, source=None):
 
13
    def __init__(self, series=None, openstack=None, source=None, stable=True):
17
14
        """Initialize the deployment environment."""
18
15
        super(OpenStackAmuletDeployment, self).__init__(series)
19
16
        self.openstack = openstack
20
17
        self.source = source
21
 
 
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)):
28
 
            return True
29
 
        else:
30
 
            return False
 
18
        self.stable = stable
 
19
        # Note(coreycb): this needs to be changed when new next branches come
 
20
        # out.
 
21
        self.current_next = "trusty"
31
22
 
32
23
    def _determine_branch_locations(self, other_services):
33
24
        """Determine the branch locations for the other services.
34
25
 
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."""
38
 
        name = 0
39
 
        if self._is_dev_branch():
40
 
            updated_services = []
41
 
            for svc in other_services:
42
 
                if svc[name] in ['mysql', 'mongodb', 'rabbitmq-server']:
43
 
                    location = 'lp:charms/{}'.format(svc[name])
 
26
           Determine if the local branch being tested is derived from its
 
27
           stable or next (dev) branch, and based on this, use the corresonding
 
28
           stable or next branches for the other_services."""
 
29
        base_charms = ['mysql', 'mongodb', 'rabbitmq-server']
 
30
 
 
31
        if self.stable:
 
32
            for svc in other_services:
 
33
                temp = 'lp:charms/{}'
 
34
                svc['location'] = temp.format(svc['name'])
 
35
        else:
 
36
            for svc in other_services:
 
37
                if svc['name'] in base_charms:
 
38
                    temp = 'lp:charms/{}'
 
39
                    svc['location'] = temp.format(svc['name'])
44
40
                else:
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
 
41
                    temp = 'lp:~openstack-charmers/charms/{}/{}/next'
 
42
                    svc['location'] = temp.format(self.current_next,
 
43
                                                  svc['name'])
49
44
        return other_services
50
45
 
51
46
    def _add_services(self, this_service, other_services):
52
47
        """Add services to the deployment and set openstack-origin/source."""
53
 
        name = 0
54
48
        other_services = self._determine_branch_locations(other_services)
 
49
 
55
50
        super(OpenStackAmuletDeployment, self)._add_services(this_service,
56
51
                                                             other_services)
 
52
 
57
53
        services = other_services
58
54
        services.append(this_service)
59
 
        use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
 
55
        use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
 
56
                      'ceph-osd', 'ceph-radosgw']
60
57
 
61
58
        if self.openstack:
62
59
            for svc in services:
63
 
                if svc[name] not in use_source:
 
60
                if svc['name'] not in use_source:
64
61
                    config = {'openstack-origin': self.openstack}
65
 
                    self.d.configure(svc[name], config)
 
62
                    self.d.configure(svc['name'], config)
66
63
 
67
64
        if self.source:
68
65
            for svc in services:
69
 
                if svc[name] in use_source:
 
66
                if svc['name'] in use_source:
70
67
                    config = {'source': self.source}
71
 
                    self.d.configure(svc[name], config)
 
68
                    self.d.configure(svc['name'], config)
72
69
 
73
70
    def _configure_services(self, configs):
74
71
        """Configure all of the services."""