Fixes several bugs

Change-Id: I990313a1b606e995a41abfe94b7afb18b8b35a3c
This commit is contained in:
Alejandro Andreu 2016-08-22 10:44:16 +02:00
parent d45751184b
commit 79de9c11f4
11 changed files with 57 additions and 42 deletions

View File

@ -92,6 +92,10 @@
#
class midonet::agent (
$zookeeper_hosts,
$controller_host,
$metadata_port,
$shared_secret,
$package_name = undef,
$service_name = undef,
$service_ensure = undef,
@ -100,10 +104,6 @@ class midonet::agent (
$package_ensure = undef,
$manage_java = undef,
$max_heap_size = undef,
$zookeeper_hosts,
$controller_host,
$metadata_port,
$shared_secret,
$is_mem = false,
$manage_repo = false,
$mem_username = undef,

View File

@ -37,16 +37,16 @@
#
class midonet::agent::run (
$zookeeper_hosts,
$controller_host,
$metadata_port,
$shared_secret,
$service_name = 'midolman',
$service_ensure = 'running',
$service_enable = true,
$agent_config_path = '/etc/midolman/midolman.conf',
$jvm_config_path = '/etc/midolman/midolman-env.sh',
$max_heap_size = '2048M',
$zookeeper_hosts,
$controller_host,
$metadata_port,
$shared_secret,
) {
file { '/tmp/mn-agent_config.sh':

View File

@ -1,6 +1,6 @@
# == Class: midonet::analytics
#
# Installs midonet analytics packages
# Installs midonet analytics packages
#
# === Parameters
#
@ -47,11 +47,11 @@
#
class midonet::analytics (
$zookeeper_hosts,
$is_mem = false,
$manage_repo = false,
$mem_username = undef,
$mem_password = undef,
$zookeeper_hosts,
) {

View File

@ -38,8 +38,8 @@
class midonet::analytics::quickstart (
$config_path = '/etc/midonet/midonet.conf',
$zookeeper_hosts,
$config_path = '/etc/midonet/midonet.conf',
) {
file { 'set_config':

View File

@ -81,6 +81,11 @@
# limitations under the License.
#
class midonet::cluster (
$zookeeper_hosts,
$cassandra_servers,
$cassandra_rep_factor,
$keystone_admin_token,
$keystone_host,
$package_name = undef,
$service_name = undef,
$service_ensure = undef,
@ -93,11 +98,6 @@ class midonet::cluster (
$max_heap_size = undef,
$heap_newsize = undef,
$is_mem = undef,
$zookeeper_hosts,
$cassandra_servers,
$cassandra_rep_factor,
$keystone_admin_token,
$keystone_host,
) {

View File

@ -23,6 +23,12 @@
# limitations under the License.
#
class midonet::cluster::run (
$zookeeper_hosts,
$cassandra_servers,
$cassandra_rep_factor,
$keystone_admin_token,
$keystone_host,
$keystone_port = '35357',
$service_name = 'midonet-cluster',
$service_ensure = 'running',
$service_enable = true,
@ -32,12 +38,6 @@ class midonet::cluster::run (
$cluster_port = '8181',
$max_heap_size = '2048M',
$heap_newsize = '1024M',
$zookeeper_hosts,
$cassandra_servers,
$cassandra_rep_factor,
$keystone_admin_token,
$keystone_host,
$keystone_port = '35357'
) {
file { '/tmp/mn-cluster_config.sh':

View File

@ -102,7 +102,7 @@ class midonet::gateway::static (
}
# Finally, execute the script
exec { "/bin/bash ${scripts_dir}/create_fake_uplink_l2.sh":
exec { "/bin/bash -x ${scripts_dir}/create_fake_uplink_l2.sh 2>&1 | tee /tmp/bash.out":
returns => ['0', '7'],
require => [
File['fake_uplink_script'],

View File

@ -26,20 +26,23 @@
# Copyright (c) 2016 Midokura SARL, All Rights Reserved.
class midonet::mem::vhost (
$mem_apache_port = $midonet::params::mem_apache_port,
$mem_apache_docroot = $midonet::params::mem_apache_docroot,
$mem_apache_servername = $midonet::params::mem_apache_servername,
$proxy_pass = [
{ 'path' => "/${midonet::params::mem_api_namespace}",
'url' => $midonet::params::mem_api_host,
},
],
) inherits midonet::params {
$directories = [
{ 'path' => $docroot,
{
'path' => $midonet::params::mem_apache_docroot,
'allow' => 'from all',
},
],
) inherits midonet::params {
]
$mem_apache_port = $midonet::params::mem_apache_port
$mem_apache_docroot = $midonet::params::mem_apache_docroot
$mem_apache_servername = $midonet::params::mem_apache_servername
$proxy_pass = [
{
'path' => "/${midonet::params::mem_api_namespace}",
'url' => $midonet::params::mem_api_host,
},
]
validate_string($mem_apache_port)
validate_string($mem_apache_docroot)

View File

@ -125,11 +125,13 @@ define midonet::resources::network_creation(
}
neutron_network { $network_external:
ensure => present,
router_external => true,
shared => true,
} ->
neutron_subnet { $subnet_name:
ensure => present,
allocation_pools => $allocation_pools,
enable_dhcp => false,
gateway_ip => $gateway_ip,
@ -142,14 +144,17 @@ define midonet::resources::network_creation(
} ->
neutron_router_interface { "${edge_router_name}:${subnet_name}":
ensure => present,
} ->
neutron_network { $edge_network_name:
ensure => present,
tenant_id => $tenant_name,
provider_network_type => 'uplink',
} ->
neutron_subnet { $edge_subnet_name:
ensure => present,
enable_dhcp => false,
cidr => $edge_cidr,
tenant_id => $tenant_name,
@ -157,6 +162,7 @@ define midonet::resources::network_creation(
} ->
neutron_port { $port_name:
ensure => present,
network_name => $edge_network_name,
binding_host_id => $::fqdn,
binding_profile => {
@ -166,7 +172,8 @@ define midonet::resources::network_creation(
} ->
neutron_router_interface { "${edge_router_name}:null":
port => $port_name,
ensure => present,
port => $port_name,
}
}

View File

@ -15,7 +15,7 @@ describe 'midonet::gateway::static' do
:fip => '200.200.200.0/24',
:edge_router => 'edge-router',
:veth0_ip => '172.19.0.1',
:veth1_ip => '172.19.0.2',
:veth1_ip => '172.19.0.2',
:veth_network => '172.19.0.0/30',
:scripts_dir => '/tmp',
:uplink_script => 'create_fake_uplink_l2.sh',
@ -23,6 +23,6 @@ describe 'midonet::gateway::static' do
}
end
it { is_expected.to contain_file('fake_uplink_script').with_ensure('present') }
it { is_expected.to contain_exec('/bin/bash /tmp/create_fake_uplink_l2.sh') }
it { is_expected.to contain_exec('/bin/bash -x /tmp/create_fake_uplink_l2.sh 2>&1 | tee /tmp/bash.out') }
end
end

View File

@ -29,7 +29,7 @@ HOST_ID=$(midonet-cli -A -e host list | grep ${HOSTNAME} | awk '{ print $2 }')
BINDING=$(midonet-cli -A -e host ${HOST_ID} list binding interface veth1)
# If interface veth1 is bound already stop the script
if [ -n "${BINDING}" ]; then
if [ -n "$(ip l | grep "veth")" ]; then
echo "Interface veth1 is already bound to host id ${HOST_ID}" >&2
exit 7
fi
@ -42,8 +42,14 @@ ip link set dev veth1 up
# Create a bridge, set an IP address and attach veth0
brctl addbr uplinkbridge
brctl addif uplinkbridge veth0
echo "ZzZ..."
sleep 3
ip addr add ${VETH0_IP}/30 dev uplinkbridge
echo "ZzZ..."
sleep 3
ip link set dev uplinkbridge up
echo "ZzZ..."
sleep 3
# Enable IPv4 forwarding
sysctl -w net.ipv4.ip_forward=1
@ -53,12 +59,11 @@ ip route add ${FIP} via ${VETH1_IP}
# Create a port on the edge router and bind it to the veth pair
ROUTER_ID=$(midonet-cli -A -e router list | grep ${EDGE_ROUTER} | awk '{ print $2 }')
PORT_ID=$(midonet-cli -A -e router ${ROUTER_ID} add port address ${VETH1_IP} \
net ${VETH_NETWORK} | cut -d ":" -f 2)
PORT_ID=$(midonet-cli -A -e router ${ROUTER_ID} port list | grep ${VETH1_IP} | cut -f 2 -d " ")
midonet-cli -e router ${ROUTER_ID} add route src 0.0.0.0/0 dst 0.0.0.0/0 \
type normal port router ${ROUTER_ID} port ${PORT_ID} gw ${VETH0_IP}
midonet-cli -e host ${HOST_ID} add binding port router ${ROUTER_ID} \
port ${PORT_ID} interface veth1
#midonet-cli -e host ${HOST_ID} add binding port router ${ROUTER_ID} \
#port ${PORT_ID} interface veth1
# Add masquerading to enable NATing
iptables -t nat -I POSTROUTING -o ${NIC} -s ${FIP} -j MASQUERADE