Skip to content

Commit

Permalink
Merge pull request #386 from mcgG/fix-ipv6
Browse files Browse the repository at this point in the history
[RAC-6563] fix esx-ks ipv6 format
  • Loading branch information
lanchongyizu committed Jul 5, 2018
2 parents 4069731 + ce75811 commit 276e19e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 28 deletions.
12 changes: 7 additions & 5 deletions data/templates/centos-ks
Expand Up @@ -216,6 +216,7 @@ export PATH
<%}) %>

systemctl stop NetworkManager
systemctl disable NetworkManager
modprobe --first-time bonding
systemctl restart network
<%} %>
Expand Down Expand Up @@ -274,8 +275,8 @@ export PATH
echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
echo "IPV6INIT=yes" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
echo "IPV6ADDR=<%=n.ipv6.ipAddr%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
echo "IPV6_DEFAULTGW=<%=n.ipv6.gateway%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
echo "IPV6ADDR=<%=n.ipv6.ipAddr%>/<%=n.ipv6.prefixlen%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
echo "IPV6_DEFAULTGW=<%=n.ipv6.gateway%>/<%=n.ipv6.prefixlen%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
echo "VLAN=yes" >> /etc/sysconfig/network-scripts/ifcfg-$interface.<%=vid%>
<% ipv6 = 1 %>
<% }); %>
Expand All @@ -287,14 +288,15 @@ export PATH
echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo "IPV6INIT=yes" >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo "IPV6ADDR=<%=n.ipv6.ipAddr%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo "IPV6_DEFAULTGW=<%=n.ipv6.gateway%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo "IPV6ADDR=<%=n.ipv6.ipAddr%>/<%=n.ipv6.prefixlen%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo "IPV6_DEFAULTGW=<%=n.ipv6.gateway%>/<%=n.ipv6.prefixlen%>" >> /etc/sysconfig/network-scripts/ifcfg-$interface
<% ipv6 = 1 %>
<% } %>
<% } %>
<% }); %>
<% if( ipv6 ) { %>
grep -q -F 'NETWORKING_IPV6=yes' /etc/sysconfig/network || echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
grep -q -F 'IPV6_AUTOCONF=no' /etc/sysconfig/network || echo "IPV6_AUTOCONF=no" >> /etc/sysconfig/network
<% } %>
<% } %>

Expand Down Expand Up @@ -347,4 +349,4 @@ done;

) 2>&1 >>/root/install-post-sh.log
EOF
%end
%end
9 changes: 7 additions & 2 deletions data/templates/esx-ks
Expand Up @@ -198,13 +198,18 @@ createVmk () {
<% n.ipv6.vlanIds.forEach(function(vid) { %>
<% vmkname = 'vmk' + vmkid++ %>
createVmk <%=vmkname%> $currdev.<%=vid%> $esxSwitchName
esxcli network ip interface ipv6 address add -i <%=vmkname%> -I <%=n.ipv6.ipAddr%>
esxcli network ip interface ipv6 address add -i <%=vmkname%> -I <%=n.ipv6.ipAddr%>/<%=n.ipv6.prefixlen%>
<% if(undefined !== n.ipv6.gateway) { %>
esxcli network interface ipv6 set -i <%=vmkname%> -d off -r off
esxcli network ip interface ipv6 set -i <%=vmkname%> -g <%=n.ipv6.gateway%>
<% } %>
esxcli network vswitch standard portgroup set -p $currdev.<%=vid%> -v <%=vid %>
<% }); %>
<% } else { %>
<% vmkname = 'vmk' + vmkid++ %>
createVmk <%=vmkname%> $currdev $esxSwitchName
esxcli network ip interface ipv6 address add -i <%=vmkname%> -I <%=n.ipv6.ipAddr%>
esxcli network ip interface ipv6 address add -i <%=vmkname%> -I <%=n.ipv6.ipAddr%>/<%=n.ipv6.prefixlen%>
esxcli network ip interface ipv6 set -i <%=vmkname%> -g <%=n.ipv6.gateway%>
<% } %>
<% } %>
<% if( (undefined === n.ipv6) && (undefined === n.ipv4) ) { %>
Expand Down
35 changes: 24 additions & 11 deletions data/templates/install-debian/debian-interfaces
Expand Up @@ -9,29 +9,42 @@ auto lo
iface lo inet loopback

<%_ if (typeof networkDevices !== 'undefined' && networkDevices.length > 0) { _%>
<%_ networkDevices.forEach(function(n) { _%>
<%_ for (p in n) { _%>
<%_ ip = n[p]; _%>
<%_ if (['ipv4', 'ipv6'].indexOf(p) === -1 || undefined == ip) continue; _%>
<%_ if (undefined !== ip.vlanIds) { _%>
<%_ ip.vlanIds.forEach(function(vid) { _%>
<%_ networkDevices.forEach(function(n) { _%>
<%_ for (p in n) { _%>
<%_ ip = n[p]; _%>
<%_ if (['ipv4', 'ipv6'].indexOf(p) === -1 || undefined == ip) continue; _%>
<%_ if (undefined !== ip.vlanIds) { _%>
<%_ ip.vlanIds.forEach(function(vid) { _%>
<%_ if (p === 'ipv4') { _%>
auto <%=n.device%>.<%=vid%>
iface <%=n.device%>.<%=vid%> inet static
address <%=ip.ipAddr%>
netmask <%=ip.netmask%>
<%_ } else { _%>
auto <%=n.device%>.<%=vid%>
iface <%=n.device%>.<%=vid%> inet6 static
address <%=ip.ipAddr%>
netmask <%=ip.prefixlen%>
<%_ } _%>
gateway <%=ip.gateway%>
vlan-raw-device <%=n.device%>
<%_ }); _%>
<%_ } else { _%>
<%_ }); _%>
<%_ } else { _%>
<%_ if (p === 'ipv4') { _%>
auto <%=n.device%>
iface <%=n.device%> inet static
address <%=ip.ipAddr%>
netmask <%=ip.netmask%>
<%_ } else { _%>
auto <%=n.device%>
iface <%=n.device%> inet6 static
address <%=ip.ipAddr%>
netmask <%=ip.prefixlen%>
<%_ } _%>
gateway <%=ip.gateway%>

<%_ } _%>
<%_ } _%>
<%_ } _%>
<%_ }); _%>
<%_ }); _%>
<%_ } _%>

<% if (typeof dnsServers !== 'undefined' && dnsServers.length > 0) { -%>
Expand Down
2 changes: 2 additions & 0 deletions data/templates/install-debian/debian-preseed
Expand Up @@ -290,6 +290,8 @@ in-target vconfig add ip.device <%=vid%>; \
<%_ }); _%>
<%_ if (typeof version !== 'undefined' && version === 'artful') { _%>
in-target wget http://<%=server%>:<%=port%>/api/current/templates/ubuntu-netplan-interfaces?nodeId=<%=nodeId%> -O /etc/netplan/01-netcfg.yaml; \
<%_ } else if (typeof version !== 'undefined' && version === 'trusty') { _%>
wget http://<%=server%>:<%=port%>/api/current/templates/debian-interfaces?nodeId=<%=nodeId%> -O /etc/network/interfaces; \
<%_ } else { _%>
in-target wget http://<%=server%>:<%=port%>/api/current/templates/debian-interfaces?nodeId=<%=nodeId%> -O /etc/network/interfaces; \
<%_ } _%>
Expand Down
2 changes: 1 addition & 1 deletion data/templates/install-photon/post-install-photon.sh
Expand Up @@ -27,7 +27,7 @@ chmod 644 /etc/systemd/network/<%=d.device%>-static.network
<%_ if ('ipv4' === conf) { _%>
<%_ cidr += ((parseInt(i, 10).toString(2)).match(/1/g) || []).length; _%>
<%_ } else { _%>
<%_ cidr += ((parseInt(i, 16).toString(2)).match(/1/g) || []).length; _%>
<%_ cidr = i _%>
<%_ } _%>
<%_ }); _%>
echo "Address=<%=ipconfig.ipAddr%>/<%=cidr%>" >> /etc/systemd/network/<%=d.device%>-static.network
Expand Down
6 changes: 6 additions & 0 deletions data/templates/pxe-cloud-config.yml
Expand Up @@ -35,6 +35,12 @@ coreos:
<% } %>
Address=<%=networkDevice.ipv4.ipAddr%>/<%=cidr_bits%>
Gateway=<%=networkDevice.ipv4.gateway%>

