Skip to content

Commit d981edb

Browse files
ustcweizhouyadvr
authored andcommitted
server: acquire IPv4 address when add secondary IP to nic if IP is not specified (#3635)
After commit fbf4884, 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.
1 parent 23ca806 commit d981edb

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

server/src/main/java/com/cloud/network/NetworkServiceImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,10 @@ public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses req
732732
}
733733

734734
try {
735-
if (ipv4Address != null) {
736-
ipaddr = _ipAddrMgr.allocatePublicIpForGuestNic(network, podId, ipOwner, ipv4Address);
737-
}
738735
if (ipv6Address != null) {
739736
ip6addr = ipv6AddrMgr.allocatePublicIp6ForGuestNic(network, podId, ipOwner, ipv6Address);
737+
} else {
738+
ipaddr = _ipAddrMgr.allocatePublicIpForGuestNic(network, podId, ipOwner, ipv4Address);
740739
}
741740
if (ipaddr == null && ipv6Address == null) {
742741
throw new InvalidParameterValueException("Allocating ip to guest nic " + nicId + " failed");

0 commit comments

Comments
 (0)