mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-08 21:17:43 +03:00
Merge branch 'feature-4888'
This commit is contained in:
commit
72603252f5
@ -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
|
||||
################################################################################
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user