Merge "add multiple uplinks support"

This commit is contained in:
Jenkins 2016-09-15 11:33:08 +00:00 committed by Gerrit Code Review
commit 59cf082060
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] == ""
vcenter = args[0]['computes']
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"]
current_node = args[3].split(".")[0]
controllersp = args[4].any? {|role| role.include?("controller")}
@ -23,12 +23,21 @@
agent["vsphere_insecure"] = vc["vc_insecure"]
agent["vsphere_ca_file"] = vc["vc_ca_file"]
cluster = vc["vc_cluster"]
if netmaps.include? ':'
vds = netmaps.split(";").collect{|k| k.split(":")}.select{|x| x[0] == cluster}.collect{|x| x[1]}[0]
netmaps = netmaps.keep_if {|s| s =~ /^#{cluster}/}.first.split(":")
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
vds = netmaps
raise 'Wrong vmware_dvs_net_maps'
end
agent["network_maps"] = physnet + ":" + vds
agent["uplink_maps"] = physnet + ":" + uplinks if uplinks
agent["use_fw_driver"] = use_fw_driver
agent["ha_enabled"] = controllersp
agent["primary"] = primaryp

View File

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

View File

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

View File

@ -15,9 +15,9 @@ attributes:
vmware_dvs_net_maps:
value: ""
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
type: "text"
type: "textarea"
regex:
source: &non_empty_string '\S'
error: "Empty name of dvSwitch"