diff options
author | Feng Pan <fpan@redhat.com> | 2018-03-16 08:16:49 -0400 |
---|---|---|
committer | Tim Rozet <trozet@redhat.com> | 2018-04-12 14:08:38 +0000 |
commit | ab64db9c0d80dbda5ff286722308a7b125628b7f (patch) | |
tree | 8bd7d9009f0f08b62e43331d926c22c4237b5fa7 /lib/puppet/parser/functions | |
parent | d98f6b68e5e25d24f4ceb747c421f7a9d4889a56 (diff) |
Add physnets and type_driver settings
Change-Id: I472879b8f67e64b571638a0385943597a9120e6c
Signed-off-by: Feng Pan <fpan@redhat.com>
(cherry picked from commit f409f083d2c63e7ec2f484a77b2229613252de5e)
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r-- | lib/puppet/parser/functions/vpp_physnet_mapping.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/vpp_physnet_mapping.rb b/lib/puppet/parser/functions/vpp_physnet_mapping.rb new file mode 100644 index 0000000..1c86a23 --- /dev/null +++ b/lib/puppet/parser/functions/vpp_physnet_mapping.rb @@ -0,0 +1,21 @@ +module Puppet::Parser::Functions + newfunction(:vpp_physnet_mapping, :type => :rvalue, :doc => "Convert VPP ML2 physnet mapping from kernel nic name (eth1) to VPP name (GigabitEthernet0/7/0).") do |arg| + mapping_list = arg[0] + mapping_list.map! do |item| + mapping = item.split(':') + unless mapping.length == 2 + raise Puppet::ParseError, "Invalid physnet mapping format: #{item}. Expecting 'physnet:interface_name'" + end + if defined? call_function + vpp_int = call_function('hiera', [mapping[1]]) + else + vpp_int = function_hiera([mapping[1]]) + end + if vpp_int.to_s.strip.empty? + raise Puppet::ParseError, "VPP interface mapped to #{mapping[1]} is not found." + end + mapping[0]+':'+vpp_int + end + return mapping_list.join(',') + end +end |