mirror of https://github.com/apache/cloudstack.git
add the status of each portable IP (its state, details of associated data
center/VPC/guest network etc) in the PortableIpRangeResponse returned by listPortableIpRanges API
This commit is contained in:
parent
e7b2fb2255
commit
bf3cb274cf
|
|
@ -58,6 +58,7 @@ import com.cloud.offering.DiskOffering;
|
|||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.user.Account;
|
||||
import org.apache.cloudstack.region.PortableIp;
|
||||
import org.apache.cloudstack.region.PortableIpRange;
|
||||
|
||||
public interface ConfigurationService {
|
||||
|
|
@ -287,4 +288,6 @@ public interface ConfigurationService {
|
|||
boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);
|
||||
|
||||
List<? extends PortableIpRange> listPortableIpRanges(ListPortableIpRangesCmd cmd);
|
||||
|
||||
List<? extends PortableIp> listPortableIps(long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ public class ApiConstants {
|
|||
public static final String POLICY_ID = "policyid";
|
||||
public static final String PORT = "port";
|
||||
public static final String PORTAL = "portal";
|
||||
public static final String PORTABLE_IP_ADDRESS = "portableipaddress";
|
||||
public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid";
|
||||
public static final String PRIVATE_INTERFACE = "privateinterface";
|
||||
public static final String PRIVATE_IP = "privateip";
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
|||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.region.PortableIp;
|
||||
import org.apache.cloudstack.region.PortableIpRange;
|
||||
import org.apache.cloudstack.region.Region;
|
||||
import org.apache.cloudstack.usage.Usage;
|
||||
|
|
@ -399,4 +400,6 @@ public interface ResponseGenerator {
|
|||
Long getAffinityGroupId(String name, long entityOwnerId);
|
||||
|
||||
PortableIpRangeResponse createPortableIPRangeResponse(PortableIpRange range);
|
||||
|
||||
PortableIpResponse createPortableIPResponse(PortableIp portableIp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ import javax.inject.Inject;
|
|||
import org.apache.cloudstack.api.*;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.PortableIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.PortableIpResponse;
|
||||
import org.apache.cloudstack.api.response.RegionResponse;
|
||||
import org.apache.cloudstack.region.PortableIp;
|
||||
import org.apache.cloudstack.region.PortableIpRange;
|
||||
import org.apache.cloudstack.region.Region;
|
||||
import org.apache.cloudstack.region.RegionService;
|
||||
|
|
@ -85,6 +87,17 @@ public class ListPortableIpRangesCmd extends BaseListCmd {
|
|||
if (portableIpRanges != null && !portableIpRanges.isEmpty()) {
|
||||
for (PortableIpRange range : portableIpRanges) {
|
||||
PortableIpRangeResponse rangeResponse = _responseGenerator.createPortableIPRangeResponse(range);
|
||||
|
||||
List<? extends PortableIp> portableIps = _configService.listPortableIps(range.getId());
|
||||
if (portableIps != null && !portableIps.isEmpty()) {
|
||||
List<PortableIpResponse> portableIpResponses = new ArrayList<PortableIpResponse>();
|
||||
for (PortableIp portableIP: portableIps) {
|
||||
PortableIpResponse portableIpresponse = _responseGenerator.createPortableIPResponse(portableIP);
|
||||
portableIpResponses.add(portableIpresponse);
|
||||
}
|
||||
rangeResponse.setPortableIpResponses(portableIpResponses);
|
||||
}
|
||||
|
||||
rangeResponse.setObjectName("portableiprange");
|
||||
responses.add(rangeResponse);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ public class PortableIpRangeResponse extends BaseResponse {
|
|||
@SerializedName(ApiConstants.END_IP) @Param(description="the end ip of the portable IP range")
|
||||
private String endIp;
|
||||
|
||||
@SerializedName(ApiConstants.PORTABLE_IP_ADDRESS)
|
||||
@Param(description="List of portable IP and association with zone/network/vpc details that are part of GSLB rule", responseObject = PortableIpResponse.class)
|
||||
private List<PortableIpResponse> portableIpResponses;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
|
@ -83,4 +87,7 @@ public class PortableIpRangeResponse extends BaseResponse {
|
|||
this.vlan = vlan;
|
||||
}
|
||||
|
||||
public void setPortableIpResponses(List<PortableIpResponse> portableIpResponses) {
|
||||
this.portableIpResponses = portableIpResponses;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
|||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.region.PortableIp;
|
||||
import org.apache.cloudstack.region.PortableIpRange;
|
||||
import org.apache.cloudstack.region.Region;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
|
|
@ -3732,4 +3733,50 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setRegionId(ipRange.getRegionId());
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortableIpResponse createPortableIPResponse(PortableIp portableIp) {
|
||||
PortableIpResponse response = new PortableIpResponse();
|
||||
response.setAddress(portableIp.getAddress());
|
||||
Long accountId = portableIp.getAllocatedInDomainId();
|
||||
if (accountId != null) {
|
||||
Account account = ApiDBUtils.findAccountById(accountId);
|
||||
response.setAllocatedToAccountId(account.getAccountName());
|
||||
Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
|
||||
response.setAllocatedInDomainId(domain.getUuid());
|
||||
}
|
||||
|
||||
response.setAllocatedTime(portableIp.getAllocatedTime());
|
||||
|
||||
if (portableIp.getAssociatedDataCenterId() != null) {
|
||||
DataCenter zone = ApiDBUtils.findZoneById(portableIp.getAssociatedDataCenterId());
|
||||
if (zone != null) {
|
||||
response.setAssociatedDataCenterId(zone.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
if (portableIp.getPhysicalNetworkId() != null) {
|
||||
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(portableIp.getPhysicalNetworkId());
|
||||
if (pnw != null) {
|
||||
response.setPhysicalNetworkId(pnw.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
if (portableIp.getAssociatedWithNetworkId() != null) {
|
||||
Network ntwk = ApiDBUtils.findNetworkById(portableIp.getAssociatedWithNetworkId());
|
||||
if (ntwk != null) {
|
||||
response.setAssociatedWithNetworkId(ntwk.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
if (portableIp.getAssociatedWithVpcId() != null) {
|
||||
Vpc vpc = ApiDBUtils.findVpcById(portableIp.getAssociatedWithVpcId());
|
||||
if (vpc != null) {
|
||||
response.setAssociatedWithVpcId(vpc.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
response.setState(portableIp.getState().name());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4391,6 +4391,17 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
return _portableIpRangeDao.listAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends PortableIp> listPortableIps(long id) {
|
||||
|
||||
PortableIpRangeVO portableIpRange = _portableIpRangeDao.findById(id);
|
||||
if (portableIpRange == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid portable IP range id.");
|
||||
}
|
||||
|
||||
return _portableIpDao.listByRangeId(portableIpRange.getId());
|
||||
}
|
||||
|
||||
private boolean checkOverlapPortableIpRange(int regionId, String newStartIpStr, String newEndIpStr) {
|
||||
long newStartIp = NetUtils.ip2Long(newStartIpStr);
|
||||
long newEndIp = NetUtils.ip2Long(newEndIpStr);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
|
|||
import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
|
||||
import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
|
||||
import org.apache.cloudstack.region.PortableIp;
|
||||
import org.apache.cloudstack.region.PortableIpRange;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -394,7 +395,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
|||
|
||||
@Override
|
||||
public boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd) {
|
||||
return false;
|
||||
return false;// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -402,6 +403,11 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
|||
return null;// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends PortableIp> listPortableIps(long id) {
|
||||
return null;// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.utils.component.Manager#configure(java.lang.String, java.util.Map)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue