1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00

Merge branch 'feature-4888'

This commit is contained in:
Javi Fontan 2016-11-04 11:31:30 +01:00
commit 72603252f5
4 changed files with 55 additions and 0 deletions

View File

@ -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

View File

@ -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
################################################################################

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

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