diff --git a/deployment/puppet/cluster/files/ocf/ns_haproxy b/deployment/puppet/cluster/files/ocf/ns_haproxy
index 2f582ce046..87f1c28a7e 100755
--- a/deployment/puppet/cluster/files/ocf/ns_haproxy
+++ b/deployment/puppet/cluster/files/ocf/ns_haproxy
@@ -331,6 +331,11 @@ set_ns_routing() {
ocf_run iptables -t nat -A POSTROUTING -s "${OCF_RESKEY_namespace_ip}" -j MASQUERADE -m comment --comment "masquerade-for-haproxy-namespace"
fi
+ ### Needed for ML2 routing ###
+ ocf_run sysctl -w net.ipv4.conf.${OCF_RESKEY_host_interface}.rp_filter=2
+ ocf_run $RUN_IN_NS sysctl -w net.ipv4.conf.all.rp_filter=2
+ ##############################
+
if [[ "${OCF_RESKEY_other_networks}" != "false" ]] ; then
for network in ${OCF_RESKEY_other_networks}
do
diff --git a/deployment/puppet/cluster/files/ocf/ns_ntp b/deployment/puppet/cluster/files/ocf/ns_ntp
index 8dc0ce4f1e..f1b55d4335 100644
--- a/deployment/puppet/cluster/files/ocf/ns_ntp
+++ b/deployment/puppet/cluster/files/ocf/ns_ntp
@@ -34,13 +34,6 @@ OCF_RESKEY_pidfile_default="/var/run/ntpd.pid"
OCF_RESKEY_binpath_default="/usr/sbin/ntpd"
OCF_RESKEY_extraconf_default=""
-OCF_RESKEY_host_interface_default="vrouter-host"
-OCF_RESKEY_namespace_interface_default="vr-ns"
-OCF_RESKEY_host_ip_default="240.0.0.5"
-OCF_RESKEY_namespace_ip_default="240.0.0.6"
-OCF_RESKEY_network_mask_default="30"
-OCF_RESKEY_route_metric_default="10000"
-
: ${OCF_ROOT=${OCF_ROOT_default}}
: ${OCF_RESKEY_ns=${OCF_RESKEY_ns_default}}
@@ -49,13 +42,6 @@ OCF_RESKEY_route_metric_default="10000"
: ${OCF_RESKEY_binpath=${OCF_RESKEY_binpath_default}}
: ${OCF_RESKEY_extraconf=${OCF_RESKEY_extraconf_default}}
-: ${OCF_RESKEY_host_interface=${OCF_RESKEY_host_interface_default}}
-: ${OCF_RESKEY_namespace_interface=${OCF_RESKEY_namespace_interface_default}}
-: ${OCF_RESKEY_host_ip=${OCF_RESKEY_host_ip_default}}
-: ${OCF_RESKEY_namespace_ip=${OCF_RESKEY_namespace_ip_default}}
-: ${OCF_RESKEY_network_mask=${OCF_RESKEY_network_mask_default}}
-: ${OCF_RESKEY_route_metric=${OCF_RESKEY_route_metric_default}}
-
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
. ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
@@ -134,71 +120,6 @@ For example, "-f /etc/ntp/shared.cfg"
-
-
-The host part of the interface pair used to connect the namespace to the network
-For example, "vrouter-host"
-
-The name of the host interface used for namespace
-
-
-
-
-
-The namespace part of the interface pair used to connect the namespace to the network
-For example, "vrouter-ns"
-
-The name of the namespace interface used for namespace
-
-
-
-
-
-The IP address used by the host interface. Must be from the same subnet as namesapce IP
-and uses network_mask to determine subnet.
-Should not collide with any IP addresses already used in your network.
-For example, "240.0.0.5"
-
-Host interface IP address
-
-
-
-
-
-The IP address used by the namespace interface. Must be from the same subnet as host IP
-and uses network_mask to determine subnet.
-Should not collide with any IP addresses already used in your network.
-For example, "240.0.0.6"
-
-Namespace interface IP address
-
-
-
-
-
-The network mask length used to determine subnet of the host
-and the namspace interfaces.
-For example, "30"
-
-Network mask length
-
-
-
-
-
-The metric value of the default route set for the pipe
-link connecting namespace and host. It should be set to
-a large number to be higher then other default route metrics
-that could be set to override this default route.
-If other routes are set eithin the namespace thir metric should
-be smaller then this number if you want them to be used istead of
-this route.
-For example, "1000"
-
-Namespace default route metric
-
-
-
@@ -213,87 +134,12 @@ END
exit $OCF_SUCCESS
}
-check_ns() {
- local ns=`ip netns list | grep "$OCF_RESKEY_ns"`
- [[ $ns != $OCF_RESKEY_ns ]] && return $OCF_ERR_GENERIC
- return $OCF_SUCCESS
-}
-
-get_ns() {
- local rc
- check_ns && return $OCF_SUCCESS
-
- ocf_run ip netns add $OCF_RESKEY_ns
- rc=$?
- ocf_run $RUN_IN_NS ip link set up dev lo
-
- return $rc
-}
-
get_variables() {
- get_ns
-
CONF_FILE="${OCF_RESKEY_conffile}"
COMMAND="$RUN ${OCF_RESKEY_binpath}"
PIDFILE="${OCF_RESKEY_pidfile}"
}
-set_ns_routing() {
- nsip() {
- ip netns exec "${OCF_RESKEY_ns}" ip ${@}
- }
-
- # create host-ns veth pair unless it's present
- ip link | grep -q -w "${OCF_RESKEY_host_interface}:"
- if [ $? -gt 0 ]; then
- ocf_log debug "Creating host interface: ${OCF_RESKEY_host_interface} and namespace interface: ${OCF_RESKEY_namespace_interface}"
- ocf_run ip link add "${OCF_RESKEY_host_interface}" type veth peer name "${OCF_RESKEY_namespace_interface}"
- fi
-
- # move the ns part to the namespace
- ip link | grep -q -w "${OCF_RESKEY_namespace_interface}:"
- if [ $? -eq 0 ]; then
- ocf_log debug "Moving interface: ${OCF_RESKEY_namespace_interface} to namespace: ${OCF_RESKEY_ns}"
- ocf_run ip link set dev "${OCF_RESKEY_namespace_interface}" netns "${OCF_RESKEY_ns}"
- fi
-
- # up the host part
- ocf_log debug "Bringing up host interface: ${OCF_RESKEY_host_interface}"
- ocf_run ip link set "${OCF_RESKEY_host_interface}" up
-
- # set host part's ip
- ip addr show dev "${OCF_RESKEY_host_interface}" | grep -q "inet ${OCF_RESKEY_host_ip}/${OCF_RESKEY_network_mask}"
- if [ $? -gt 0 ]; then
- ocf_log debug "Setting host interface: ${OCF_RESKEY_host_interface} IP to: ${OCF_RESKEY_host_ip}/${OCF_RESKEY_network_mask}"
- ocf_run ip addr add "${OCF_RESKEY_host_ip}/${OCF_RESKEY_network_mask}" dev "${OCF_RESKEY_host_interface}"
- fi
-
- # up the ns part
- ocf_log debug "Bringing up the namespace interface: ${OCF_RESKEY_namespace_interface}"
- ocf_run nsip link set "${OCF_RESKEY_namespace_interface}" up
-
- # set ns part's ip
- nsip addr show dev "${OCF_RESKEY_namespace_interface}" | grep -q "inet ${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}"
- if [ $? -gt 0 ]; then
- ocf_log debug "Setting namespace interface: ${OCF_RESKEY_namespace_interface} IP to: ${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}"
- ocf_run nsip addr add "${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}" dev "${OCF_RESKEY_namespace_interface}"
- fi
-
- # set default gateway inside ns
- nsip route list | grep -q "default via ${OCF_RESKEY_host_ip}"
- if [ $? -gt 0 ]; then
- ocf_log debug "Creating default route inside the namespace to ${OCF_RESKEY_host_ip} with metric ${OCF_RESKEY_route_metric}"
- ocf_run nsip route add default via "${OCF_RESKEY_host_ip}" metric "${OCF_RESKEY_route_metric}"
- fi
-
- # set masquerade on host node
- iptables -t nat -L | grep -q masquerade-for-vrouter-namespace
- if [ $? -gt 0 ]; then
- ocf_log debug "Creating NAT rule on the host system for traffic from IP: ${OCF_RESKEY_namespace_ip}"
- ocf_run iptables -t nat -A POSTROUTING -s "${OCF_RESKEY_namespace_ip}" -j MASQUERADE -m comment --comment "masquerade-for-vrouter-namespace"
- fi
-}
-
ntp_status() {
get_variables
if [ -n "${PIDFILE}" -a -f "${PIDFILE}" ]; then
@@ -332,10 +178,6 @@ ntp_start()
return $OCF_ERR_GENERIC
fi
- if [ "${OCF_RESKEY_ns}" != '' ]; then
- set_ns_routing
- fi
-
# run the ntp binary
ocf_run ${COMMAND} ${OCF_RESKEY_extraconf} -u ntp:ntp -p "${PIDFILE}" -g -c ${CONF_FILE}
if [ $? -ne 0 ]; then
diff --git a/deployment/puppet/cluster/files/ocf/ns_vrouter b/deployment/puppet/cluster/files/ocf/ns_vrouter
new file mode 100644
index 0000000000..a716b1d561
--- /dev/null
+++ b/deployment/puppet/cluster/files/ocf/ns_vrouter
@@ -0,0 +1,348 @@
+#!/bin/bash
+#
+# Resource script for vrouter namespace support
+#
+# Description: Manages vrouter namespace as an OCF resource in
+# an High Availability setup
+#
+# Vrouter OCF script's Author: Mirantis
+# License: GNU General Public License (GPL)
+#
+# usage: $0 {start|stop|restart|status|monitor|validate-all|meta-data}
+#
+# The "start" arg starts vrouter.
+#
+# The "stop" arg stops it.
+#
+# OCF parameters:
+# OCF_RESKEY_ns
+# OCF_RESKEY_other_networks
+#
+# OCF_RESKEY_host_interface
+# OCF_RESKEY_namespace_interface
+# OCF_RESKEY_host_ip
+# OCF_RESKEY_namespace_ip
+# OCF_RESKEY_network_mask
+# OCF_RESKEY_route_metric
+#
+##########################################################################
+# Initialization:
+
+OCF_ROOT_default="/usr/lib/ocf"
+
+OCF_RESKEY_ns_default="vrouter"
+OCF_RESKEY_other_networks_default=false
+OCF_RESKEY_host_interface_default="vrouter-host"
+OCF_RESKEY_namespace_interface_default="vr-ns"
+OCF_RESKEY_host_ip_default="240.0.0.5"
+OCF_RESKEY_namespace_ip_default="240.0.0.6"
+OCF_RESKEY_network_mask_default="30"
+OCF_RESKEY_route_metric_default="10000"
+
+: ${OCF_ROOT=${OCF_ROOT_default}}
+
+: ${OCF_RESKEY_ns=${OCF_RESKEY_ns_default}}
+: ${OCF_RESKEY_other_networks=${OCF_RESKEY_other_networks_default}}
+: ${OCF_RESKEY_host_interface=${OCF_RESKEY_host_interface_default}}
+: ${OCF_RESKEY_namespace_interface=${OCF_RESKEY_namespace_interface_default}}
+: ${OCF_RESKEY_host_ip=${OCF_RESKEY_host_ip_default}}
+: ${OCF_RESKEY_namespace_ip=${OCF_RESKEY_namespace_ip_default}}
+: ${OCF_RESKEY_network_mask=${OCF_RESKEY_network_mask_default}}
+: ${OCF_RESKEY_route_metric=${OCF_RESKEY_route_metric_default}}
+
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
+. ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
+
+USAGE="Usage: $0 {start|stop|restart|status|monitor|validate-all|meta-data}";
+
+RUN_IN_NS="ip netns exec $OCF_RESKEY_ns "
+if [[ -z $OCF_RESKEY_ns ]] ; then
+ RUN=''
+else
+ RUN="$RUN_IN_NS "
+fi
+
+##########################################################################
+
+usage()
+{
+ echo $USAGE >&2
+}
+
+meta_data()
+{
+cat <
+
+
+1.0
+
+This script manages vrouter daemon with namespace support
+
+Manages an vrouter daemon inside an namespace
+
+
+
+
+
+Name of network namespace.
+Should be present.
+
+Name of network namespace.
+
+
+
+
+
+Additional routes that should be added to this resource. Routes will be added via value namespace_interface.
+
+List of addtional routes to add routes for.
+
+
+
+
+
+The host part of the interface pair used to connect the namespace to the network
+For example, "vrouter-host"
+
+The name of the host interface used for namespace
+
+
+
+
+
+The namespace part of the interface pair used to connect the namespace to the network
+For example, "vr-ns"
+
+The name of the namespace interface used for namespace
+
+
+
+
+
+The IP address used by the host interface. Must be from the same subnet as namesapce IP
+and uses network_mask to determine subnet.
+Should not collide with any IP addresses already used in your network.
+For example, "240.0.0.5"
+
+Host interface IP address
+
+
+
+
+
+The IP address used by the namespace interface. Must be from the same subnet as host IP
+and uses network_mask to determine subnet.
+Should not collide with any IP addresses already used in your network.
+For example, "240.0.0.6"
+
+Namespace interface IP address
+
+
+
+
+
+The network mask length used to determine subnet of the host
+and the namspace interfaces.
+For example, "30"
+
+Network mask length
+
+
+
+
+
+The metric value of the default route set for the pipe
+link connecting namespace and host. It should be set to
+a large number to be higher then other default route metrics
+that could be set to override this default route.
+If other routes are set eithin the namespace thir metric should
+be smaller then this number if you want them to be used istead of
+this route.
+For example, "1000"
+
+Namespace default route metric
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+END
+exit $OCF_SUCCESS
+}
+
+check_ns() {
+ local LH="${LL} check_ns():"
+ local ns=`ip netns list | grep "$OCF_RESKEY_ns"`
+ ocf_log debug "${LH} recieved netns list: ${ns}"
+ [[ $ns != $OCF_RESKEY_ns ]] && return $OCF_ERR_GENERIC
+ return $OCF_SUCCESS
+}
+
+get_ns() {
+ local rc
+ local LH="${LL} get_ns():"
+ check_ns && return $OCF_SUCCESS
+
+ ocf_run ip netns add $OCF_RESKEY_ns
+ rc=$?
+ ocf_run $RUN_IN_NS ip link set up dev lo
+ ocf_log debug "${LH} added netns ${OCF_RESKEY_ns} and set up lo"
+
+ return $rc
+}
+
+set_ns_routing() {
+ nsip() {
+ ip netns exec "${OCF_RESKEY_ns}" ip ${@}
+ }
+
+ # create host-ns veth pair unless it's present
+ ip link | grep -q "${OCF_RESKEY_host_interface}:"
+ if [ $? -gt 0 ]; then
+ ocf_log debug "Creating host interface: ${OCF_RESKEY_host_interface} and namespace interface: ${OCF_RESKEY_namespace_interface}"
+ ocf_run ip link add "${OCF_RESKEY_host_interface}" type veth peer name "${OCF_RESKEY_namespace_interface}"
+ else
+ return $OCF_SUCCESS
+ fi
+
+ # move the ns part to the namespace
+ ip link | grep -q "${OCF_RESKEY_namespace_interface}:"
+ if [ $? -eq 0 ]; then
+ ocf_log debug "Moving interface: ${OCF_RESKEY_namespace_interface} to namespace: ${OCF_RESKEY_ns}"
+ ocf_run ip link set dev "${OCF_RESKEY_namespace_interface}" netns "${OCF_RESKEY_ns}"
+ fi
+
+ # up the host part
+ ocf_log debug "Bringing up host interface: ${OCF_RESKEY_host_interface}"
+ ocf_run ip link set "${OCF_RESKEY_host_interface}" up
+
+ # set host part's ip
+ ip addr show dev "${OCF_RESKEY_host_interface}" | grep -q "inet ${OCF_RESKEY_host_ip}/${OCF_RESKEY_network_mask}"
+ if [ $? -gt 0 ]; then
+ ocf_log debug "Setting host interface: ${OCF_RESKEY_host_interface} IP to: ${OCF_RESKEY_host_ip}/${OCF_RESKEY_network_mask}"
+ ocf_run ip addr add "${OCF_RESKEY_host_ip}/${OCF_RESKEY_network_mask}" dev "${OCF_RESKEY_host_interface}"
+ fi
+
+ # up the ns part
+ ocf_log debug "Bringing up the namespace interface: ${OCF_RESKEY_namespace_interface}"
+ ocf_run nsip link set "${OCF_RESKEY_namespace_interface}" up
+
+ # set ns part's ip
+ nsip addr show dev "${OCF_RESKEY_namespace_interface}" | grep -q "inet ${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}"
+ if [ $? -gt 0 ]; then
+ ocf_log debug "Setting namespace interface: ${OCF_RESKEY_namespace_interface} IP to: ${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}"
+ ocf_run nsip addr add "${OCF_RESKEY_namespace_ip}/${OCF_RESKEY_network_mask}" dev "${OCF_RESKEY_namespace_interface}"
+ fi
+
+ # set default gateway inside ns
+ nsip route list | grep -q "default via ${OCF_RESKEY_host_ip}"
+ if [ $? -gt 0 ]; then
+ ocf_log debug "Creating default route inside the namespace to ${OCF_RESKEY_host_ip} with metric ${OCF_RESKEY_route_metric}"
+ ocf_run nsip route add default via "${OCF_RESKEY_host_ip}" metric "${OCF_RESKEY_route_metric}"
+ fi
+
+ # set masquerade on host node
+ iptables -t nat -L | grep -q masquerade-for-vrouter-namespace
+ if [ $? -gt 0 ]; then
+ ocf_log debug "Creating NAT rule on the host system for traffic from IP: ${OCF_RESKEY_namespace_ip}"
+ ocf_run iptables -t nat -A POSTROUTING -s "${OCF_RESKEY_namespace_ip}" -j MASQUERADE -m comment --comment "masquerade-for-vrouter-namespace"
+ fi
+
+ ### Needed for ML2 routing ###
+ ocf_run sysctl -w net.ipv4.conf.${OCF_RESKEY_host_interface}.rp_filter=2
+ ocf_run $RUN_IN_NS sysctl -w net.ipv4.conf.all.rp_filter=2
+ ##############################
+
+ if [[ "${OCF_RESKEY_other_networks}" != "false" ]] ; then
+ for network in ${OCF_RESKEY_other_networks}
+ do
+ ocf_log debug "Adding route on the host system to ${network}: ${OCF_RESKEY_namespace_ip}"
+ ocf_run $RUN_IN_NS ip route replace ${network} via ${OCF_RESKEY_host_ip} metric 10000
+ done
+ fi
+}
+
+vrouter_status() {
+ get_ns || return $OCF_NOT_RUNNING
+ set_ns_routing
+}
+
+vrouter_start()
+{
+ get_ns
+ set_ns_routing
+ return $OCF_SUCCESS
+}
+
+vrouter_stop()
+{
+ ocf_log debug "Vrouter was stopped, namespaces still exist"
+ return $OCF_SUCCESS
+}
+
+vrouter_monitor()
+{
+ vrouter_status
+}
+
+vrouter_validate_all()
+{
+ get_ns
+ return $OCF_SUCCESS
+}
+
+vrouter_restart()
+{
+ vrouter_stop
+ vrouter_start
+}
+
+#
+# Main
+#
+
+if [ $# -ne 1 ]; then
+ usage
+ exit $OCF_ERR_ARGS
+fi
+umask 0022
+export LL="${OCF_RESOURCE_INSTANCE}:"
+
+case $1 in
+ start) vrouter_start
+ ;;
+
+ stop) vrouter_stop
+ ;;
+
+ restart) vrouter_restart
+ ;;
+
+ status) vrouter_status
+ ;;
+
+ monitor) vrouter_monitor
+ ;;
+
+ validate-all) vrouter_validate_all
+ ;;
+
+ meta-data) meta_data
+ ;;
+
+ usage) usage; exit $OCF_SUCCESS
+ ;;
+
+ *) usage; exit $OCF_ERR_UNIMPLEMENTED
+ ;;
+esac
diff --git a/deployment/puppet/cluster/manifests/dns_ocf.pp b/deployment/puppet/cluster/manifests/dns_ocf.pp
index e02f03ea28..6d85b46c8c 100644
--- a/deployment/puppet/cluster/manifests/dns_ocf.pp
+++ b/deployment/puppet/cluster/manifests/dns_ocf.pp
@@ -34,8 +34,18 @@ class cluster::dns_ocf ( $primary_controller ) {
'timeout' => '30'
},
},
+ } ->
+
+ cs_rsc_colocation { 'dns-with-vrouter-ns':
+ ensure => present,
+ score => 'INFINITY',
+ primitives => [
+ "clone_${service_name}",
+ "clone_p_vrouter"
+ ],
}
- Cs_resource[$service_name] ~> Service[$service_name]
+
+ Cs_resource[$service_name] ~> Service[$service_name]
}
file {'dns-ocf':
diff --git a/deployment/puppet/cluster/manifests/ntp_ocf.pp b/deployment/puppet/cluster/manifests/ntp_ocf.pp
index 736a413bf9..beec737190 100644
--- a/deployment/puppet/cluster/manifests/ntp_ocf.pp
+++ b/deployment/puppet/cluster/manifests/ntp_ocf.pp
@@ -33,6 +33,15 @@ class cluster::ntp_ocf ( ) {
'timeout' => '30'
},
},
+ } ->
+
+ cs_rsc_colocation { 'ntp-with-vrouter-ns':
+ ensure => present,
+ score => 'INFINITY',
+ primitives => [
+ "clone_${service_name}",
+ "clone_p_vrouter"
+ ],
}
Cs_resource[$service_name] ~> Service[$service_name]
diff --git a/deployment/puppet/cluster/manifests/vrouter_ocf.pp b/deployment/puppet/cluster/manifests/vrouter_ocf.pp
new file mode 100644
index 0000000000..49c94ad897
--- /dev/null
+++ b/deployment/puppet/cluster/manifests/vrouter_ocf.pp
@@ -0,0 +1,64 @@
+# == Class: cluster::vrouter_ocf
+#
+# Configure OCF service for vrouter managed by corosync/pacemaker
+#
+class cluster::vrouter_ocf (
+ $primary_controller,
+ $other_networks = false,
+){
+ $service_name = 'p_vrouter'
+
+ file {'/usr/lib/ocf/resource.d/fuel/ns_vrouter':
+ mode => '0755',
+ owner => root,
+ group => root,
+ source => 'puppet:///modules/cluster/ocf/ns_vrouter',
+ }
+
+ if $primary_controller {
+ cs_resource { $service_name:
+ ensure => present,
+ primitive_class => 'ocf',
+ provided_by => 'fuel',
+ primitive_type => 'ns_vrouter',
+ complex_type => 'clone',
+ ms_metadata => {
+ 'interleave' => true,
+ },
+ metadata => {
+ 'migration-threshold' => '3',
+ 'failure-timeout' => '120',
+ },
+ parameters => {
+ 'ns' => 'vrouter',
+ 'other_networks' => "'$other_networks'",
+ },
+ operations => {
+ 'monitor' => {
+ 'interval' => '30',
+ 'timeout' => '60'
+ },
+ 'start' => {
+ 'timeout' => '30'
+ },
+ 'stop' => {
+ 'timeout' => '60'
+ },
+ },
+ }
+
+ File['/usr/lib/ocf/resource.d/fuel/ns_vrouter'] -> Cs_resource[$service_name]
+ Cs_resource[$service_name] -> Service[$service_name]
+ }
+
+ File['/usr/lib/ocf/resource.d/fuel/ns_vrouter'] ~> Service[$service_name]
+
+ service { $service_name:
+ ensure => 'running',
+ name => $service_name,
+ enable => true,
+ hasstatus => true,
+ hasrestart => true,
+ provider => 'pacemaker',
+ }
+}
diff --git a/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/direct_networks.rb b/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/direct_networks.rb
index 0035be835d..bdd6ac5ef3 100644
--- a/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/direct_networks.rb
+++ b/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/direct_networks.rb
@@ -1,9 +1,8 @@
Puppet::Parser::Functions::newfunction(:direct_networks, :type => :rvalue, :doc => <<-EOS
- parses network scheme and returns networks
- directly attached to the host
- EOS
- ) do |argv|
-
+parses network scheme and returns networks
+directly attached to the host
+EOS
+) do |argv|
endpoints = argv[0]
networks = []
@@ -13,6 +12,11 @@ Puppet::Parser::Functions::newfunction(:direct_networks, :type => :rvalue, :doc
networks << IPAddr.new(ip).to_s + "/" + ip.split('/')[1]
}
end
+ if v.has_key?('routes') and v['routes'].is_a?(Array)
+ v['routes'].each { |route|
+ networks << route['net']
+ }
+ end
}
return networks.join(' ')
end
diff --git a/deployment/puppet/osnailyfacter/modular/cluster-vrouter/cluster-vrouter.pp b/deployment/puppet/osnailyfacter/modular/cluster-vrouter/cluster-vrouter.pp
new file mode 100644
index 0000000000..6c8802b512
--- /dev/null
+++ b/deployment/puppet/osnailyfacter/modular/cluster-vrouter/cluster-vrouter.pp
@@ -0,0 +1,8 @@
+notice('MODULAR: cluster-vrouter.pp')
+
+$network_scheme = hiera('network_scheme', {})
+
+class { 'cluster::vrouter_ocf':
+ primary_controller => hiera('primary_controller'),
+ other_networks => direct_networks($network_scheme['endpoints']),
+}
diff --git a/deployment/puppet/osnailyfacter/modular/cluster-vrouter/tasks.yaml b/deployment/puppet/osnailyfacter/modular/cluster-vrouter/tasks.yaml
new file mode 100644
index 0000000000..9353ee7f0f
--- /dev/null
+++ b/deployment/puppet/osnailyfacter/modular/cluster-vrouter/tasks.yaml
@@ -0,0 +1,9 @@
+- id: cluster-vrouter
+ type: puppet
+ groups: [primary-controller, controller]
+ required_for: [virtual_ips]
+ requires: [cluster]
+ parameters:
+ puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/cluster-vrouter/cluster-vrouter.pp
+ puppet_modules: /etc/puppet/modules
+ timeout: 3600
diff --git a/tests/noop/spec/hosts/cluster-haproxy/cluster-haproxy_spec.rb b/tests/noop/spec/hosts/cluster-haproxy/cluster-haproxy_spec.rb
index 6c2919b4dc..b392a836da 100644
--- a/tests/noop/spec/hosts/cluster-haproxy/cluster-haproxy_spec.rb
+++ b/tests/noop/spec/hosts/cluster-haproxy/cluster-haproxy_spec.rb
@@ -13,6 +13,11 @@ describe manifest do
networks << IPAddr.new(ip).to_s + '/' + ip.split('/')[1]
}
end
+ if v.has_key?('routes') and v['routes'].is_a?(Array)
+ v['routes'].each { |route|
+ networks << route['net']
+ }
+ end
}
it "should delcare cluster::haproxy with other_networks set to #{networks.join(' ')}" do
diff --git a/tests/noop/spec/hosts/cluster-vrouter/cluster-vrouter_spec.rb b/tests/noop/spec/hosts/cluster-vrouter/cluster-vrouter_spec.rb
new file mode 100644
index 0000000000..e4cf76dab8
--- /dev/null
+++ b/tests/noop/spec/hosts/cluster-vrouter/cluster-vrouter_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper'
+require 'shared-examples'
+manifest = 'cluster-vrouter/cluster-vrouter.pp'
+
+describe manifest do
+ shared_examples 'puppet catalogue' do
+ settings = Noop.fuel_settings
+ networks = []
+ settings['network_scheme']['endpoints'].each{ |k,v|
+ if v['IP'].is_a?(Array)
+ v['IP'].each { |ip|
+ networks << IPAddr.new(ip).to_s + "/" + ip.split('/')[1]
+ }
+ end
+ if v.has_key?('routes') and v['routes'].is_a?(Array)
+ v['routes'].each { |route|
+ networks << route['net']
+ }
+ end
+ }
+
+ it "should delcare cluster::vrouter_ocf with other_networks set to #{networks.join(' ')}" do
+ should contain_class('cluster::vrouter_ocf').with(
+ 'other_networks' => networks.join(' '),
+ )
+ end
+
+ end
+
+ test_ubuntu_and_centos manifest
+end
+