~nobuto/charms/trusty/ceph/workaround-multinics

« back to all changes in this revision

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

  • Committer: Liam Young
  • Date: 2014-09-17 06:36:31 UTC
  • mfrom: (78.1.5 ceph)
  • Revision ID: liam.young@canonical.com-20140917063631-sh28aabz283xfxyo
[corey.bryant,r=gnuoy] Add Amulet basic 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):
 
14
        """Initialize the deployment environment."""
 
15
        super(OpenStackAmuletDeployment, self).__init__(series)
 
16
        self.openstack = openstack
 
17
        self.source = source
 
18
 
 
19
    def _add_services(self, this_service, other_services):
 
20
        """Add services to the deployment and set openstack-origin."""
 
21
        super(OpenStackAmuletDeployment, self)._add_services(this_service,
 
22
                                                             other_services)
 
23
        name = 0
 
24
        services = other_services
 
25
        services.append(this_service)
 
26
        use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
 
27
 
 
28
        if self.openstack:
 
29
            for svc in services:
 
30
                if svc[name] not in use_source:
 
31
                    config = {'openstack-origin': self.openstack}
 
32
                    self.d.configure(svc[name], config)
 
33
 
 
34
        if self.source:
 
35
            for svc in services:
 
36
                if svc[name] in use_source:
 
37
                    config = {'source': self.source}
 
38
                    self.d.configure(svc[name], config)
 
39
 
 
40
    def _configure_services(self, configs):
 
41
        """Configure all of the services."""
 
42
        for service, config in configs.iteritems():
 
43
            self.d.configure(service, config)
 
44
 
 
45
    def _get_openstack_release(self):
 
46
        """Get openstack release.
 
47
 
 
48
           Return an integer representing the enum value of the openstack
 
49
           release.
 
50
           """
 
51
        (self.precise_essex, self.precise_folsom, self.precise_grizzly,
 
52
         self.precise_havana, self.precise_icehouse,
 
53
         self.trusty_icehouse) = range(6)
 
54
        releases = {
 
55
            ('precise', None): self.precise_essex,
 
56
            ('precise', 'cloud:precise-folsom'): self.precise_folsom,
 
57
            ('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
 
58
            ('precise', 'cloud:precise-havana'): self.precise_havana,
 
59
            ('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
 
60
            ('trusty', None): self.trusty_icehouse}
 
61
        return releases[(self.series, self.openstack)]