Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/network/NetworkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public interface NetworkService {

List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);

IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp) throws ResourceAllocationException, InsufficientAddressCapacityException,
IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp, String ipaddress) throws ResourceAllocationException, InsufficientAddressCapacityException,
ConcurrentOperationException;

boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd implements UserCmd {
authorized = {RoleType.Admin})
private Boolean display;

@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="IP Address to be associated")
private String ipAddress;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -178,6 +181,10 @@ public Integer getRegionId() {
return regionId;
}

public String getIpAddress() {
return ipAddress;
}

public Long getNetworkId() {
if (vpcId != null) {
return null;
Expand Down Expand Up @@ -306,7 +313,7 @@ public void create() throws ResourceAllocationException {
IpAddress ip = null;

if (!isPortable()) {
ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId(), getDisplayIp());
ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId(), getDisplayIp(), ipAddress);
} else {
ip = _networkService.allocatePortableIP(_accountService.getAccount(getEntityOwnerId()), 1, getZoneId(), getNetworkId(), getVpcId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void transferPortableIP(long ipAddrId, long currentNetworkId, long newNetworkId)
PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat)
throws ConcurrentOperationException, InsufficientAddressCapacityException;

IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone, Boolean displayIp)
IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone, Boolean displayIp, String ipaddress)
throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException;

PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List<Long> vlanDbIds, Long networkId, String requestedIp, boolean isSystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public boolean implement(final Network network, final NetworkOffering offering,
try {
Account caller = CallContext.current().getCallingAccount();
long callerUserId = CallContext.current().getCallingUserId();
outsideIp = _ipAddrMgr.allocateIp(owner, false, caller, callerUserId, zone, true);
outsideIp = _ipAddrMgr.allocateIp(owner, false, caller, callerUserId, zone, true, null);
} catch (ResourceAllocationException e) {
s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);
throw new CloudRuntimeException("Unable to allocate additional public Ip address. Exception details " + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) thr

DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);

return allocateIp(ipOwner, isSystem, caller, callerUserId, zone, null);
return allocateIp(ipOwner, isSystem, caller, callerUserId, zone, null, null);
}

// An IP association is required in below cases
Expand Down Expand Up @@ -1132,7 +1132,7 @@ public void releasePodIp(Long id) throws CloudRuntimeException {

@DB
@Override
public IpAddress allocateIp(final Account ipOwner, final boolean isSystem, Account caller, long callerUserId, final DataCenter zone, final Boolean displayIp)
public IpAddress allocateIp(final Account ipOwner, final boolean isSystem, Account caller, long callerUserId, final DataCenter zone, final Boolean displayIp, final String ipaddress)
throws ConcurrentOperationException,
ResourceAllocationException, InsufficientAddressCapacityException {

Expand Down Expand Up @@ -1166,7 +1166,7 @@ public IpAddress allocateIp(final Account ipOwner, final boolean isSystem, Accou
ip = Transaction.execute(new TransactionCallbackWithException<PublicIp, InsufficientAddressCapacityException>() {
@Override
public PublicIp doInTransaction(TransactionStatus status) throws InsufficientAddressCapacityException {
PublicIp ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, null, false, assign, null, isSystem, null, displayIp, false);
PublicIp ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, null, false, assign, ipaddress, isSystem, null, displayIp, false);

if (ip == null) {
InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Unable to find available public IP addresses", DataCenter.class, zone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZ

@Override
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true)
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp)
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp, String ipaddress)
throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {

Account caller = CallContext.current().getCallingAccount();
Expand All @@ -544,7 +544,7 @@ public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolea
if (s_logger.isDebugEnabled()) {
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
}
return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone, displayIp);
return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone, displayIp, ipaddress);
} else {
throw new InvalidParameterValueException("Associate IP address can only be called on the shared networks in the advanced zone"
+ " with Firewall/Source Nat/Static Nat/Port Forwarding/Load balancing services enabled");
Expand All @@ -555,7 +555,7 @@ public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolea
_accountMgr.checkAccess(caller, null, false, ipOwner);
}

return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone, displayIp);
return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone, displayIp, ipaddress);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zone
* @see com.cloud.network.NetworkService#allocateIP(com.cloud.user.Account, long, java.lang.Long)
*/
@Override
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp) throws ResourceAllocationException, InsufficientAddressCapacityException,
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp, String ipaddress) throws ResourceAllocationException, InsufficientAddressCapacityException,
ConcurrentOperationException {
// TODO Auto-generated method stub
return null;
Expand Down
Loading