MidoNet support up until Liberty

This commit is contained in:
Antoni Segura Puimedon 2016-01-22 16:14:59 +01:00
parent e7a00482bf
commit cdb8db5e5e
17 changed files with 212 additions and 10 deletions

View File

@ -101,6 +101,7 @@ options:
vsp - Nuage Networks VSP
nsx - VMWare NSX
Calico - Project Calico Networking
midonet - MidoNet
.
overlay-network-type:
default: gre
@ -487,3 +488,25 @@ options:
description: |
Connect timeout configuration in ms for haproxy, used in HA
configurations. If not provided, default value of 5000ms is used.
midonet-origin:
default: midonet-2015.06
type: string
description: |
'mem-1.8', 'mem-1.9',
'midonet-2015.06'
NOTE: updating this setting to a source that is known to provide a later
version of MidoNet (do not change between MEM and MidoNet) will
trigger a software upgrade.
mem-username:
type: string
default:
description: |
The Midokura Enterprise MidoNet username credentials to access the
repository.
mem-password:
type: string
default:
description: |
The Midokura Enterprise MidoNet password credentials to access the
repository.

19
files/midokura.key Normal file
View File

@ -0,0 +1,19 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.5
Comment: Hostname: keyserver.ubuntu.com
mI0ETb6aOgEEAMVw8Vnwk+zpDtsc0gSW10JEe48zKr2vpl9tQgWAFOPgOA1NglYMw/xT6Rns
7CrYxPR0cb3DeMFtFdMkfWXO0R6x4yHrozMDY/DpvwgYQclIIbcYYe0p83nlBp793D2dSq60
HWuXJu3oi0wQQuR0/jTmOnjxzCzu5jKdJeXihl95ABEBAAG0Jk1pZG9rdXJhIChNaWRva3Vy
YSkgPGluZm9AbWlkb2t1cmEuanA+iLgEEwECACIFAk2+mjoCGwMGCwkIBwMCBhUIAgkKCwQW
AgMBAh4BAheAAAoJEGezjToFQxTNAp0D/2c+PLnRFzEXCztXT+05xoO1mPzpm3x2p5ecVPGH
R8IxhozlN9DDGDdnvNfMOhi6nv/G2l86+9Fj8Dz01ne0RZzZHSS1DF/zb6dMYrPJqiT1DXKH
0Y73OL/+M7rsutEq0B/DKhjdBfFPutk3gerEUZPNfIhScE3tnwCnVGJKPQbFuI0ETb6aOgEE
ANLJK3gmXrsp1VKnt663RoxZgoFQgQ6wHaZZWhULTteafjoThX9tj7FidR2+7qJLwpa57M9d
rib4OlbW+rE4PW199/Uqfy86gLv76Q2GZMpzaYB1ZZow0Ny1RTCwh7apkhR/8fCUpq37aODQ
4YwBpZC54iXVKfcntpdJFoObIqXtABEBAAGInwQYAQIACQUCTb6aOgIbDAAKCRBns406BUMU
zfzOBACKx4jChKTAl6HfldOxVN7o8DQpd5rgkHIEj062ym4Zq5t2v3oaz0H0P2WV66MAhOuj
gX0V1duZi8fKHdIsdk0nvEa/mV0QS6pEAeZh+dbLkKyu1J4MSi5l+L+te5XjYBGpoRa3ZGrI
R3CkA0oQDCOh312SrcH6Tn9RBPChVSigzg==
=zF5K
-----END PGP PUBLIC KEY BLOCK-----

24
files/midonet.key Normal file
View File

