Search in sources :

Example 11 with VMDetails

use of com.cloud.api.ApiConstants.VMDetails in project cosmic by MissionCriticalCloud.

the class UpdateVMAffinityGroupCmdByAdmin method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException {
    CallContext.current().setEventDetails("Vm Id: " + getId());
    final UserVm result = _affinityGroupService.updateVMAffinityGroups(getId(), getAffinityGroupIdList());
    final ArrayList<VMDetails> dc = new ArrayList<>();
    dc.add(VMDetails.valueOf("affgrp"));
    final EnumSet<VMDetails> details = EnumSet.copyOf(dc);
    if (result != null) {
        final UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", details, result).get(0);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm's affinity groups");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) VMDetails(com.cloud.api.ApiConstants.VMDetails) ServerApiException(com.cloud.api.ServerApiException) ArrayList(java.util.ArrayList) UserVmResponse(com.cloud.api.response.UserVmResponse)

Aggregations

VMDetails (com.cloud.api.ApiConstants.VMDetails)11 ArrayList (java.util.ArrayList)11 ServerApiException (com.cloud.api.ServerApiException)9 UserVmResponse (com.cloud.api.response.UserVmResponse)9 UserVm (com.cloud.uservm.UserVm)9 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)1