Add physnets and type_driver settings 85/53985/9
authorFeng Pan <fpan@redhat.com>
Fri, 16 Mar 2018 12:16:49 +0000 (08:16 -0400)
committerFeng Pan <fpan@redhat.com>
Mon, 2 Apr 2018 01:49:40 +0000 (21:49 -0400)
Change-Id: I472879b8f67e64b571638a0385943597a9120e6c
Signed-off-by: Feng Pan <fpan@redhat.com>
lib/puppet/parser/functions/vpp_physnet_mapping.rb [new file with mode: 0644]
manifests/profile/base/neutron/agents/vpp.pp
manifests/profile/base/neutron/plugins/ml2/vpp.pp

diff --git a/lib/puppet/parser/functions/vpp_physnet_mapping.rb b/lib/puppet/parser/functions/vpp_physnet_mapping.rb
new file mode 100644 (file)
index 0000000..1c86a23
--- /dev/null
@@ -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
index 6c55b86..0b06b57 100644 (file)
 #   (Optional) etcd server listening port.
 #   Defaults to 2379
 #
+# [*physnet_mapping*]
+#   (Optional) physnet mapping, example: 'datacentre:eth1'. Note that the
+#   interface specified here is a kernel interface name that is bound to
+#   VPP.
+#   Defaults to []
+#
+# [*type_drivers*]
+#   (optional) List of network type driver entrypoints to be loaded
+#   Could be an array that can contain flat, vlan or vxlan
+#   Defaults to hiera('neutron::plugins::ml2::type_drivers', undef)
+#
 class tripleo::profile::base::neutron::agents::vpp(
-  $step      = Integer(hiera('step')),
-  $etcd_host = hiera('etcd_vip'),
-  $etcd_port = 2379,
+  $step            = Integer(hiera('step')),
+  $etcd_host       = hiera('etcd_vip'),
+  $etcd_port       = 2379,
+  $physnet_mapping = [],
+  $type_drivers    = hiera('neutron::plugins::ml2::type_drivers', undef),
 ) {
   if empty($etcd_host) {
     fail('etcd_vip not set in hieradata')
   }
 
   if $step >= 4 {
+    if $::hostname in hiera('controller_node_names') {
+      $service_plugins = hiera('neutron::service_plugins')
+    } else {
+      $service_plugins = undef
+    }
     class { '::neutron::agents::ml2::vpp':
-      etcd_host => $etcd_host,
-      etcd_port => $etcd_port,
+      etcd_host       => $etcd_host,
+      etcd_port       => $etcd_port,
+      physnets        => vpp_physnet_mapping($physnet_mapping),
+      type_drivers    => $type_drivers,
+      service_plugins => $service_plugins,
     }
   }
 }
index 7d59239..0312eff 100644 (file)
@@ -41,9 +41,15 @@ class tripleo::profile::base::neutron::plugins::ml2::vpp (
   }
 
   if $step >= 4 {
+    if $::hostname in hiera('controller_node_names') {
+      $l3_hosts = strip(hiera('controller_node_names').split(',')[0])
+    } else {
+      $l3_hosts = undef
+    }
     class { '::neutron::plugins::ml2::vpp':
       etcd_host => $etcd_host,
       etcd_port => $etcd_port,
+      l3_hosts  => $l3_hosts,
     }
   }
 }