@ -0,0 +1,24 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.5
Comment: Hostname: keyserver.ubuntu.com
mQGiBFRF760RBADwIz8rK0K1qiXbq0/cda42oKZW+jvcqUIDsNeKYSWI5YRfS4NX+jRJM/rL
PzQD+JZtLeFHeLK0qxpr5b2acxleOgNfw3hzxz4DNQsVbkts3n1s7YT80DwNdYPBbFCAOOkJ
jH7CL2PN4fTs5eP/0QpMOZT+s5DTqozPDgTYWhhVrwCgoc5H2zYVW86Ok3c0fOru9VZPJxsE
AIexw3sBv9FZyvVr6rehiVlzOtwfHwSEQZQ511so46H5GdLqQFwThKmWVvxyDAGshtpjLJbs
KHilEJVkfzhs/xyCjwAPl8VbIYgUy/FlhKtFWWxkQLlUwuC5iOPLdzhoL1PEzZuCYmMkSr0E
XASN83nbzIIqdQgvEZrAUGUzTf68A/9eSiry88vEIIGL7hT2rw/NockwCGsc2xrjqrfs9PpU
rg7ksTPua1UQUkMeWoKEoYpGppGd5XXEvo6287i8eAB4B9qr4AGbz8NKmVI2lC9V641Ecu3/
kmhaGQRBmCZgcW3B987rTyY5lsLc66+tNai6L72y1fj5nBtY2MVYg6ixZrRNTWlkb2t1cmEg
UlBNICYgREVCIFJlcG9zaXRvcnkgQXV0b21hdGljIFNpZ25pbmcgS2V5ICgyMDE0KSA8b3Bz
QG1pZG9rdXJhLmNvbT6IYgQTEQIAIgUCVEXvrQIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgEC
F4AACgkQ/ONA0lDxj8+EZgCdEqXQrZ8PiemTgQK7044Deed5OpsAnjL8Cw4GnGJZHmW24pKQ
IkzTvb1SuQENBFRF760QBADJD9aLzLYAehNITLlrNao+bZsSAAeKRYWjtyf6Z620/WiQw6a+
01/ZwrthvXNUcnIVIKKokPVpXR29AUV0T7npDMTkQCXfw24X+9NedBCquJpHnBS/YySHP+EJ
vNeLc0xdwnOcGehe7IeaDN0eEWx+HVhEfC/lXa/Pebs4OpIo/wADBwQAwyCTQ7Vod3jO7JFP
6R6mS5gX3Sx6s3ocE4laDFBmh9d8GPWpdzHwzPzrVaIw/xSaxP2zXeWFcDoY3zT7PH3dm+xj
cEG23iTqvmMAr7EXirKu9pL/DKuBPncNMTS6JoltGGVzZLoJF2OJZX81c+U1mGyLpWg/hK3K
t9VpzNjFGc2ISQQYEQIACQUCVEXvrQIbDAAKCRD840DSUPGPz0PiAJ9QXGyMCTymuuCdYyEX
3D94y0Z8FgCaAwYNRahgGw/HN04xkqfrN7bXajE=
=hLRg
-----END PGP PUBLIC KEY BLOCK-----

View File

@ -233,6 +233,13 @@ def neutron_plugins():
'neutron-plugin-ml2']
# NOTE: patch in vmware renames nvp->nsx for icehouse onwards
plugins['nvp'] = plugins['nsx']
if release >= 'kilo':
plugins['midonet']['driver'] = (
'neutron.plugins.midonet.plugin.MidonetPluginV2')
if release >= 'liberty':
if config('midonet-origin')[4:5] == '1':
plugins['midonet']['driver'] = (
'midonet.neutron.plugin_v1.MidonetPluginV2')
return plugins

View File

@ -0,0 +1 @@
neutron_api_hooks.py

View File

@ -0,0 +1 @@
neutron_api_hooks.py

View File

@ -0,0 +1 @@
neutron_api_hooks.py

View File

@ -166,6 +166,12 @@ class NeutronCCContext(context.NeutronContext):
ctxt['pg_username'] = config('plumgrid-username')
ctxt['pg_password'] = config('plumgrid-password')
ctxt['virtual_ip'] = config('plumgrid-virtual-ip')
elif config('neutron-plugin') == 'midonet':
ctxt.update(MidonetContext()())
identity_context = IdentityServiceContext(service='neutron',
service_user='neutron')()
if identity_context is not None:
ctxt.update(identity_context)
ctxt['l2_population'] = self.neutron_l2_population
ctxt['enable_dvr'] = self.neutron_dvr
ctxt['l3_ha'] = self.neutron_l3ha
@ -342,3 +348,21 @@ class NeutronApiSDNConfigFileContext(context.OSContextGenerator):
if neutron_server_plugin_conf:
return {'config': neutron_server_plugin_conf}
return {'config': '/etc/neutron/plugins/ml2/ml2_conf.ini'}
class MidonetContext(context.OSContextGenerator):
def __init__(self, rel_name='midonet'):
self.rel_name = rel_name
self.interfaces = [rel_name]
def __call__(self):
for rid in relation_ids(self.rel_name):
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit)
ctxt = {
'midonet_api_ip': rdata.get('host'),
'midonet_api_port': rdata.get('port'),
}
if self.context_complete(ctxt):
return ctxt
return {}

