Search in sources :

Example 1 with SystemVmInstanceResponse

use of org.apache.cloudstack.api.response.SystemVmInstanceResponse in project cloudstack by apache.

the class ApiResponseHelper method createSystemVmInstanceResponse.

@Override
public SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine vm) {
    SystemVmInstanceResponse vmResponse = new SystemVmInstanceResponse();
    vmResponse.setId(vm.getUuid());
    vmResponse.setSystemVmType(vm.getType().toString().toLowerCase());
    vmResponse.setName(vm.getHostName());
    if (vm.getHostId() != null) {
        Host host = ApiDBUtils.findHostById(vm.getHostId());
        if (host != null) {
            vmResponse.setHostId(host.getUuid());
        }
    }
    if (vm.getState() != null) {
        vmResponse.setState(vm.getState().toString());
    }
    if (vm.getType() == Type.DomainRouter) {
        VirtualRouter router = (VirtualRouter) vm;
        if (router.getRole() != null) {
            vmResponse.setRole(router.getRole().toString());
        }
    }
    vmResponse.setObjectName("systemvminstance");
    return vmResponse;
}
Also used : SystemVmInstanceResponse(org.apache.cloudstack.api.response.SystemVmInstanceResponse) Host(com.cloud.host.Host) VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

Host (com.cloud.host.Host)1 VirtualRouter (com.cloud.network.router.VirtualRouter)1 SystemVmInstanceResponse (org.apache.cloudstack.api.response.SystemVmInstanceResponse)1