public void execute() throws ResourceUnavailableException, ResourceAllocationException,
ConcurrentOperationException, InsufficientCapacityException {
CallContext.current().setEventDetails("Nic Id: " + getNicId() );
String ip;
NicSecondaryIp result;
String secondaryIp = null;
if ((ip = getIpaddress()) != null) {
if (!NetUtils.isValidIp(ip)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid ip address " + ip);
}
}
try {
result = _networkService.allocateSecondaryGuestIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNicId(), getNetworkId(), getIpaddress());
} catch (InsufficientAddressCapacityException e) {
throw new InvalidParameterValueException("Allocating guest ip for nic failed");
}
if (result != null) {
secondaryIp = result.getIp4Address();
if (getNetworkType() == NetworkType.Basic) {
// add security group rules for the secondary ip addresses
boolean success = false;
success = _securityGroupService.securityGroupRulesForVmSecIp(getNicId(), getNetworkId(), secondaryIp, (boolean) true);
if (success == false) {