From 8b9e2b3c6ca5221249b8aa7dc792e756ee92209a Mon Sep 17 00:00:00 2001 From: Michael Henkel Date: Fri, 16 Jun 2017 10:49:57 -0700 Subject: Contrail: Fix controlplane/dataplane network asignments & enable optional dpdk This patch will move the Contrail roles communication towards OpenStack APIs from the public/external network to the internal_api network. I will also add the option to enable dpdk for Contrail. Change-Id: Ia835df656031cdf28de20f41ec6ab1c028dced23 Closes-Bug: 1698422 --- lib/puppet/parser/functions/netmask_to_cidr.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/puppet/parser/functions/netmask_to_cidr.rb (limited to 'lib') diff --git a/lib/puppet/parser/functions/netmask_to_cidr.rb b/lib/puppet/parser/functions/netmask_to_cidr.rb new file mode 100644 index 0000000..68ee4cf --- /dev/null +++ b/lib/puppet/parser/functions/netmask_to_cidr.rb @@ -0,0 +1,14 @@ +# Custom function to transform netmask from IP notation to +# CIDR format. Input is an IP address, output a CIDR: +# 255.255.255.0 = 24 +# The CIDR formated netmask is needed for some +# Contrail configuration files +require 'ipaddr' +module Puppet::Parser::Functions + newfunction(:netmask_to_cidr, :type => :rvalue) do |args| + if args[0].class != String + raise Puppet::ParseError, "Syntax error: #{args[0]} must be a String" + end + IPAddr.new(args[0]).to_i.to_s(2).count("1") + end +end -- cgit 1.2.3-korg