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;
}
Aggregations