~james-page/charms/trusty/midonet-agent/trunk

« back to all changes in this revision

Viewing changes to hooks/midonet_helpers/repositories.py

  • Committer: Antoni Segura Puimedon
  • Date: 2015-08-03 13:47:25 UTC
  • Revision ID: toni@midokura.com-20150803134725-uldzl0ghv5oe8la8
Initial midonet-agent commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Copyright (c) 2015 Midokura SARL, All Rights Reserved.
 
3
#
 
4
# Licensed under the Apache License, Version 2.0 (the "License");
 
5
# you may not use this file except in compliance with the License.
 
6
# You may obtain a copy of the License at
 
7
#
 
8
#    http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
10
# Unless required by applicable law or agreed to in writing, software
 
11
# distributed under the License is distributed on an "AS IS" BASIS,
 
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
# See the License for the specific language governing permissions and
 
14
# limitations under the License.
 
15
#
 
16
import collections
 
17
 
 
18
 
 
19
RELEASES = collections.OrderedDict([
 
20
    ('icehouse/mem-1.8', {
 
21
        'midonet_repo':
 
22
        'http://%s:%s@apt.midokura.com/midonet/v1.8/stable',
 
23
        'midonet_openstack_repo':
 
24
        'http://%s:%s@apt.midokura.com/openstack/icehouse/stable',
 
25
        'midonet_stage':
 
26
        'trusty',
 
27
        'midonet_key_fingerprint':
 
28
        'BC4E4E90DDA81C21396081CC67B38D3A054314CD',
 
29
        'openstack_release':
 
30
        'icehouse'
 
31
    }),
 
32
    ('juno/mem-1.8', {
 
33
        'midonet_repo':
 
34
        'http://%s:%s@apt.midokura.com/midonet/v1.8/stable',
 
35
        'midonet_openstack_repo':
 
36
        'http://%s:%s@apt.midokura.com/openstack/juno/stable',
 
37
        'midonet_stage':
 
38
        'trusty',
 
39
        'midonet_key_fingerprint':
 
40
        'BC4E4E90DDA81C21396081CC67B38D3A054314CD',
 
41
        'openstack_release':
 
42
        'juno'
 
43
    }),
 
44
    ('juno/mem-1.9', {
 
45
        'midonet_repo':
 
46
        'http://%s:%s@apt.midokura.com/midonet/v1.9/stable',
 
47
        'midonet_openstack_repo':
 
48
        'http://%s:%s@apt.midokura.com/openstack/juno/stable',
 
49
        'midonet_stage':
 
50
        'trusty',
 
51
        'midonet_key_fingerprint':
 
52
        'BC4E4E90DDA81C21396081CC67B38D3A054314CD',
 
53
        'openstack_release':
 
54
        'juno'
 
55
    }),
 
56
    ('kilo/mem-1.9', {
 
57
        'midonet_repo':
 
58
        'http://%s:%s@apt.midokura.com/midonet/v1.9/stable',
 
59
        'midonet_openstack_repo':
 
60
        'http://%s:%s@apt.midokura.com/openstack/kilo/stable',
 
61
        'midonet_stage':
 
62
        'trusty',
 
63
        'midonet_key_fingerprint':
 
64
        'BC4E4E90DDA81C21396081CC67B38D3A054314CD',
 
65
        'openstack_release':
 
66
        'kilo'
 
67
    }),
 
68
    ('juno/midonet-2015.03', {
 
69
        'midonet_repo':
 
70
        'http://repo.midonet.org/midonet/v2015.03',
 
71
        'openstack_release':
 
72
        'juno'
 
73
    }),
 
74
    ('kilo/midonet-2015.03', {
 
75
        'midonet_repo':
 
76
        'http://repo.midonet.org/midonet/v2015.03',
 
77
        'openstack_release':
 
78
        'kilo'
 
79
    }),
 
80
])
 
81
 
 
82
 
 
83
def config(midonet_rel=None, user=None, password=None):
 
84
    cfg = {}
 
85
 
 
86
    if midonet_rel in (None, '', 'latest'):
 
87
        cfg['midonet_latest'] = True
 
88
    else:
 
89
        if midonet_rel not in RELEASES:
 
90
            raise ValueError('Unrecognized release %s' % midonet_rel)
 
91
        cfg = dict(RELEASES[midonet_rel])
 
92
        mem = midonet_rel.split('/')[1].startswith('mem')
 
93
        if mem:
 
94
            if user is None or password is None:
 
95
                raise ValueError('MEM releases require credentials')
 
96
            cfg['midonet_repo'] = cfg['midonet_repo'] % (user, password)
 
97
 
 
98
    return cfg