Commit c1bcd234 authored by IMBERT Matthieu's avatar IMBERT Matthieu Committed by Baptiste Jonglez
Browse files

[ipv6] use global config instead of hardcoded value

parent a633007f
--- ---
ipv6: ipv6:
prefix: '2001:660:4406'
site-indexes: site-indexes:
grenoble: 1 grenoble: 1
lille: 2 lille: 2
......
...@@ -162,7 +162,7 @@ def add_ipv6(h) ...@@ -162,7 +162,7 @@ def add_ipv6(h)
ip4 = ipv6_adapters.values[0]['ip'] ip4 = ipv6_adapters.values[0]['ip']
ipv6_adapters.each_with_index do |(_iface, nah), idx| ipv6_adapters.each_with_index do |(_iface, nah), idx|
# compute and assign IPv6 based on IPv4 of the first adapter # compute and assign IPv6 based on IPv4 of the first adapter
ip6 = '2001:660:4406:' ip6 = h['ipv6']['prefix'] + ':'
ip6 += '%x' % h['ipv6']['site-indexes'][site_uid] ip6 += '%x' % h['ipv6']['site-indexes'][site_uid]
ip6 += '00:' ip6 += '00:'
ip6 += '%x' % ((ip4.split('.')[2].to_i & 0b1111) + 1) ip6 += '%x' % ((ip4.split('.')[2].to_i & 0b1111) + 1)
...@@ -199,7 +199,7 @@ def add_kavlan_ipv6s(h) ...@@ -199,7 +199,7 @@ def add_kavlan_ipv6s(h)
hn['kavlan6'][iface] = {} hn['kavlan6'][iface] = {}
hn['kavlan'][iface].each_key do |kvl| hn['kavlan'][iface].each_key do |kvl|
kvl_id = kvl.split('-')[1].to_i kvl_id = kvl.split('-')[1].to_i
ip6 = '2001:660:4406:' ip6 = h['ipv6']['prefix'] + ':'
ip6 += '%x' % h['ipv6']['site-indexes'][site_uid] ip6 += '%x' % h['ipv6']['site-indexes'][site_uid]
ip6 += '%x:' % (kvl_id + 0x80) ip6 += '%x:' % (kvl_id + 0x80)
ip6 += '%x' % ((ip4.split('.')[2].to_i & 0b1111) + 1) ip6 += '%x' % ((ip4.split('.')[2].to_i & 0b1111) + 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment