diff options
author | 2017-08-02 20:49:02 +0000 | |
---|---|---|
committer | 2017-08-02 20:49:02 +0000 | |
commit | 44f4b03869f7be1a7cc41222a7d99810f64457d9 (patch) | |
tree | cce54767ddf17bffd8aee07ad2897229b323c64f /lib/puppet | |
parent | 6ff2ccc2f3e3bf8c8b34a4be108e91f8d41a2442 (diff) | |
parent | 8e0fd5033c0897a11abb5d9948b5ad77bdccacfa (diff) |
Merge "nosdn-fdio scenario fixes"
Diffstat (limited to 'lib/puppet')
-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 |