~celebdor/charms/trusty/neutron-agents-midonet/trunk

« back to all changes in this revision

Viewing changes to tests/basic_deployment.py

  • Committer: Antoni Segura Puimedon
  • Date: 2016-01-25 15:57:58 UTC
  • Revision ID: toni@midokura.com-20160125155758-ni7pxb7vryhgckpj
Sync dependencies

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
16
# License for the specific language governing permissions and limitations
17
17
# under the License.
18
 
import os
19
 
 
20
18
import amulet
21
19
 
22
20
from charmhelpers.contrib.openstack.amulet.utils import (
32
30
 
33
31
 
34
32
class MidonetBasicDeployment():
35
 
    def __init__(self, ubuntu_series, openstack_origin=None,
36
 
                 midonet_origin=None):
37
 
        self.os_release = openstack_origin
 
33
    def __init__(self, ubuntu_series, openstack=None, midonet_release=None):
 
34
        self.os_release = openstack
38
35
        self.series = ubuntu_series
39
 
        self.midonet_origin = midonet_origin
40
 
        self.mem = self.midonet_origin[:3] == 'mem'
41
 
        self.mem_credentials = {'mem-username': os.getenv('MEM_USERNAME'),
42
 
                                'mem-password': os.getenv('MEM_PWD')}
 
36
        self.midonet_release = midonet_release
43
37
        self.d = amulet.Deployment(series=self.series)
44
 
        self.d.charm_name = 'neutron-agents-midonet'
45
 
 
46
38
        self._add_services()
47
39
        self._add_relations()
48
40
        self._configure_services()
55
47
        self.d.add('rabbitmq-server', charm='cs:trusty/rabbitmq-server',
56
48
                   units=1, series=self.series)
57
49
        self.d.add('cassandra', charm='cassandra', units=1,
58
 
                   branch='cs:trusty/cassandra', series=self.series)
 
50
                   branch='lp:charms/cassandra', series=self.series)
59
51
        self.d.add('keystone', charm='keystone', units=1, series=self.series,
60
 
                branch='cs:trusty/keystone')
61
 
        self.d.add('compute', charm='nova-compute', units=1,
62
 
                   branch='cs:trusty/nova-compute', series=self.series,
63
 
                   constraints={'mem': '8G'})
64
 
        self.d.add('neutron', charm='neutron-api', units=1,
65
 
                   branch='lp:~celebdor/charms/trusty/neutron-api/liberty',
66
 
                   series=self.series)
67
 
        self.d.add('nova', charm='nova-cloud-controller',
68
 
               units=1, series=self.series)
69
 
        self.d.add('glance', charm='glance',
70
 
               branch='cs:trusty/glance',
71
 
               units=1, series=self.series)
72
 
        self.d.add('cinder', charm='cinder',
73
 
               branch='cs:trusty/glance',
 
52
                    branch='lp:~celebdor/charms/trusty/keystone/trunk')
 
53
        self.d.add('nova-compute', charm='nova-compute', units=1,
 
54
                   branch='lp:~celebdor/charms/trusty/nova-compute/trunk',
 
55
                   series=self.series)
 
56
        self.d.add('neutron-api', charm='neutron-api', units=1,
 
57
                   branch='lp:~celebdor/charms/trusty/neutron-api/trunk',
 
58
                   series=self.series)
 
59
        self.d.add('nova-cloud-controller', charm='nova-cloud-controller',
 
60
               branch='lp:~celebdor/charms/trusty/nova-cloud-controller/trunk',
74
61
               units=1, series=self.series)
75
62
        self.d.add('zookeeper', charm='cs:trusty/zookeeper', units=1,
76
63
                   series=self.series)
80
67
        self.d.add('midonet-agent', charm='midonet-agent', units=1,
81
68
                   branch='lp:~celebdor/charms/trusty/midonet-agent/trunk',
82
69
                   series=self.series)
83
 
        self.d.add('neutron-agents-midonet', constraints={'mem': '4G'})
 
70
        self.d.add('neutron-agents-midonet', charm='neutron-agents-midonet',
 
71
              branch='lp:~celebdor/charms/trusty/neutron-agents-midonet/trunk',
 
72
              series='trusty')
84
73
 
85
74
    def _add_relations(self):
86
 
        # Keystone
87
75
        self.d.relate('mysql:shared-db', 'keystone:shared-db')
