Skip to content

Commit

Permalink
IPv6: fix deploy vm issue in ipv6-only networks without VR (#5648)
Browse files Browse the repository at this point in the history
* IPv6: fix deploy vm issue in ipv6-only networks

* Update #5648: add method setNicPropertiesFromNetwork
  • Loading branch information
weizhouapache committed Nov 18, 2021
1 parent c95f8e2 commit dd458fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public interface Ipv6AddressManager extends Manager {

public String acquireGuestIpv6Address(Network network, String requestedIpv6) throws InsufficientAddressCapacityException;

public void setNicIp6Address(final NicProfile nic, final DataCenter dc, final Network network);
public void setNicIp6Address(final NicProfile nic, final DataCenter dc, final Network network) throws InsufficientAddressCapacityException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ protected boolean isIp6Taken(Network network, String requestedIpv6) {
* address information.
*/
@Override
public void setNicIp6Address(final NicProfile nic, final DataCenter dc, final Network network) {
public void setNicIp6Address(final NicProfile nic, final DataCenter dc, final Network network) throws InsufficientAddressCapacityException {
if (network.getIp6Gateway() != null) {
if (nic.getIPv6Address() == null) {
s_logger.debug("Found IPv6 CIDR " + network.getIp6Cidr() + " for Network " + network);
nic.setIPv6Cidr(network.getIp6Cidr());
nic.setIPv6Gateway(network.getIp6Gateway());

setNicPropertiesFromNetwork(nic, network);

IPv6Address ipv6addr = NetUtils.EUI64Address(network.getIp6Cidr(), nic.getMacAddress());
s_logger.info("Calculated IPv6 address " + ipv6addr + " using EUI-64 for NIC " + nic.getUuid());
nic.setIPv6Address(ipv6addr.toString());
Expand All @@ -217,4 +219,15 @@ public void setNicIp6Address(final NicProfile nic, final DataCenter dc, final Ne
}
}

private void setNicPropertiesFromNetwork(NicProfile nic, Network network) throws InsufficientAddressCapacityException {
if (nic.getBroadcastType() == null) {
nic.setBroadcastType(network.getBroadcastDomainType());
}
if (nic.getBroadCastUri() == null) {
nic.setBroadcastUri(network.getBroadcastUri());
}
if (nic.getMacAddress() == null) {
nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void setAcquireGuestIpv6AddressTest(boolean isIPAvailable, State state)
}

@Test
public void setNICIPv6AddressTest() {
public void setNICIPv6AddressTest() throws InsufficientAddressCapacityException {
NicProfile nic = new NicProfile();
Network network = mock(Network.class);
DataCenter dc = mock(DataCenter.class);
Expand Down

0 comments on commit dd458fe

Please sign in to comment.