nosdn-fdio scenario fixes 73/38473/2
authorFeng Pan <fpan@redhat.com>
Mon, 31 Jul 2017 19:05:28 +0000 (15:05 -0400)
committerFeng Pan <fpan@redhat.com>
Tue, 1 Aug 2017 00:55:17 +0000 (20:55 -0400)
- Add vpp_physnet_mappings function
- Change etcd deployment model

Change-Id: Ie336c22b366bd478963ca14e25d645fec0cded7a
Signed-off-by: Feng Pan <fpan@redhat.com>
lib/puppet/parser/functions/vpp_physnet_mapping.rb [new file with mode: 0644]
manifests/profile/base/etcd.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 505e29f..c29c937 100644 (file)
@@ -46,20 +46,13 @@ class tripleo::profile::base::etcd (
   $nodes       = hiera('etcd_node_names', []),
   $step        = hiera('step'),
 ) {
-  if $step >= 1 {
-    if count($nodes) > 1 {
-      $cluster_enabled = true
-    } else {
-      $cluster_enabled = false
-    }
-
+  if $step >= 2 {
     class {'::etcd':
       listen_client_urls          => "http://${bind_ip}:${client_port}",
       advertise_client_urls       => "http://${bind_ip}:${client_port}",
       listen_peer_urls            => "http://${bind_ip}:${peer_port}",
       initial_advertise_peer_urls => "http://${bind_ip}:${peer_port}",
       initial_cluster             => regsubst($nodes, '.+', "\\0=http://\\0:${peer_port}"),
-      cluster_enabled             => $cluster_enabled,
       proxy                       => 'off',
     }
   }