Bug #3632: Avoid failure if vlan not present in Distributed vSwitch

This commit is contained in:
Tino Vazquez committed 2015-02-24 17:18:10 +01:00
1 parent a00e2947ef
commit 11e4b4a12e
1 file changed
+22 -10
+22 -10
View File
@@ -376,17 +376,29 @@ class VIClient
"BRIDGE = \"#{n[:name]}\"\n" \
"VCENTER_TYPE = \"Distributed Port Group\""
vlan = n.config.defaultPortConfig.vlan.vlanId
vlan_str = ""
if vlan != 0
if vlan.is_a? Array
vlan.each{|v|
vlan_str += v.start.to_s + ".." + v.end.to_s + ","
}
vlan_str.chop!
else
vlan_str = vlan.to_s
default_pc = n.config.defaultPortConfig
has_vlan = false
if default_pc.methods.include? :vlan
has_vlan = default_pc.vlan.methods.include? :vlanId
end
if has_vlan
vlan = n.config.defaultPortConfig.vlan.vlanId
vlan_str = ""
if vlan != 0
if vlan.is_a? Array
vlan.each{|v|
vlan_str += v.start.to_s + ".." +
v.end.to_s + ","
}
vlan_str.chop!
else
vlan_str = vlan.to_s
end
end
end