View File

@ -25,6 +25,7 @@ from charmhelpers.core.hookenv import (
)
from charmhelpers.core.host import (
mkdir,
restart_on_change,
service_reload,
service_restart,
@ -162,18 +163,18 @@ def configure_https():
def install():
status_set('maintenance', 'Executing pre-install')
execd_preinstall()
configure_installation_source(config('openstack-origin'))
additional_install_locations(
config('neutron-plugin'), config('openstack-origin')
)
openstack_origin = config('openstack-origin')
configure_installation_source(openstack_origin)
neutron_plugin = config('neutron-plugin')
additional_install_locations(neutron_plugin, openstack_origin)
add_source(config('extra-source'), config('extra-key'))
status_set('maintenance', 'Installing apt packages')
apt_update(fatal=True)
packages = determine_packages(config('openstack-origin'))
packages = determine_packages(openstack_origin)
apt_install(packages, fatal=True)
if config('neutron-plugin') == 'vsp':
if neutron_plugin == 'vsp':
source = config('nuage-tarball-url')
if source is not None:
try:
@ -201,6 +202,10 @@ def install():
[open_port(port) for port in determine_ports()]
if neutron_plugin == 'midonet':
mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron',
perms=0o755, force=False)
@hooks.hook('vsd-rest-api-relation-changed')
@restart_on_change(restart_map(), stopstart=True)
@ -593,6 +598,14 @@ def etcd_proxy_force_restart(relation_id=None):
force_etcd_restart()
@hooks.hook('midonet-relation-joined')
@hooks.hook('midonet-relation-changed')
@hooks.hook('midonet-relation-departed')
@restart_on_change(restart_map())
def midonet_changed():
CONFIGS.write_all()
def main():
try:
hooks.execute(sys.argv)

View File

