Search in sources :

Example 1 with IPAddressResponse

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

Example 2 with IPAddressResponse

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

Example 3 with IPAddressResponse

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

Example 4 with IPAddressResponse

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

Example 5 with IPAddressResponse

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

Aggregations

IPAddressResponse (com.cloud.api.response.IPAddressResponse)8 IpAddress (com.cloud.network.IpAddress)7 ArrayList (java.util.ArrayList)4 ServerApiException (com.cloud.api.ServerApiException)3 ListResponse (com.cloud.api.response.ListResponse)3 List (java.util.List)2 ResourceTagResponse (com.cloud.api.response.ResourceTagResponse)1 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 NetworkACL (com.cloud.network.vpc.NetworkACL)1 Vpc (com.cloud.network.vpc.Vpc)1 ResourceTag (com.cloud.server.ResourceTag)1 UserVm (com.cloud.uservm.UserVm)1