Search in sources :

Example 1 with ServiceInstanceResponse

use of org.apache.cloudstack.network.contrail.api.response.ServiceInstanceResponse in project cloudstack by apache.

the class CreateServiceInstanceCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    try {
        _vrouterService.startServiceInstance(getEntityId());
        ServiceInstanceResponse response = _vrouterService.createServiceInstanceResponse(getEntityId());
        response.setObjectName("serviceinstance");
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (Exception ex) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : ServiceInstanceResponse(org.apache.cloudstack.network.contrail.api.response.ServiceInstanceResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 2 with ServiceInstanceResponse

use of org.apache.cloudstack.network.contrail.api.response.ServiceInstanceResponse in project cloudstack by apache.

the class ServiceManagerImpl method createServiceInstanceResponse.

@Override
public ServiceInstanceResponse createServiceInstanceResponse(long instanceId) {
    s_logger.debug("ServiceInstance response for id: " + instanceId);
    UserVmVO vm = _vmDao.findById(instanceId);
    ServiceInstanceResponse response = new ServiceInstanceResponse();
    response.setId(vm.getUuid());
    Account owner = _accountService.getAccount(vm.getAccountId());
    if (owner.getType() == Account.ACCOUNT_TYPE_PROJECT) {
        Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(owner.getAccountId());
        response.setProjectId(project.getUuid());
        response.setProjectName(project.getName());
    } else {
        response.setAccountName(owner.getAccountName());
    }
    return response;
}
Also used : ServiceInstanceResponse(org.apache.cloudstack.network.contrail.api.response.ServiceInstanceResponse) Account(com.cloud.user.Account) Project(com.cloud.projects.Project) UserVmVO(com.cloud.vm.UserVmVO)

Aggregations

ServiceInstanceResponse (org.apache.cloudstack.network.contrail.api.response.ServiceInstanceResponse)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 Project (com.cloud.projects.Project)1 Account (com.cloud.user.Account)1 UserVmVO (com.cloud.vm.UserVmVO)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1