Search in sources :

Example 1 with IPAddressResponse

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);
    }
}
Also used : IpAddress(com.cloud.network.IpAddress) IPAddressResponse(org.apache.cloudstack.api.response.IPAddressResponse)

Example 2 with IPAddressResponse

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);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IpAddress(com.cloud.network.IpAddress) IPAddressResponse(org.apache.cloudstack.api.response.IPAddressResponse)

Example 3 with IPAddressResponse

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");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) IpAddress(com.cloud.network.IpAddress) IPAddressResponse(org.apache.cloudstack.api.response.IPAddressResponse)

Example 4 with IPAddressResponse

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);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IpAddress(com.cloud.network.IpAddress) IPAddressResponse(org.apache.cloudstack.api.response.IPAddressResponse)

Example 5 with IPAddressResponse

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");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) IpAddress(com.cloud.network.IpAddress) IPAddressResponse(org.apache.cloudstack.api.response.IPAddressResponse)

Aggregations

IPAddressResponse (org.apache.cloudstack.api.response.IPAddressResponse)6 IpAddress (com.cloud.network.IpAddress)5 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 DataCenter (com.cloud.dc.DataCenter)1 VlanVO (com.cloud.dc.VlanVO)1 Network (com.cloud.network.Network)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 Vpc (com.cloud.network.vpc.Vpc)1 ResourceTag (com.cloud.server.ResourceTag)1 UserVm (com.cloud.uservm.UserVm)1 ResourceTagResponse (org.apache.cloudstack.api.response.ResourceTagResponse)1