rafaelweingartner commented on a change in pull request #2773:
CLOUDSTACK-10328: Add Secondary IPv6 address through API
URL: https://github.com/apache/cloudstack/pull/2773#discussion_r206868794
##########
File path:
api/src/main/java/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java
##########
@@ -169,17 +161,15 @@ public long getEntityOwnerId() {
@Override
public void create() throws ResourceAllocationException {
- String ip;
NicSecondaryIp result;
- String secondaryIp = null;
- if ((ip = getIpaddress()) != null) {
- if (!NetUtils.isValidIp4(ip)) {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
"Invalid ip address " + ip);
- }
+
+ IpAddresses requestedIpPair = new IpAddresses(ipAddr, null);
+ if (!NetUtils.isIpv4(ipAddr)) {
+ requestedIpPair = new IpAddresses(null, ipAddr);
}
try {
- result = _networkService.allocateSecondaryGuestIP(getNicId(),
getIpaddress());
+ result = _networkService.allocateSecondaryGuestIP(getNicId(),
requestedIpPair);
Review comment:
What about sending the command to `allocateSecondaryGuestIP`? Then, you can
extract the block 166-168 to a method and unit-test it there.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services