Merge branch 'feature-4888' into one-5.2

This commit is contained in:
Javi Fontan committed 2016-11-04 11:30:21 +01:00
commit bba8ca4252
4 files changed
+55

No files matched your search

@@ -51,4 +51,17 @@ class VLANTagDriver < VNMMAD::VLANDriver
OpenNebula.exec_and_log("#{command(:ip)} link set #{@nic[:vlan_dev]} up")
end
def get_interface_vlan(name)
text = %x(#{command(:ip)} -d link show #{name})
return nil if $?.exitstatus != 0
text.each_line do |line|
m = line.match(/vlan protocol 802.1Q id (\d+)/)
return m[1] if m
end
nil
end
end
@@ -14,6 +14,10 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Set to true to check that no other vlans are connected to the bridge.
# Works with 802.1Q and VXLAN.
:validate_vlan_id: false
################################################################################
# Open vSwitch Options
################################################################################
+25
View File
@@ -46,6 +46,9 @@ module VNMMAD
# Create the bridge.
create_bridge
# Check that no other vlans are connected to this bridge
validate_vlan_id
# Return if vlan device is already in the bridge.
next if @bridges[@nic[:bridge]].include? @nic[:vlan_dev]
@@ -149,5 +152,27 @@ module VNMMAD
bridges
end
def get_interface_vlan(name)
nil
end
def validate_vlan_id
@bridges[@nic[:bridge]].each do |interface|
vlan = get_interface_vlan(interface)
if vlan && vlan.to_s != @nic[:vlan_id]
OpenNebula.log_error("The interface #{interface} has "\
"vlan_id = #{vlan} but the network is configured "\
"with vlan_id = #{@nic[:vlan_id]}")
msg = "Interface with an incorrect vlan_id is already in "\
"the bridge"
OpenNebula.error_message(msg)
exit(-1)
end
end
end
end
end
+13
View File
@@ -54,4 +54,17 @@ class VXLANDriver < VNMMAD::VLANDriver
OpenNebula.exec_and_log("#{command(:ip)} link set #{@nic[:vlan_dev]} up")
end
def get_interface_vlan(name)
text = %x(#{command(:ip)} -d link show #{name})
return nil if $?.exitstatus != 0
text.each_line do |line|
m = line.match(/^\s*vxlan id (\d+)/)
return m[1] if m
end
nil
end
end