use of org.apache.cloudstack.api.response.IPAddressResponse in project cloudstack by apache.
the class UpdateIPAddrCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
IpAddress result = _networkService.updateIP(getId(), getCustomId(), getDisplayIp());
if (result != null) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result);
ipResponse.setResponseName(getCommandName());
setResponseObject(ipResponse);
}
}
use of org.apache.cloudstack.api.response.IPAddressResponse in project cloudstack by apache.
the class ListPublicIpAddressesCmdByAdmin method execute.
@Override
public void execute() {
Pair<List<? extends IpAddress>, Integer> result = _mgr.searchForIPAddresses(this);
ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
for (IpAddress ipAddress : result.first()) {
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 org.apache.cloudstack.api.response.IPAddressResponse in project cloudstack by apache.
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) {
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 org.apache.cloudstack.api.response.IPAddressResponse in project cloudstack by apache.
the class ListPublicIpAddressesCmd method execute.
@Override
public void execute() {
Pair<List<? extends IpAddress>, Integer> result = _mgr.searchForIPAddresses(this);
ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
for (IpAddress ipAddress : result.first()) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, ipAddress);
ipResponse.setObjectName("publicipaddress");
ipAddrResponses.add(ipResponse);
}
response.setResponses(ipAddrResponses, result.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.IPAddressResponse in project cloudstack by apache.
the class AssociateIPAddrCmdByAdmin 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) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Full, result);
ipResponse.setResponseName(getCommandName());
setResponseObject(ipResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address");
}
}
Aggregations