~corey.bryant/charms/trusty/neutron-api/db-stamp

« 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-01 21:05:24 UTC
  • mfrom: (39.3.25 ipv6)
  • Revision ID: james.page@ubuntu.com-20141001210524-z6uqyljzorphrhy6
[xianghui,dosaboy,r=james-page,t=gema] Add IPv6 support using prefer-ipv6 flag

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from bzrlib.branch import Branch
 
2
import os
 
3
import re
1
4
from charmhelpers.contrib.amulet.deployment import (
2
5
    AmuletDeployment
3
6
)
4
7
 
5
8
 
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.
 
11
 
 
12
       This class inherits from AmuletDeployment and has additional support
 
13
       that is specifically for use by OpenStack charms.
 
14
       """
9
15
 
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
15
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
 
31
 
 
32
    def _determine_branch_locations(self, other_services):
 
33
        """Determine the branch locations for the other services.
 
34
 
 
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])
 
44
                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
 
49
        return other_services
 
50
 
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."""
 
53
        name = 0
 
54
        other_services = self._determine_branch_locations(other_services)
18
55
        super(OpenStackAmuletDeployment, self)._add_services(this_service,
19
56
                                                             other_services)
20
 
        name = 0
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)
41
77
 
42
78
    def _get_openstack_release(self):
43
 
        """Return an integer representing the enum value of the openstack
44
 
           release."""
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.
 
80
 
 
81
           Return an integer representing the enum value of the openstack
 
82
           release.
 
83
           """
 
84
        (self.precise_essex, self.precise_folsom, self.precise_grizzly,
 
85
         self.precise_havana, self.precise_icehouse,
 
86
         self.trusty_icehouse) = range(6)
48
87
        releases = {
49
88
            ('precise', None): self.precise_essex,
50
89
            ('precise', 'cloud:precise-folsom'): self.precise_folsom,