@ -28,6 +28,7 @@ from charmhelpers.contrib.python.packages import (
)
from charmhelpers.core.hookenv import (
charm_dir,
config,
log,
relation_ids,
@ -198,14 +199,43 @@ def additional_install_locations(plugin, source):
on the Neutron plugin being used. This will also force an immediate
package upgrade.
'''
release = get_os_codename_install_source(source)
if plugin == 'Calico':
if config('calico-origin'):
calico_source = config('calico-origin')
else:
release = get_os_codename_install_source(source)
calico_source = 'ppa:project-calico/%s' % release
add_source(calico_source)
elif plugin == 'midonet':
midonet_origin = config('midonet-origin')
release_num = midonet_origin.split('-')[1]
if midonet_origin.startswith('mem'):
with open(os.path.join(charm_dir(),
'files/midokura.key')) as midokura_gpg_key:
priv_gpg_key = midokura_gpg_key.read()
mem_username = config('mem-username')
mem_password = config('mem-password')
if release in ('juno', 'kilo', 'liberty'):
add_source(
'deb http://%s:%s@apt.midokura.com/openstack/%s/stable '
'trusty main' % (mem_username, mem_password, release),
key=priv_gpg_key)
add_source('http://%s:%s@apt.midokura.com/midonet/v%s/stable '
'main' % (mem_username, mem_password, release_num),
key=priv_gpg_key)
else:
with open(os.path.join(charm_dir(),
'files/midonet.key')) as midonet_gpg_key:
pub_gpg_key = midonet_gpg_key.read()
if release in ('juno', 'kilo', 'liberty'):
add_source(
'deb http://repo.midonet.org/openstack-%s stable main' %
release, key=pub_gpg_key)
add_source('deb http://repo.midonet.org/midonet/v%s stable main' %
release_num, key=pub_gpg_key)
apt_update(fatal=True)
apt_upgrade(fatal=True)

View File

@ -44,6 +44,8 @@ requires:
scope: container
etcd-proxy:
interface: etcd-proxy
midonet:
interface: midonet
peers:
cluster:
interface: neutron-api-ha

View File

@ -0,0 +1,11 @@
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[MIDONET]
# MidoNet API URL
midonet_uri = http://{{ midonet_api_ip }}:{{ midonet_api_port }}/midonet-api
# credentials
username = {{ admin_user }}
password = {{ admin_password }}
project_id = {{ admin_tenant_name }}

View File

@ -102,4 +102,6 @@ admin_password = {{ admin_password }}
[service_providers]
service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
{% if not neutron_plugin or neutron_plugin != 'midonet' -%}
service_provider=FIREWALL:Iptables:neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver:default
{% endif -%}

View File

@ -107,9 +107,13 @@ root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
{% include "section-rabbitmq-oslo" %}
[service_providers]
service_provider=LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
service_provider=VPN:openswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
{% if neutron_plugin and neutron_plugin == 'midonet' -%}
service_provider = LOADBALANCER:Midonet:midonet.neutron.services.loadbalancer.driver.MidonetLoadbalancerDriver:default
{% else -%}
service_provider=LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
service_provider=FIREWALL:Iptables:neutron_fwaas.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver:default
{% endif -%}
[oslo_concurrency]
lock_path = $state_path/lock

View File

@ -36,6 +36,8 @@ service_plugins = {{ service_plugins }}
{% else -%}
{% if neutron_plugin in ['ovs', 'ml2', 'Calico'] -%}
service_plugins = router,firewall,lbaas,vpnaas,metering
{% elif neutron_plugin == 'midonet' -%}
service_plugins = lbaas
{% endif -%}
{% endif -%}
{% endif -%}
@ -44,7 +46,7 @@ service_plugins = router,firewall,lbaas,vpnaas,metering
allow_overlapping_ips = True
{% if neutron_plugin == 'Calico' -%}
neutron_firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
{% else -%}
{% elif neutron_plugin != 'midonet' -%}
neutron_firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
{% endif -%}
{% endif -%}

View File

@ -15,5 +15,9 @@
# auth_version = 2
[service_providers]
{% if neutron_plugin and neutron_plugin == 'midonet' -%}
service_provider = LOADBALANCER:Midonet:midonet.neutron.services.loadbalancer.driver.MidonetLoadbalancerDriver:default
{% else -%}
service_provider=LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
# service_provider=LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
# service_provider=LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
{% endif %}

View File

@ -283,6 +283,9 @@ class NeutronCCContextTest(CharmTestCase):
self.test_config.set('plumgrid-username', 'plumgrid')
self.test_config.set('plumgrid-password', 'plumgrid')
self.test_config.set('plumgrid-virtual-ip', '192.168.100.250')
self.test_config.set('midonet-origin', 'mem-1.9')
self.test_config.set('mem-username', 'yousir')
self.test_config.set('mem-password', 'heslo')
self.test_config.set('enable-ml2-port-security', True)
self.test_config.set('dhcp-agents-per-network', 3)
@ -654,3 +657,34 @@ class NeutronApiSDNConfigFileContextTest(CharmTestCase):
self.assertEquals(napisdn_ctxt, {
'config': '/etc/neutron/plugins/ml2/ml2_conf.ini'
})
class MidonetContextTest(CharmTestCase):
def setUp(self):
super(MidonetContextTest, self).setUp(context, TO_PATCH)
self.relation_get.side_effect = self.test_relation.get
self.config.side_effect = self.test_config.get
self.test_config.set('neutron-plugin', 'midonet')
self.test_config.set('midonet-origin', 'midonet-2015.06')
def tearDown(self):
super(MidonetContextTest, self).tearDown()
def test_midonet_no_related_units(self):
self.related_units.return_value = []
ctxt = context.MidonetContext()()
expect = {}
self.assertEquals(expect, ctxt)
def test_some_related_units(self):
self.related_units.return_value = ['unit1']
self.relation_ids.return_value = ['rid1']
self.test_relation.set({'host': '11.11.11.11',
'port': '8080'})
ctxt = context.MidonetContext()()
expect = {'midonet_api_ip': '11.11.11.11',
'midonet_api_port': '8080'}
self.assertEquals(expect, ctxt)