~1chb1n/charms/trusty/ceph-radosgw/next.normalize-makefile-test-deps

« back to all changes in this revision

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

  • Committer: james.page at ubuntu
  • Date: 2014-10-06 22:16:05 UTC
  • mfrom: (26.1.5 ceph-radosgw)
  • Revision ID: james.page@ubuntu.com-20141006221605-z9wo0l6kj02s4onu
[coreycb,r=james-page] Add amulet tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from charmhelpers.contrib.amulet.deployment import (
 
2
    AmuletDeployment
 
3
)
 
4
 
 
5
 
 
6
class OpenStackAmuletDeployment(AmuletDeployment):
 
7
    """OpenStack amulet deployment.
 
8
 
 
9
       This class inherits from AmuletDeployment and has additional support
 
10
       that is specifically for use by OpenStack charms.
 
11
       """
 
12
 
 
13
    def __init__(self, series=None, openstack=None, source=None, stable=True):
 
14
        """Initialize the deployment environment."""
 
15
        super(OpenStackAmuletDeployment, self).__init__(series)
 
16
        self.openstack = openstack
 
17
        self.source = source
 
18
        self.stable = stable
 
19
        # Note(coreycb): this needs to be changed when new next branches come
 
20
        # out.
 
21
        self.current_next = "trusty"
 
22
 
 
23
    def _determine_branch_locations(self, other_services):
 
24
        """Determine the branch locations for the other services.
 
25
 
 
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'])
 
40
                else:
 
41
                    temp = 'lp:~openstack-charmers/charms/{}/{}/next'
 
42
                    svc['location'] = temp.format(self.current_next,
 
43
                                                  svc['name'])
 
44
        return other_services
 
45
 
 
46
    def _add_services(self, this_service, other_services):
 
47
        """Add services to the deployment and set openstack-origin/source."""
 
48
        other_services = self._determine_branch_locations(other_services)
 
49
 
 
50
        super(OpenStackAmuletDeployment, self)._add_services(this_service,
 
51
                                                             other_services)
 
52
 
 
53
        services = other_services
 
54
        services.append(this_service)
 
55
        use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
 
56
                      'ceph-osd', 'ceph-radosgw']
 
57
 
 
58
        if self.openstack:
 
59
            for svc in services:
 
60
                if svc['name'] not in use_source:
 
61
                    config = {'openstack-origin': self.openstack}
 
62
                    self.d.configure(svc['name'], config)
 
63
 
 
64
        if self.source:
 
65
            for svc in services:
 
66
                if svc['name'] in use_source:
 
67
                    config = {'source': self.source}
 
68
                    self.d.configure(svc['name'], config)
 
69
 
 
70
    def _configure_services(self, configs):
 
71
        """Configure all of the services."""
 
72
        for service, config in configs.iteritems():
 
73
            self.d.configure(service, config)
 
74
 
 
75
    def _get_openstack_release(self):
 
76
        """Get openstack release.
 
77
 
 
78
           Return an integer representing the enum value of the openstack
 
79
           release.
 
80
           """
 
81
        (self.precise_essex, self.precise_folsom, self.precise_grizzly,
 
82
         self.precise_havana, self.precise_icehouse,
 
83
         self.trusty_icehouse) = range(6)
 
84
        releases = {
 
85
            ('precise', None): self.precise_essex,
 
86
            ('precise', 'cloud:precise-folsom'): self.precise_folsom,
 
87
            ('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
 
88
            ('precise', 'cloud:precise-havana'): self.precise_havana,
 
89
            ('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
 
90
            ('trusty', None): self.trusty_icehouse}
 
91
        return releases[(self.series, self.openstack)]