@@ -24,11 +24,11 @@ module VXLAN
2424 # This function creates and activate a VLAN device
2525 ############################################################################
2626 def create_vlan_dev
27- vxlan_mode = @nic [ :conf ] [ : vxlan_mode] || 'multicast'
27+ vxlan_mode = conf_attribute ( @nic , : vxlan_mode, 'multicast' )
2828 group = ""
2929
3030 if vxlan_mode . downcase == 'evpn'
31- vxlan_tep = @nic [ :conf ] [ : vxlan_tep] || 'dev'
31+ vxlan_tep = conf_attribute ( @nic , : vxlan_tep, 'dev' )
3232
3333 if vxlan_tep . downcase == 'dev'
3434 tep = "dev #{ @nic [ :phydev ] } "
@@ -37,9 +37,9 @@ def create_vlan_dev
3737 end
3838 else
3939 begin
40- ipaddr = IPAddr . new @nic [ :conf ] [ : vxlan_mc]
40+ ipaddr = IPAddr . new conf_attribute ( @nic , : vxlan_mc, '239.0.0.0' )
4141 rescue
42- ipaddr = IPAddr . new " 239.0.0.0"
42+ ipaddr = IPAddr . new ' 239.0.0.0'
4343 end
4444
4545 mc = ipaddr . to_i + @nic [ @attr_vlan_id ] . to_i
@@ -105,4 +105,10 @@ def get_interface_first_ip(name)
105105 end
106106 return nil
107107 end
108+
109+ def conf_attribute ( nic , name , default )
110+ return nic [ name ] unless nic [ name ] . nil?
111+
112+ nic [ :conf ] [ name ] || default
113+ end
108114end
0 commit comments