88
 
 
89
 
        # Nova
90
 
        self.d.relate('mysql:shared-db', 'nova:shared-db')
91
 
        self.d.relate('keystone:identity-service', 'nova:identity-service')
92
 
        self.d.relate('rabbitmq-server:amqp', 'nova:amqp')
93
 
        self.d.relate('neutron-agents-midonet:neutron_agents',
94
 
                      'nova:quantum-network-service')
95
 
        self.d.relate('neutron:neutron-api', 'nova:neutron-api')
96
 
        self.d.relate('compute:cloud-compute', 'nova:cloud-compute')
97
 
        self.d.relate('glance:image-service', 'nova:image-service')
98
 
        self.d.relate('cinder:cinder-volume-service',
99
 
                      'nova:cinder-volume-service')
100
 
 
101
 
        # Cinder
102
 
        self.d.relate('keystone:identity-service', 'cinder:identity-service')
103
 
        self.d.relate('mysql:shared-db', 'cinder:shared-db')
104
 
        self.d.relate('rabbitmq-server:amqp', 'cinder:amqp')
105
 
        self.d.relate('glance:image-service', 'cinder:image-service')
106
 
 
107
 
        # Glance
108
 
        self.d.relate('keystone:identity-service', 'glance:identity-service')
109
 
        self.d.relate('mysql:shared-db', 'glance:shared-db')
110
 
        self.d.relate('rabbitmq-server:amqp', 'glance:amqp')
111
 
 
112
 
        # Neutron
113
 
        self.d.relate('mysql:shared-db', 'neutron:shared-db')
114
 
        self.d.relate('keystone:identity-service', 'neutron:identity-service')
115
 
        self.d.relate('rabbitmq-server:amqp', 'neutron:amqp')
116
 
        self.d.relate('neutron-agents-midonet:neutron-plugin-api',
117
 
                      'neutron:neutron-plugin-api')
118
 
 
119
 
        # MidoNet
 
76
        self.d.relate('mysql:shared-db', 'nova-cloud-controller:shared-db')
 
77
        self.d.relate('rabbitmq-server:amqp', 'nova-compute:amqp')
 
78
        self.d.relate('rabbitmq-server:amqp', 'nova-cloud-controller:amqp')
 
79
        self.d.relate('rabbitmq-server:amqp', 'neutron-api:amqp')
 
80
        self.d.relate('nova-cloud-controller:identity-service',
 
81
                      'keystone:identity-service')
 
82
 
 
83
        self.d.relate('neutron-api:identity-service',
 
84
                      'keystone:identity-service')
 
85
        self.d.relate('nova-compute:cloud-compute',
 
86
                      'nova-cloud-controller:cloud-compute')
 
87
        self.d.relate('neutron-api:neutron-api',
 
88
                      'nova-cloud-controller:neutron-api')
 
89
 
120
90
        self.d.relate('keystone:identity-service', 'midonet-api:keystone')
121
91
        self.d.relate('zookeeper:zookeeper', 'midonet-api:zookeeper')
122
92
        self.d.relate('midonet-agent:host', 'midonet-api:host')
123
 
        self.d.relate('neutron:midonet', 'midonet-api:midonet-api')
124
 
        self.d.relate('rabbitmq-server:amqp', 'neutron-gents-midonet:amqp')
125
 
        self.d.relate('midonet-agent:host', 'neutron-agents-midonet:agent')
126
 
        self.d.relate('cassandra:database', 'midonet-agent:cassandra')
127
 
        self.d.relate('zookeeper:zookeeper', 'midonet-agent:zookeeper')
128
 
        self.d.relate('midonet-api:midonet-api',
129
 
                      'neutron-agents-midonet:midonet')
130
 
 
131
 
        # Compute
132
 
        self.d.relate('rabbitmq-server:amqp', 'compute:amqp')
133
 
        self.d.relate('midonet-agent:neutron-plugin', 'compute:neutron-plugin')
134
 
        self.d.relate('glance:image-service', 'compute:image-service')
 
93
        self.d.relate('neutron-api:midonet', 'midonet-api:midonet-api')
 
94
 
 
95
        self.d.relate('neutron-agents-midonet:neutron_agents',
 
96
                      'nova-cloud-controller:quantum-network-service')
 
97
 
 
98
        self.d.relate('neutron-agents-midonet:neutron-plugin-api',
 
99
                      'neutron-api:neutron-plugin-api')
 
