use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class ProcessOvfUpdateForStorageDomainCommand method addVmsStatus.
private void addVmsStatus(List<Guid> vmAndTemplatesIds, Map<String, Object> data) {
Map<String, Object> vmsStatus = new HashMap<>();
for (Guid vmId : vmAndTemplatesIds) {
VmDynamic vmDynamic = vmDynamicDao.get(vmId);
if (vmDynamic != null && vmDynamic.getStatus() != VMStatus.Down) {
vmsStatus.put(vmId.toString(), vmDynamic.getStatus().getValue());
log.debug("OVF_STORE - Add vm id '{}' with status: '{}'", vmId, vmDynamic.getStatus());
} else {
log.debug("OVF_STORE - Skip entity id '{}' with status: '{}'", vmId, vmDynamic != null ? vmDynamic.getStatus() : "N/A");
}
}
data.put(OvfInfoFileConstants.VmStatus, vmsStatus);
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVMDynamicData.
public static VmDynamic buildVMDynamicData(Map<String, Object> struct, VDS host) {
VmDynamic vmdynamic = new VmDynamic();
updateVMDynamicData(vmdynamic, struct, host);
return vmdynamic;
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class VmStatsVdsBrokerCommand method createVdsmVm.
protected VdsmVm createVdsmVm(Map<String, Object> struct) {
VmDynamic vmDynamic = new VmDynamic();
VdsBrokerObjectsBuilder.updateVMDynamicData(vmDynamic, struct, getVds());
Guid vmId = vmDynamic.getId();
return new VdsmVm(getVdsmCallTimestamp(struct)).setVmDynamic(vmDynamic).setDevicesHash(getVmDevicesHash(struct)).setVmStatistics(buildVMStatisticsData(struct)).setVmJobs(buildVmJobsData(struct)).setInterfaceStatistics(buildInterfaceStatisticsData(struct)).setVmBalloonInfo(buildVmBalloonInfo(struct)).setVmGuestAgentInterfaces(buildVmGuestAgentInterfacesData(vmId, struct)).setLunsMap(buildVmLunDisksData(struct)).setDiskStatistics(buildVmDiskStatistics(struct));
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class DestroyVmVDSCommand method executeVmCommand.
@Override
protected void executeVmCommand() {
VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.Destroy, getParameters());
if (vdsReturnValue.getSucceeded()) {
VmDynamic vm = vmDynamicDao.get(getParameters().getVmId());
changeStatus(vm);
vm.setStopReason(getParameters().getReason());
vmManager.update(vm);
getVDSReturnValue().setReturnValue(vm.getStatus());
} else if (vdsReturnValue.getExceptionObject() != null) {
logFailureToDestroy(vdsReturnValue);
getVDSReturnValue().setSucceeded(false);
getVDSReturnValue().setExceptionString(vdsReturnValue.getExceptionString());
getVDSReturnValue().setExceptionObject(vdsReturnValue.getExceptionObject());
getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
}
}
use of org.ovirt.engine.core.common.businessentities.VmDynamic in project ovirt-engine by oVirt.
the class StorageDomainValidator method isRunningVmsOrVmLeasesForBackupDomain.
public ValidationResult isRunningVmsOrVmLeasesForBackupDomain(VmHandler vmHandler) {
Set<String> invalidVmsForBackupStorageDomain = new HashSet<>();
QueryReturnValue ret = getEntitiesWithLeaseIdForStorageDomain(storageDomain.getId());
if (!ret.getSucceeded()) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_RETRIEVE_VMS_FOR_WITH_LEASES);
}
getRetVal(ret).forEach(vmBase -> {
VmDynamic vm = getVmDynamicDao().get(vmBase.getId());
if (vm != null && vm.getStatus() != VMStatus.Down) {
invalidVmsForBackupStorageDomain.add(vmBase.getName());
}
});
List<VM> vms = getVmDao().getAllActiveForStorageDomain(storageDomain.getId());
vms.forEach(vmHandler::updateDisksFromDb);
invalidVmsForBackupStorageDomain.addAll(vms.stream().filter(vm -> vm.getDiskMap().values().stream().filter(DisksFilter.ONLY_IMAGES).filter(DisksFilter.ONLY_PLUGGED).map(DiskImage.class::cast).anyMatch(vmDisk -> vmDisk.getStorageIds().get(0).equals(storageDomain.getId()))).map(VM::getName).collect(Collectors.toList()));
if (!invalidVmsForBackupStorageDomain.isEmpty()) {
log.warn("Can't update the backup property of the storage domain since it contains VMs with " + "leases or active disks which are attached to running VMs." + "The following VMs list are: '{}'", invalidVmsForBackupStorageDomain);
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_RUNNING_VM_OR_VM_LEASES_PRESENT_ON_STORAGE_DOMAIN);
}
return ValidationResult.VALID;
}
Aggregations