Search in sources :

Example 1 with VMDetails

use of org.apache.cloudstack.api.ApiConstants.VMDetails in project cloudstack by apache.

the class AddNicToVMCmdByAdmin method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + getVmId() + " Network Id: " + getNetworkId());
    UserVm result = _userVmService.addNicToVirtualMachine(this);
    ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
    dc.add(VMDetails.valueOf("nics"));
    EnumSet<VMDetails> details = EnumSet.copyOf(dc);
    if (result != null) {
        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 add NIC to vm. Refer to server logs for details.");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Example 2 with VMDetails

use of org.apache.cloudstack.api.ApiConstants.VMDetails in project cloudstack by apache.

the class RemoveNicFromVMCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getVmId()) + " Nic Id: " + this._uuidMgr.getUuid(Nic.class, getNicId()));
    UserVm result = _userVmService.removeNicFromVirtualMachine(this);
    ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
    dc.add(VMDetails.valueOf("nics"));
    EnumSet<VMDetails> details = EnumSet.copyOf(dc);
    if (result != null) {
        UserVmResponse response = _responseGenerator.createUserVmResponse(getResponseView(), "virtualmachine", details, result).get(0);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove NIC from vm, see error log for details");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Example 3 with VMDetails

use of org.apache.cloudstack.api.ApiConstants.VMDetails in project cloudstack by apache.

the class UpdateVMAffinityGroupCmdByAdmin method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException {
    CallContext.current().setEventDetails("Vm Id: " + getId());
    UserVm result = _affinityGroupService.updateVMAffinityGroups(getId(), getAffinityGroupIdList());
    ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
    dc.add(VMDetails.valueOf("affgrp"));
    EnumSet<VMDetails> details = EnumSet.copyOf(dc);
    if (result != null) {
        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(org.apache.cloudstack.api.ApiConstants.VMDetails) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Example 4 with VMDetails

use of org.apache.cloudstack.api.ApiConstants.VMDetails in project cloudstack by apache.

the class UpdateDefaultNicForVMCmdByAdmin method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + getVmId() + " Nic Id: " + getNicId());
    UserVm result = _userVmService.updateDefaultNicForVirtualMachine(this);
    ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
    dc.add(VMDetails.valueOf("nics"));
    EnumSet<VMDetails> details = EnumSet.copyOf(dc);
    if (result != null) {
        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 set default nic for VM. Refer to server logs for details.");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Example 5 with VMDetails

use of org.apache.cloudstack.api.ApiConstants.VMDetails in project cloudstack by apache.

the class RemoveNicFromVMCmdByAdmin method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + getVmId() + " Nic Id: " + getNicId());
    UserVm result = _userVmService.removeNicFromVirtualMachine(this);
    ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
    dc.add(VMDetails.valueOf("nics"));
    EnumSet<VMDetails> details = EnumSet.copyOf(dc);
    if (result != null) {
        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 remove NIC from vm, see error log for details");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Aggregations

ArrayList (java.util.ArrayList)11 VMDetails (org.apache.cloudstack.api.ApiConstants.VMDetails)11 UserVm (com.cloud.uservm.UserVm)10 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)10 ServerApiException (org.apache.cloudstack.api.ServerApiException)9 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 ApiDBUtils (com.cloud.api.ApiDBUtils)1 ApiResponseHelper (com.cloud.api.ApiResponseHelper)1 UserVmJoinVO (com.cloud.api.query.vo.UserVmJoinVO)1 GPU (com.cloud.gpu.GPU)1 ServiceOfferingDetailsVO (com.cloud.service.ServiceOfferingDetailsVO)1 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)1 GuestOS (com.cloud.storage.GuestOS)1 Account (com.cloud.user.Account)1 AccountManager (com.cloud.user.AccountManager)1 User (com.cloud.user.User)1 UserStatisticsVO (com.cloud.user.UserStatisticsVO)1 UserDao (com.cloud.user.dao.UserDao)1 UserStatisticsDao (com.cloud.user.dao.UserStatisticsDao)1 SearchBuilder (com.cloud.utils.db.SearchBuilder)1