Browse Source

Fix the bug that prevent assign 2 Cluster to one controller

In some cases Ruby uses pointer instead of copying something for
optimization. But it allows to side effects. It was cause of that bug.
After cloning one variable by var.dup the problem was fixed.

Change-Id: Ide58c184f4cb9b655e11a13afb8c05bfc5149ab9
Closes-bug: #1625092
changes/53/373253/1
Igor Gajsin 2 years ago
parent
commit
b19b88653d

+ 9
- 12
deployment_scripts/puppet/modules/vmware_dvs/lib/puppet/parser/functions/get_agents_data.rb View File

@@ -13,9 +13,11 @@
13 13
     controllersp = args[4].any? {|role| role.include?("controller")}
14 14
     primaryp = args[4].any? {|role| role.include?("primary")}
15 15
     agents = []
16
+
16 17
     vcenter.each {|vc|
17 18
       if (vc["target_node"] == "controllers" and controllersp) or current_node == vc["target_node"]
18 19
         agent = {}
20
+        ns = netmaps.dup
19 21
         agent["host"] = vc["availability_zone_name"] + "-" + vc["service_name"]
20 22
         agent["vsphere_hostname"] = vc["vc_host"]
21 23
         agent["vsphere_login"] = vc["vc_user"]
@@ -23,18 +25,13 @@
23 25
         agent["vsphere_insecure"] = vc["vc_insecure"]
24 26
         agent["vsphere_ca_file"] = vc["vc_ca_file"]
25 27
         cluster = vc["vc_cluster"]
26
-        netmaps = netmaps.keep_if {|s| s =~ /^#{cluster}/}.first.split(":")
27
-        if netmaps.length == 4
28
-          vds = netmaps[1]
29
-          uplinks = netmaps[2] + ":" + netmaps[3]
30
-        elsif netmaps.length == 3
31
-          vds = netmaps[1]
32
-          uplinks = netmaps[2]
33
-        elsif netmaps.length == 2
34
-          vds = netmaps[1]
35
-          uplinks = false
36
-        else
37
-          raise 'Wrong vmware_dvs_net_maps'
28
+        ns = ns.keep_if {|s| s =~ /^#{cluster}/}.first.split(":")
29
+        vds = ns[1]
30
+        uplinks = false
31
+        if ns.length == 4
32
+          uplinks = ns[2] + ":" + ns[3]
33
+        elsif ns.length == 3
34
+          uplinks = ns[2]
38 35
         end
39 36
         agent["network_maps"] = physnet + ":" + vds
40 37
         agent["uplink_maps"] =  physnet + ":" + uplinks if uplinks

Loading…
Cancel
Save