add multiple uplinks support

The network and uplink mapping now should be set in the new format:
a) Multiple strings each for one cluster in a textarea item;
b) Uplinks-mapping is optional
c) possible data is:
   1. Cluster:VDS
   2. Cluster:VDS:TU1;TU2;TU3
   3. Cluster:VDS:TU1;TU2:FU3;FU4
where TU -- teaming uplink,
      FU -- fallback uplink,
      there is no limitation for amount of uplinks,
      uplinks shoud be splitted by ';'

Change-Id: Ibf40675bb048a15a70157598931fae211da04edb
This commit is contained in:
Igor Gajsin 2016-09-14 14:37:22 +03:00
parent 364894a955
commit bd01b39922
4 changed files with 24 additions and 7 deletions

View File

@ -7,7 +7,7 @@
raise(Puppet::ParseError, 'Shoud have 5 arguments!') if args.size < 4 or args[0] == "" raise(Puppet::ParseError, 'Shoud have 5 arguments!') if args.size < 4 or args[0] == ""
vcenter = args[0]['computes'] vcenter = args[0]['computes']
physnet = args[1]["predefined_networks"]["admin_internal_net"]["L2"]["physnet"] physnet = args[1]["predefined_networks"]["admin_internal_net"]["L2"]["physnet"]
netmaps = args[2]["vmware_dvs_net_maps"].delete(' ') netmaps = args[2]["vmware_dvs_net_maps"].delete(' ').split("\n")
use_fw_driver = args[2]["vmware_dvs_fw_driver"] use_fw_driver = args[2]["vmware_dvs_fw_driver"]
current_node = args[3].split(".")[0] current_node = args[3].split(".")[0]
controllersp = args[4].any? {|role| role.include?("controller")} controllersp = args[4].any? {|role| role.include?("controller")}
@ -23,12 +23,21 @@
agent["vsphere_insecure"] = vc["vc_insecure"] agent["vsphere_insecure"] = vc["vc_insecure"]
agent["vsphere_ca_file"] = vc["vc_ca_file"] agent["vsphere_ca_file"] = vc["vc_ca_file"]
cluster = vc["vc_cluster"] cluster = vc["vc_cluster"]
if netmaps.include? ':' netmaps = netmaps.keep_if {|s| s =~ /^#{cluster}/}.first.split(":")
vds = netmaps.split(";").collect{|k| k.split(":")}.select{|x| x[0] == cluster}.collect{|x| x[1]}[0] if netmaps.length == 4
vds = netmaps[1]
uplinks = netmaps[2] + ":" + netmaps[3]
elsif netmaps.length == 3
vds = netmaps[1]
uplinks = netmaps[2]
elsif netmaps.length == 2
vds = netmaps[1]
uplinks = false
else else
vds = netmaps raise 'Wrong vmware_dvs_net_maps'
end end
agent["network_maps"] = physnet + ":" + vds agent["network_maps"] = physnet + ":" + vds
agent["uplink_maps"] = physnet + ":" + uplinks if uplinks
agent["use_fw_driver"] = use_fw_driver agent["use_fw_driver"] = use_fw_driver
agent["ha_enabled"] = controllersp agent["ha_enabled"] = controllersp
agent["primary"] = primaryp agent["primary"] = primaryp

View File

@ -45,6 +45,10 @@
# (required) String. This is a name of DVS. # (required) String. This is a name of DVS.
# Defaults to 'physnet1:dvSwitch1'. # Defaults to 'physnet1:dvSwitch1'.
# #
# [*uplink_maps*]
# (required) String. This is a string that explains uplinks usage policy.
# Defaults to undef.
#
# [*use_fw_driver*] # [*use_fw_driver*]
# (optional) Boolean. Use firewall driver or mock. # (optional) Boolean. Use firewall driver or mock.
# Defaults to true. # Defaults to true.
@ -69,6 +73,7 @@ define vmware_dvs::agent(
$vsphere_insecure = true, $vsphere_insecure = true,
$vsphere_ca_file = undef, $vsphere_ca_file = undef,
$network_maps = 'physnet1:dvSwitch1', $network_maps = 'physnet1:dvSwitch1',
$uplink_maps = undef,
$use_fw_driver = true, $use_fw_driver = true,
$py_root = '/usr/lib/python2.7/dist-packages', $py_root = '/usr/lib/python2.7/dist-packages',
$ha_enabled = true, $ha_enabled = true,

View File

@ -7,9 +7,12 @@ firewall_driver=<%= @fw_driver %>
[ml2_vmware] [ml2_vmware]
vsphere_login=<%= @vsphere_login %> vsphere_login=<%= @vsphere_login %>
network_maps=<%= @network_maps %>
vsphere_hostname=<%= @vsphere_hostname %> vsphere_hostname=<%= @vsphere_hostname %>
vsphere_password=<%= @vsphere_password %> vsphere_password=<%= @vsphere_password %>
network_maps=<%= @network_maps %>
<% if @uplink_maps -%>
uplink_maps=<%= @uplink_maps%>
<% end -%>
insecure=<%= @agent_vcenter_insecure_real %> insecure=<%= @agent_vcenter_insecure_real %>
<% if @agent_vcenter_ca_filepath and @agent_vcenter_ca_filepath \ <% if @agent_vcenter_ca_filepath and @agent_vcenter_ca_filepath \
!= "<SERVICE DEFAULT>" and !@agent_vcenter_ca_filepath.empty? -%> != "<SERVICE DEFAULT>" and !@agent_vcenter_ca_filepath.empty? -%>

View File

@ -15,9 +15,9 @@ attributes:
vmware_dvs_net_maps: vmware_dvs_net_maps:
value: "" value: ""
label: "Enter the Cluster to dvSwitch mapping." label: "Enter the Cluster to dvSwitch mapping."
description: "List of ClusterName:dvSwitchName pairs, separated by semicolon." description: "List of strings with format ClusterName:dvSwitchName:TeamingUplink1;TeamingUplink2:FallbackUplink1;FallbackUplink2."
weight: 25 weight: 25
type: "text" type: "textarea"
regex: regex:
source: &non_empty_string '\S' source: &non_empty_string '\S'
error: "Empty name of dvSwitch" error: "Empty name of dvSwitch"