100
 
 
101
        self.d.relate('midonet-agent:neutron-plugin',
 
102
                      'nova-compute:neutron-plugin')
 
103
 
 
104
        self.d.relate('midonet-agent:host', 'neutron-api:midonet-host')
 
105
        self.d.relate('midonet-agent:cassandra', 'cassandra:database')
 
106
        self.d.relate('midonet-agent:zookeeper', 'zookeeper:zookeeper')
135
107
 
136
108
    def _configure_services(self):
137
 
        repo_config = {'midonet-origin': self.midonet_origin,
138
 
                      'openstack-origin': self.os_release}
139
 
        if self.mem:
140
 
            repo_config.update(self.mem_credentials)
141
 
 
142
109
        self.d.configure('keystone', {
143
 
                         'admin-user': 'admin',
144
 
                         'admin-password': 'openstack',
145
 
                         'admin-token': 'osttesting',
146
110
                         'enable-pki': 'false',
147
111
                         'openstack-origin': self.os_release})
148
112
 
149
 
        self.d.configure('mysql', {
150
 
                         'max-connections': 500})
151
 
 
152
113
        self.d.configure('cassandra', {
153
 
            'authenticator': 'AllowAllAuthenticator',
154
 
            'cluster_name': 'midonet',
155
 
            'install_keys': '7E41C00F85BFC1706C4FFFB3350200F2B999A372',
156
 
            'install_sources':
 
114
            'allow-single-node': True,
 
115
            'cluster-name': 'midonet',
 
116
            'apt-repo-key': '7E41C00F85BFC1706C4FFFB3350200F2B999A372',
 
117
            'apt-repo-spec':
157
118
            'deb http://debian.datastax.com/community 2.0 main',
158
 
            'extra_packages': 'dsc20'})
159
 
 
160
 
        self.d.configure('compute', {
 
119
            'extra_packages': 'openjdk-7-jre-headless dsc20'})
 
120
 
 
121
        self.d.configure('mysql', {'max-connections': 2000})
 
122
 
 
123
        self.d.configure('nova-compute', {
161
124
                         'openstack-origin': self.os_release,
162
125
                         'virt-type': 'qemu',
163
126
                         'flat-interface': 'eth0',
164
127
                         'manage-neutron-plugin-legacy-mode': 'false'})
165
128
 
166
 
        self.d.configure('nova', {
 
129
        self.d.configure('nova-cloud-controller', {
167
130
                         'openstack-origin': self.os_release,
168
131
                         'network-manager': 'Neutron',
169
 
                         'shared-secret': 'secret'})
 
132
                         'shared_secret': 'secret'})
170
133
 
171
 
        self.d.configure('neutron', {
 
134
        self.d.configure('neutron-api', {
172
135
                         'neutron-plugin': 'midonet',
173
136
                         'neutron-security-groups': 'True',
174
137
                         'neutron-external-network': 'Public_Network',
175
138
                         'l2-population': 'False',
176
139
                         'openstack-origin': self.os_release,
177
 
                         'midonet-origin': self.midonet_origin})
178
 
 
179
 
 
180
 
        self.d.configure('midonet-api', repo_config)
181
 
 
182
 
        neutron_agts_midonet_config = {'shared-secret': 'secret'}
183
 
        neutron_agts_midonet_config.update(repo_config)
184
 
        self.d.configure('neutron-agents-midonet', neutron_agts_midonet_config)
185
 
 
186
 
        self.d.configure('midonet-agent', repo_config)
 
140
                         'midonet-release': self.midonet_release})
 
141
 
 
142
        self.d.configure('midonet-api',
 
143
                         {'midonet-release': self.midonet_release})
 
144
 
 
145
        self.d.configure('neutron-agents-midonet',
 
146
                         {'shared_secret': 'secret'})
 
147
 
 
148
        self.d.configure('midonet-agent',
 
149
                         {'midonet-release': self.midonet_release})
187
150
 
188
151
    def _deploy(self):
189
152
        try:
197
160
        self.zookeeper_sentry = self.d.sentry.unit['zookeeper/0']
198
161
        self.keystone_sentry = self.d.sentry.unit['keystone/0']
199
162
        self.cassandra_sentry = self.d.sentry.unit['cassandra/0']
200
 
        self.nova_compute_sentry = self.d.sentry.unit['compute/0']
 
