~ivoks/charms/trusty/neutron-gateway/mtu-vlan

« back to all changes in this revision

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

  • Committer: Corey Bryant
  • Date: 2014-07-09 19:25:29 UTC
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: corey.bryant@canonical.com-20140709192529-c2azv58whgj6dnmd
Sync with charm-helpers

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
    """This class inherits from AmuletDeployment and has additional support
 
8
       that is specifically for use by OpenStack charms."""
 
9
 
 
10
    def __init__(self, series, openstack=None, source=None):
 
11
        """Initialize the deployment environment."""
 
12
        super(OpenStackAmuletDeployment, self).__init__(series)
 
13
        self.openstack = openstack
 
14
        self.source = source
 
15
 
 
16
    def _add_services(self, this_service, other_services):
 
17
        """Add services to the deployment and set openstack-origin."""
 
18
        super(OpenStackAmuletDeployment, self)._add_services(this_service,
 
19
                                                             other_services)
 
20
        name = 0
 
21
        services = other_services
 
22
        services.append(this_service)
 
23
        use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
 
24
 
 
25
        if self.openstack:
 
26
            for svc in services:
 
27
                charm_name = self._get_charm_name(svc[name])
 
28
                if charm_name not in use_source:
 
29
                    config = {'openstack-origin': self.openstack}
 
30
                    self.d.configure(svc[name], config)
 
31
 
 
32
        if self.source:
 
33
            for svc in services:
 
34
                charm_name = self._get_charm_name(svc[name])
 
35
                if charm_name in use_source:
 
36
                    config = {'source': self.source}
 
37
                    self.d.configure(svc[name], config)
 
38
 
 
39
    def _configure_services(self, configs):
 
40
        """Configure all of the services."""
 
41
        for service, config in configs.iteritems():
 
42
            self.d.configure(service, config)
 
43
 
 
44
    def _get_openstack_release(self):
 
45
        """Return an integer representing the enum value of the openstack
 
46
           release."""
 
47
        self.precise_essex, self.precise_folsom, self.precise_grizzly, \
 
48
            self.precise_havana, self.precise_icehouse, \
 
49
            self.trusty_icehouse = range(6)
 
50
        releases = {
 
51
            ('precise', None): self.precise_essex,
 
52
            ('precise', 'cloud:precise-folsom'): self.precise_folsom,
 
53
            ('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
 
54
            ('precise', 'cloud:precise-havana'): self.precise_havana,
 
55
            ('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
 
56
            ('trusty', None): self.trusty_icehouse}
 
57
        return releases[(self.series, self.openstack)]