1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4 filetype=python
#
# Copyright (c) 2015 Midokura Europe SARL, All Rights Reserved.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import subprocess
from charmhelpers.contrib.openstack import utils
from charmhelpers.core import hookenv
from charmhelpers import fetch # noqa
try:
from midonet_helpers import puppet
except ImportError:
fetch.apt_install(['python-jinja2', 'python-yaml'], fatal=True)
from midonet_helpers import puppet
def _configure_sysctl():
from augeas import Augeas
aug = Augeas()
aug.set('/files/etc/sysctl.conf/net.ipv4.ip_forward', '1')
aug.set('/files/etc/sysctl.conf/net.ipv4.conf.all.rp_filter', '0')
aug.set('/files/etc/sysctl.conf/net.ipv4.conf.default.rp_filter', '0')
aug.save()
subprocess.check_call(['sysctl', '-p'])
if __name__ == '__main__':
hookenv.status_set('maintenance', 'Executing pre-install')
utils.configure_installation_source(hookenv.config('openstack-origin'))
fetch.apt_install('puppet', fatal=True)
puppet.set_juju_hierarchy(extra_data_dirs=['neutron_agents'])
puppet.module_install('midonet-midonet')
hookenv.status_set('maintenance', 'Installing packages')
fetch.apt_update()
fetch.apt_install(['nova-api-metadata',
'neutron-dhcp-agent',
'neutron-metadata-agent',
'python-augeas',
'python-jinja2'], fatal=True)
hookenv.status_set('maintenance', 'Enable forwarding')
_configure_sysctl()
|