Search in sources :

Example 1 with VpcOffering

use of com.cloud.legacymodel.network.vpc.VpcOffering in project cosmic by MissionCriticalCloud.

the class VpcManagerImpl method updateVpcOffering.

@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_UPDATE, eventDescription = "updating vpc offering")
public VpcOffering updateVpcOffering(final long vpcOffId, final String vpcOfferingName, final String displayText, final String state) {
    CallContext.current().setEventDetails(" Id: " + vpcOffId);
    // Verify input parameters
    final VpcOfferingVO offeringToUpdate = _vpcOffDao.findById(vpcOffId);
    if (offeringToUpdate == null) {
        throw new InvalidParameterValueException("Unable to find vpc offering " + vpcOffId);
    }
    final VpcOfferingVO offering = _vpcOffDao.createForUpdate(vpcOffId);
    if (vpcOfferingName != null) {
        offering.setName(vpcOfferingName);
    }
    if (displayText != null) {
        offering.setDisplayText(displayText);
    }
    if (state != null) {
        boolean validState = false;
        for (final VpcOffering.State st : VpcOffering.State.values()) {
            if (st.name().equalsIgnoreCase(state)) {
                validState = true;
                offering.setState(st);
            }
        }
        if (!validState) {
            throw new InvalidParameterValueException("Incorrect state value: " + state);
        }
    }
    if (_vpcOffDao.update(vpcOffId, offering)) {
        s_logger.debug("Updated VPC offeirng id=" + vpcOffId);
        return _vpcOffDao.findById(vpcOffId);
    } else {
        return null;
    }
}
Also used : State(com.cloud.legacymodel.network.vpc.VpcOffering.State) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) VpcOffering(com.cloud.legacymodel.network.vpc.VpcOffering) ActionEvent(com.cloud.event.ActionEvent)

Example 2 with VpcOffering

use of com.cloud.legacymodel.network.vpc.VpcOffering in project cosmic by MissionCriticalCloud.

the class ListVPCOfferingsCmd method execute.

@Override
public void execute() {
    final Pair<List<? extends VpcOffering>, Integer> offerings = _vpcProvSvc.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), getSupportedServices(), isDefault, this.getKeyword(), getState(), this.getStartIndex(), this.getPageSizeVal());
    final ListResponse<VpcOfferingResponse> response = new ListResponse<>();
    final List<VpcOfferingResponse> offeringResponses = new ArrayList<>();
    for (final VpcOffering offering : offerings.first()) {
        final VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
        offeringResponses.add(offeringResponse);
    }
    response.setResponses(offeringResponses, offerings.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ListResponse(com.cloud.api.response.ListResponse) VpcOffering(com.cloud.legacymodel.network.vpc.VpcOffering) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with VpcOffering

use of com.cloud.legacymodel.network.vpc.VpcOffering in project cosmic by MissionCriticalCloud.

the class CreateVPCOfferingCmd method execute.

@Override
public void execute() {
    final VpcOffering vpc = _vpcProvSvc.getVpcOffering(getEntityId());
    if (vpc != null) {
        final VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(vpc);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC offering");
    }
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) VpcOffering(com.cloud.legacymodel.network.vpc.VpcOffering)

Example 4 with VpcOffering

use of com.cloud.legacymodel.network.vpc.VpcOffering in project cosmic by MissionCriticalCloud.

the class UpdateVPCOfferingCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final VpcOffering result = _vpcProvSvc.updateVpcOffering(getId(), getVpcOfferingName(), getDisplayText(), getState());
    if (result != null) {
        final VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC offering");
    }
}
Also used : VpcOfferingResponse(com.cloud.api.response.VpcOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) VpcOffering(com.cloud.legacymodel.network.vpc.VpcOffering)

Example 5 with VpcOffering

use of com.cloud.legacymodel.network.vpc.VpcOffering in project cosmic by MissionCriticalCloud.

the class CreateVPCOfferingCmd method create.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void create() throws ResourceAllocationException {
    final VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices(), getServiceProviders(), getServiceCapabilitystList(), getServiceOfferingId(), getSecondaryServiceOfferingId());
    if (vpcOff != null) {
        setEntityId(vpcOff.getId());
        setEntityUuid(vpcOff.getUuid());
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a VPC offering");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) VpcOffering(com.cloud.legacymodel.network.vpc.VpcOffering)

Aggregations

VpcOffering (com.cloud.legacymodel.network.vpc.VpcOffering)8 ArrayList (java.util.ArrayList)4 ServerApiException (com.cloud.api.ServerApiException)3 VpcOfferingResponse (com.cloud.api.response.VpcOfferingResponse)3 Service (com.cloud.legacymodel.network.Network.Service)3 List (java.util.List)3 NetworkOrchestrationService (com.cloud.engine.orchestration.service.NetworkOrchestrationService)2 ActionEvent (com.cloud.event.ActionEvent)2 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)2 Network (com.cloud.legacymodel.network.Network)2 NetworkService (com.cloud.network.NetworkService)2 PhysicalNetwork (com.cloud.network.PhysicalNetwork)2 ResourceLimitService (com.cloud.user.ResourceLimitService)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Set (java.util.Set)2 ExecutorService (java.util.concurrent.ExecutorService)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 ListResponse (com.cloud.api.response.ListResponse)1 NetworkResponse (com.cloud.api.response.NetworkResponse)1