~junaidali/charms/trusty/plumgrid-gateway/analyst_opsvm

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/neutron.py

  • Committer: bbaqar at plumgrid
  • Date: 2016-04-25 09:21:09 UTC
  • mfrom: (26.1.2 plumgrid-gateway)
  • Revision ID: bbaqar@plumgrid.com-20160425092109-kweey25bx97pmj80
Merge: Liberty/Mitaka support

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    if kernel_version() >= (3, 13):
51
51
        return []
52
52
    else:
53
 
        return ['openvswitch-datapath-dkms']
 
53
        return [headers_package(), 'openvswitch-datapath-dkms']
54
54
 
55
55
 
56
56
# legacy
70
70
                                        relation_prefix='neutron',
71
71
                                        ssl_dir=QUANTUM_CONF_DIR)],
72
72
            'services': ['quantum-plugin-openvswitch-agent'],
73
 
            'packages': [[headers_package()] + determine_dkms_package(),
 
73
            'packages': [determine_dkms_package(),
74
74
                         ['quantum-plugin-openvswitch-agent']],
75
75
            'server_packages': ['quantum-server',
76
76
                                'quantum-plugin-openvswitch'],
111
111
                                        relation_prefix='neutron',
112
112
                                        ssl_dir=NEUTRON_CONF_DIR)],
113
113
            'services': ['neutron-plugin-openvswitch-agent'],
114
 
            'packages': [[headers_package()] + determine_dkms_package(),
 
114
            'packages': [determine_dkms_package(),
115
115
                         ['neutron-plugin-openvswitch-agent']],
116
116
            'server_packages': ['neutron-server',
117
117
                                'neutron-plugin-openvswitch'],
155
155
                                        relation_prefix='neutron',
156
156
                                        ssl_dir=NEUTRON_CONF_DIR)],
157
157
            'services': [],
158
 
            'packages': [[headers_package()] + determine_dkms_package(),
 
158
            'packages': [determine_dkms_package(),
159
159
                         ['neutron-plugin-cisco']],
160
160
            'server_packages': ['neutron-server',
161
161
                                'neutron-plugin-cisco'],
174
174
                         'neutron-dhcp-agent',
175
175
                         'nova-api-metadata',
176
176
                         'etcd'],
177
 
            'packages': [[headers_package()] + determine_dkms_package(),
 
177
            'packages': [determine_dkms_package(),
178
178
                         ['calico-compute',
179
179
                          'bird',
180
180
                          'neutron-dhcp-agent',
209
209
            'server_packages': ['neutron-server',
210
210
                                'neutron-plugin-plumgrid'],
211
211
            'server_services': ['neutron-server']
 
212
        },
 
213
        'midonet': {
 
214
            'config': '/etc/neutron/plugins/midonet/midonet.ini',
 
215
            'driver': 'midonet.neutron.plugin.MidonetPluginV2',
 
216
            'contexts': [
 
217
                context.SharedDBContext(user=config('neutron-database-user'),
 
218
                                        database=config('neutron-database'),
 
219
                                        relation_prefix='neutron',
 
220
                                        ssl_dir=NEUTRON_CONF_DIR)],
 
221
            'services': [],
 
222
            'packages': [determine_dkms_package()],
 
223
            'server_packages': ['neutron-server',
 
224
                                'python-neutron-plugin-midonet'],
 
225
            'server_services': ['neutron-server']
212
226
        }
213
227
    }
214
228
    if release >= 'icehouse':
219
233
                                             'neutron-plugin-ml2']
220
234
        # NOTE: patch in vmware renames nvp->nsx for icehouse onwards
221
235
        plugins['nvp'] = plugins['nsx']
 
236
    if release >= 'kilo':
 
237
        plugins['midonet']['driver'] = (
 
238
            'neutron.plugins.midonet.plugin.MidonetPluginV2')
 
239
    if release >= 'liberty':
 
240
        plugins['midonet']['driver'] = (
 
241
            'midonet.neutron.plugin_v1.MidonetPluginV2')
 
242
        plugins['midonet']['server_packages'].remove(
 
243
            'python-neutron-plugin-midonet')
 
244
        plugins['midonet']['server_packages'].append(
 
245
            'python-networking-midonet')
 
246
        plugins['plumgrid']['driver'] = (
 
247
            'networking_plumgrid.neutron.plugins.plugin.NeutronPluginPLUMgridV2')
 
248
        plugins['plumgrid']['server_packages'].remove(
 
249
            'neutron-plugin-plumgrid')
222
250
    return plugins
223
251
 
224
252
 
269
297
        return 'neutron'
270
298
 
271
299
 
272
 
def parse_mappings(mappings):
 
300
def parse_mappings(mappings, key_rvalue=False):
 
301
    """By default mappings are lvalue keyed.
 
302
 
 
303
    If key_rvalue is True, the mapping will be reversed to allow multiple
 
304
    configs for the same lvalue.
 
305
    """
273
306
    parsed = {}
274
307
    if mappings:
275
308
        mappings = mappings.split()
276
309
        for m in mappings:
277
310
            p = m.partition(':')
278
 
            key = p[0].strip()
279
 
            if p[1]:
280
 
                parsed[key] = p[2].strip()
 
311
 
 
312
            if key_rvalue:
 
313
                key_index = 2
 
314
                val_index = 0
 
315
                # if there is no rvalue skip to next
 
316
                if not p[1]:
 
317
                    continue
281
318
            else:
282
 
                parsed[key] = ''
 
319
                key_index = 0
 
320
                val_index = 2
 
321
 
 
322
            key = p[key_index].strip()
 
323
            parsed[key] = p[val_index].strip()
283
324
 
284
325
    return parsed
285
326
 
297
338
def parse_data_port_mappings(mappings, default_bridge='br-data'):
298
339
    """Parse data port mappings.
299
340
 
300
 
    Mappings must be a space-delimited list of bridge:port mappings.
 
341
    Mappings must be a space-delimited list of bridge:port.
301
342
 
302
 
    Returns dict of the form {bridge:port}.
 
343
    Returns dict of the form {port:bridge} where ports may be mac addresses or
 
344
    interface names.
303
345
    """
304
 
    _mappings = parse_mappings(mappings)
 
346
 
 
347
    # NOTE(dosaboy): we use rvalue for key to allow multiple values to be
 
348
    # proposed for <port> since it may be a mac address which will differ
 
349
    # across units this allowing first-known-good to be chosen.
 
350
    _mappings = parse_mappings(mappings, key_rvalue=True)
305
351
    if not _mappings or list(_mappings.values()) == ['']:
306
352
        if not mappings:
307
353
            return {}
308
354
 
309
355
        # For backwards-compatibility we need to support port-only provided in
310
356
        # config.
311
 
        _mappings = {default_bridge: mappings.split()[0]}
312
 
 
313
 
    bridges = _mappings.keys()
314
 
    ports = _mappings.values()
315
 
    if len(set(bridges)) != len(bridges):
316
 
        raise Exception("It is not allowed to have more than one port "
317
 
                        "configured on the same bridge")
318
 
 
 
357
        _mappings = {mappings.split()[0]: default_bridge}
 
358
 
 
359
    ports = _mappings.keys()
319
360
    if len(set(ports)) != len(ports):
320
361
        raise Exception("It is not allowed to have the same port configured "
321
362
                        "on more than one bridge")