~ibm-charms/charms/trusty/nova-compute-power/trunk

« back to all changes in this revision

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

  • Committer: james.page at ubuntu
  • Date: 2015-06-17 09:08:47 UTC
  • mfrom: (74.2.46 nova-compute-power)
  • Revision ID: james.page@ubuntu.com-20150617090847-ork7zgglosiiqs7y
Merge updates for OpenStack Kilo release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014-2015 Canonical Limited.
 
2
#
 
3
# This file is part of charm-helpers.
 
4
#
 
5
# charm-helpers is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU Lesser General Public License version 3 as
 
7
# published by the Free Software Foundation.
 
8
#
 
9
# charm-helpers is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU Lesser General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Lesser General Public License
 
15
# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
import six
 
18
from collections import OrderedDict
1
19
from charmhelpers.contrib.amulet.deployment import (
2
20
    AmuletDeployment
3
21
)
26
44
           Determine if the local branch being tested is derived from its
27
45
           stable or next (dev) branch, and based on this, use the corresonding
28
46
           stable or next branches for the other_services."""
29
 
        base_charms = ['mysql', 'mongodb', 'rabbitmq-server']
 
47
        base_charms = ['mysql', 'mongodb']
 
48
 
 
49
        if self.series in ['precise', 'trusty']:
 
50
            base_series = self.series
 
51
        else:
 
52
            base_series = self.current_next
30
53
 
31
54
        if self.stable:
32
55
            for svc in other_services:
33
 
                temp = 'lp:charms/{}'
34
 
                svc['location'] = temp.format(svc['name'])
 
56
                temp = 'lp:charms/{}/{}'
 
57
                svc['location'] = temp.format(base_series,
 
58
                                              svc['name'])
35
59
        else:
36
60
            for svc in other_services:
37
61
                if svc['name'] in base_charms:
38
 
                    temp = 'lp:charms/{}'
39
 
                    svc['location'] = temp.format(svc['name'])
 
62
                    temp = 'lp:charms/{}/{}'
 
63
                    svc['location'] = temp.format(base_series,
 
64
                                                  svc['name'])
40
65
                else:
41
66
                    temp = 'lp:~openstack-charmers/charms/{}/{}/next'
42
67
                    svc['location'] = temp.format(self.current_next,
54
79
        services.append(this_service)
55
80
        use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
56
81
                      'ceph-osd', 'ceph-radosgw']
 
82
        # Openstack subordinate charms do not expose an origin option as that
 
83
        # is controlled by the principle
 
84
        ignore = ['neutron-openvswitch']
57
85
 
58
86
        if self.openstack:
59
87
            for svc in services:
60
 
                if svc['name'] not in use_source:
 
88
                if svc['name'] not in use_source + ignore:
61
89
                    config = {'openstack-origin': self.openstack}
62
90
                    self.d.configure(svc['name'], config)
63
91
 
64
92
        if self.source:
65
93
            for svc in services:
66
 
                if svc['name'] in use_source:
 
94
                if svc['name'] in use_source and svc['name'] not in ignore:
67
95
                    config = {'source': self.source}
68
96
                    self.d.configure(svc['name'], config)
69
97
 
70
98
    def _configure_services(self, configs):
71
99
        """Configure all of the services."""
72
 
        for service, config in configs.iteritems():
 
100
        for service, config in six.iteritems(configs):
73
101
            self.d.configure(service, config)
74
102
 
75
103
    def _get_openstack_release(self):
78
106
           Return an integer representing the enum value of the openstack
79
107
           release.
80
108
           """
 
109
        # Must be ordered by OpenStack release (not by Ubuntu release):
81
110
        (self.precise_essex, self.precise_folsom, self.precise_grizzly,
82
111
         self.precise_havana, self.precise_icehouse,
83
 
         self.trusty_icehouse) = range(6)
 
112
         self.trusty_icehouse, self.trusty_juno, self.utopic_juno,
 
113
         self.trusty_kilo, self.vivid_kilo) = range(10)
 
114
 
84
115
        releases = {
85
116
            ('precise', None): self.precise_essex,
86
117
            ('precise', 'cloud:precise-folsom'): self.precise_folsom,
87
118
            ('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
88
119
            ('precise', 'cloud:precise-havana'): self.precise_havana,
89
120
            ('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
90
 
            ('trusty', None): self.trusty_icehouse}
 
121
            ('trusty', None): self.trusty_icehouse,
 
122
            ('trusty', 'cloud:trusty-juno'): self.trusty_juno,
 
123
            ('trusty', 'cloud:trusty-kilo'): self.trusty_kilo,
 
124
            ('utopic', None): self.utopic_juno,
 
125
            ('vivid', None): self.vivid_kilo}
91
126
        return releases[(self.series, self.openstack)]
 
127
 
 
128
    def _get_openstack_release_string(self):
 
129
        """Get openstack release string.
 
130
 
 
131
           Return a string representing the openstack release.
 
132
           """
 
133
        releases = OrderedDict([
 
134
            ('precise', 'essex'),
 
135
            ('quantal', 'folsom'),
 
136
            ('raring', 'grizzly'),
 
137
            ('saucy', 'havana'),
 
138
            ('trusty', 'icehouse'),
 
139
            ('utopic', 'juno'),
 
140
            ('vivid', 'kilo'),
 
141
        ])
 
142
        if self.openstack:
 
143
            os_origin = self.openstack.split(':')[1]
 
144
            return os_origin.split('%s-' % self.series)[1].split('/')[0]
 
145
        else:
 
146
            return releases[self.series]