use of com.cloud.api.response.IPAddressResponse in project cosmic by MissionCriticalCloud.
the class ListPublicIpAddressesCmdByAdmin method execute.
@Override
public void execute() {
final Pair<List<? extends IpAddress>, Integer> result = _mgr.searchForIPAddresses(this);
final ListResponse<IPAddressResponse> response = new ListResponse<>();
final List<IPAddressResponse> ipAddrResponses = new ArrayList<>();
for (final IpAddress ipAddress : result.first()) {
final IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Full, ipAddress);
ipResponse.setObjectName("publicipaddress");
ipAddrResponses.add(ipResponse);
}
response.setResponses(ipAddrResponses, result.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.IPAddressResponse in project cosmic by MissionCriticalCloud.
the class AssociateIPAddrCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
CallContext.current().setEventDetails("IP ID: " + getEntityId());
IpAddress result = null;
if (getVpcId() != null) {
result = _vpcService.associateIPToVpc(getEntityId(), getVpcId());
} else if (getNetworkId() != null) {
result = _networkService.associateIPToNetwork(getEntityId(), getNetworkId());
}
if (result != null) {
final IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result);
ipResponse.setResponseName(getCommandName());
setResponseObject(ipResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign IP address");
}
}
use of com.cloud.api.response.IPAddressResponse in project cosmic by MissionCriticalCloud.
the class UpdateIPAddrCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
final IpAddress result = _networkService.updateIP(getId(), getCustomId(), getDisplayIp());
if (result != null) {
final IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result);
ipResponse.setResponseName(getCommandName());
setResponseObject(ipResponse);
}
}
use of com.cloud.api.response.IPAddressResponse in project CloudStack-archive by CloudStack-extras.
the class ListPublicIpAddressesCmd method execute.
@Override
public void execute() {
List<? extends IpAddress> result = _mgr.searchForIPAddresses(this);
ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
for (IpAddress ipAddress : result) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ipAddress);
ipResponse.setObjectName("publicipaddress");
ipAddrResponses.add(ipResponse);
}
response.setResponses(ipAddrResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.IPAddressResponse in project CloudStack-archive by CloudStack-extras.
the class AssociateIPAddrCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
UserContext.current().setEventDetails("Ip Id: " + getEntityId());
IpAddress result = _networkService.associateIP(getEntityId());
if (result != null) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
ipResponse.setResponseName(getCommandName());
this.setResponseObject(ipResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to assign ip address");
}
}
Aggregations