<% if( undefined !== networkDevice.ipv6) { %>
Address=<%=networkDevice.ipv6.ipAddr%>/<%=networkDevice.ipv6.prefixlen%>
Gateway=<%=networkDevice.ipv6.gateway%>
<% } %>

- name: down-interfaces.service
command: start
content: |
Expand Down
4 changes: 2 additions & 2 deletions data/templates/suse-autoinst.xml
Expand Up @@ -98,7 +98,7 @@
<startmode>auto</startmode>
<device><%=n.device%>.<%=vid%></device>
<ipaddr><%=n.ipv6.ipAddr%></ipaddr>
<netmask><%=n.ipv6.netmask%></netmask>
<prefixlen><%=n.ipv6.prefixlen%></prefixlen>
<gateway><%=n.ipv6.gateway%></gateway>
<vlan>yes</vlan>
</interface>
Expand All @@ -109,7 +109,7 @@
<startmode>auto</startmode>
<device><%=n.device%></device>
<ipaddr><%=n.ipv6.ipAddr%></ipaddr>
<netmask><%=n.ipv6.netmask%></netmask>
<prefixlen><%=n.ipv6.prefixlen%></prefixlen>
<gateway><%=n.ipv6.gateway%></gateway>
</interface>
<% ipv6 = 1 %>
Expand Down
12 changes: 5 additions & 7 deletions data/templates/unattend_server2012.xml
Expand Up @@ -180,20 +180,18 @@
<%} %>
<% if( undefined != n.ipv6 ) { %>
<% if( undefined != n.ipv6.netmask ) { %>
<% n.ipv6.netmask.split(':').forEach(function(octet) {%>
<% ipv6_cidr_bits+=((parseInt(octet, 16) >>> 0).toString(2).match(/1/g)||[]).length;%>
<% });%>
<% if( undefined != n.ipv6.prefixlen ) { %>
<% ipv6_cidr_bits = n.ipv6.prefixlen %>
<% } %>
<% if( undefined != n.ipv6.ipAddr ) { %>
<% ipv6_ipAddress = n.ipv6.ipAddr %>
<% ipv6_ipAddress = n.ipv6.ipAddr %>
<% } else { %>
<% dhcp_ipv6 = true %>
<% dhcp_ipv6 = true %>
<% } %>
<% if( undefined != n.ipv6.gateway ) { %>
<% ipv6_gateWay = n.ipv6.gateway %>
<% ipv6_gateWay = n.ipv6.gateway %>
<% } %>
<% } %>
Expand Down

0 comments on commit 276e19e

Please sign in to comment.