163
        self.nova_compute_sentry = self.d.sentry.unit['nova-compute/0']
201
164
        self.mn_api_sentry = self.d.sentry.unit['midonet-api/0']
202
165
        self.mn_agent_sentry = self.d.sentry.unit['midonet-agent/0']
203
166
        self.agents_mn_sentry = self.d.sentry.unit['neutron-agents-midonet/0']
204
167
 
205
168
        self.keystone_api_relation = self.keystone_sentry.relation(
206
 
            'identity-service', 'midonet-api:keystone')
 
169
             'identity-service', 'midonet-api:keystone')
207
170
        self.zookeeper_api_relation = self.zookeeper_sentry.relation(
208
 
            'zookeeper', 'midonet-api:zookeeper')
 
171
             'zookeeper', 'midonet-api:zookeeper')
209
172
        self.zk_host_relation = self.zookeeper_sentry.relation(
210
 
            'zookeeper', 'midonet-agent:zookeeper')
 
173
                                'zookeeper', 'midonet-agent:zookeeper')
211
174
        self.cs_host_relation = self.cassandra_sentry.relation(
212
175
            'database', 'midonet-agent:cassandra')
213
176
        self.api_host_relation = self.mn_api_sentry.relation(
220
183
 
221
184
    def test_neutron_agents_mn(self):
222
185
        u.log.debug('Checking if the key has been correctly fetched...')
223
 
        apt_key_out, _ = self.mn_agent_sentry.run('apt-key list | '
224
 
                                                  'grep Midokura')
 
186
        apt_key_out, apt_key_exit = self.mn_agent_sentry.run(
 
187
                                    'apt-key list | grep Midokura')
225
188
        if 'Midokura' not in apt_key_out:
226
 
            amulet.raise_status(amulet.FAIL,
227
 
                                msg='Midokura repository key is not installed')
 
189
            message = ("error, Midokura repository key is not installed")
 
190
            amulet.raise_status(amulet.FAIL, msg=message)
228
191
 
229
192
        u.log.debug('Checking if midonet-plugin package has been installed...')
230
 
        dpkg_plugin_out, _ = self.agents_mn_sentry.run(
231
 
            'dpkg -l | grep python-neutron-plugin-midonet')
 
193
        dpkg_plugin_out, dpkg_exit = self.agents_mn_sentry.run(
 
194
                              ('dpkg -l | grep python-neutron-plugin-midonet'))
232
195
        if 'python-neutron-plugin-midonet' not in dpkg_plugin_out:
233
 
            amulet.raise_status(amulet.FAIL,
234
 
                                msg='python-neutron-plugin-midonet package is '
235
 
                                'not installed')
 
196
            message = (
 
197
               "error: python-neutron-plugin-midonet package is not installed")
 
198
            amulet.raise_status(amulet.FAIL, msg=message)
236
199
 
237
200
        u.log.debug('Checking neutron-dhcp-agent...')
238
 
        dhcp_agent_out, _ = self.agents_mn_sentry.run(
239
 
            'service neutron-dhcp-agent status')
 
201
        dhcp_agent_out, dhcp_agent_exit = self.agents_mn_sentry.run(
 
202
                                  'service neutron-dhcp-agent status')
240
203
        if 'running' not in dhcp_agent_out:
241
 
            amulet.raise_status(amulet.FAIL,
242
 
                                msg="neutron-dhcp-agent not running: %s" %
243
 
                                dhcp_agent_out)
 
204
            message = (
 
205
               "error, neutron-dhcp-agent not running: %s" % dhcp_agent_out)
 
206
            amulet.raise_status(amulet.FAIL, msg=message)
244
207
 
245
208
        u.log.debug('Checking neutron-metadata-agent...')
246
 
        meta_agent_out, _ = self.agents_mn_sentry.run(
247
 
            'service neutron-metadata-agent status')
 
209
        meta_agent_out, meta_agent_exit = self.agents_mn_sentry.run(
 
210
                                  'service neutron-metadata-agent status')
248
211
        if 'running' not in meta_agent_out:
249
 
            amulet.raise_status(amulet.FAIL,
250
 
                                msg="neutron-metadata-agent not running: %s" %
251
 
                                meta_agent_out)
 
212
            message = (
 
213
              "error, neutron-metadata-agent not running: %s" % meta_agent_out)
 
214
            amulet.raise_status(amulet.FAIL, msg=message)