server: acquire IPv4 address when add secondary IP to nic if IP is not specified (#3635)

After commit fbf488497f, admin need to specify an ipv4 or ipv6 addresses when add IP to nic which breaks backward compatibity. If IP is not specified, a IPv4 address should be returned.
This commit is contained in:
Wei Zhou 2019-11-21 07:14:41 +01:00 committed by Rohit Yadav
parent 23ca806db9
commit d981edb4bc
1 changed files with 2 additions and 3 deletions

View File

@ -732,11 +732,10 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
}
try {
if (ipv4Address != null) {
ipaddr = _ipAddrMgr.allocatePublicIpForGuestNic(network, podId, ipOwner, ipv4Address);
}
if (ipv6Address != null) {
ip6addr = ipv6AddrMgr.allocatePublicIp6ForGuestNic(network, podId, ipOwner, ipv6Address);
} else {
ipaddr = _ipAddrMgr.allocatePublicIpForGuestNic(network, podId, ipOwner, ipv4Address);
}
if (ipaddr == null && ipv6Address == null) {
throw new InvalidParameterValueException("Allocating ip to guest nic " + nicId + " failed");