use of org.ovirt.engine.core.common.businessentities.VmWatchdog in project ovirt-engine by oVirt.
the class TemplateVmModelBehavior method initialize.
@Override
public void initialize() {
super.initialize();
getModel().getTemplateWithVersion().setIsChangeable(false);
getModel().getBaseTemplate().setIsChangeable(false);
getModel().getTemplateWithVersion().setIsChangeable(false);
getModel().getProvisioning().setIsChangeable(false);
getModel().getStorageDomain().setIsChangeable(false);
getModel().getIsSoundcardEnabled().setIsChangeable(true);
getModel().getVmType().setIsChangeable(true);
getModel().getTemplateVersionName().setIsChangeable(!template.isBaseTemplate());
getModel().getName().setIsChangeable(template.isBaseTemplate());
if (template.getStoragePoolId() != null && !template.getStoragePoolId().equals(Guid.Empty)) {
AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> AsyncDataProvider.getInstance().getClusterListByService(new AsyncQuery<>(clusters -> {
ArrayList<Cluster> clustersSupportingVirt = new ArrayList<>();
// filter clusters supporting virt service only
for (Cluster cluster : clusters) {
if (cluster.supportsVirtService()) {
clustersSupportingVirt.add(cluster);
}
}
List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clustersSupportingVirt, template.getClusterArch());
getModel().setDataCentersAndClusters(getModel(), new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter })), filteredClusters, template.getClusterId());
updateRngDevice(template.getId());
AsyncDataProvider.getInstance().isSoundcardEnabled(new AsyncQuery<>(returnValue -> {
getModel().getIsSoundcardEnabled().setEntity(returnValue);
initTemplate();
initCdImage();
}), template.getId());
Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(template.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
AsyncDataProvider.getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), template.getId());
}), true, false)), template.getStoragePoolId());
}
AsyncDataProvider.getInstance().getWatchdogByVmId(new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
UnitVmModel model = getModel();
@SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
for (VmWatchdog watchdog : watchdogs) {
model.getWatchdogAction().setSelectedItem(watchdog.getAction());
model.getWatchdogModel().setSelectedItem(watchdog.getModel());
}
}), template.getId());
getModel().getMigrationMode().setSelectedItem(template.getMigrationSupport());
setupBaseTemplate(template.getBaseTemplateId());
}
use of org.ovirt.engine.core.common.businessentities.VmWatchdog in project ovirt-engine by oVirt.
the class UpdateVmCommand method updateWatchdog.
private void updateWatchdog() {
// do not update if this flag is not set
if (getParameters().isUpdateWatchdog()) {
QueryReturnValue query = runInternalQuery(QueryType.GetWatchdog, new IdQueryParameters(getParameters().getVmId()));
List<VmWatchdog> watchdogs = query.getReturnValue();
if (watchdogs.isEmpty()) {
if (getParameters().getWatchdog() == null) {
// nothing to do, no watchdog and no watchdog to create
} else {
WatchdogParameters parameters = new WatchdogParameters();
parameters.setId(getParameters().getVmId());
parameters.setAction(getParameters().getWatchdog().getAction());
parameters.setModel(getParameters().getWatchdog().getModel());
runInternalAction(ActionType.AddWatchdog, parameters, cloneContextAndDetachFromParent());
}
} else {
WatchdogParameters watchdogParameters = new WatchdogParameters();
watchdogParameters.setId(getParameters().getVmId());
if (getParameters().getWatchdog() == null) {
// there is a watchdog in the vm, there should not be any, so let's delete
runInternalAction(ActionType.RemoveWatchdog, watchdogParameters, cloneContextAndDetachFromParent());
} else {
// there is a watchdog in the vm, we have to update.
watchdogParameters.setAction(getParameters().getWatchdog().getAction());
watchdogParameters.setModel(getParameters().getWatchdog().getModel());
runInternalAction(ActionType.UpdateWatchdog, watchdogParameters, cloneContextAndDetachFromParent());
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.VmWatchdog in project ovirt-engine by oVirt.
the class UpdateVmVersionCommand method buildAddVmParameters.
private AddVmParameters buildAddVmParameters() {
AddVmParameters addVmParams = new AddVmParameters(getParameters().getVmStaticData());
addVmParams.setPoolId(getParameters().getVmPoolId());
addVmParams.setDiskInfoDestinationMap(buildDiskInfoDestinationMap());
addVmParams.setConsoleEnabled(deviceExists(VmDeviceGeneralType.CONSOLE));
addVmParams.setBalloonEnabled(deviceExists(VmDeviceGeneralType.BALLOON, VmDeviceType.MEMBALLOON));
addVmParams.setSoundDeviceEnabled(deviceExists(VmDeviceGeneralType.SOUND));
addVmParams.setVirtioScsiEnabled(deviceExists(VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI));
List<VmWatchdog> watchdogs = runInternalQuery(QueryType.GetWatchdog, new IdQueryParameters(getVmTemplateId())).getReturnValue();
if (!watchdogs.isEmpty()) {
addVmParams.setWatchdog(watchdogs.get(0));
}
loadVmPayload(addVmParams);
// then there is no session, so using the current user.
if (StringUtils.isEmpty(getParameters().getSessionId())) {
addVmParams.setParametersCurrentUser(getCurrentUser());
} else {
addVmParams.setSessionId(getParameters().getSessionId());
}
addVmParams.setDiskOperatorAuthzPrincipalDbId(getParameters().getPreviousDiskOperatorAuthzPrincipalDbId());
// reset vm to not initialized
addVmParams.getVmStaticData().setInitialized(false);
return addVmParams;
}
use of org.ovirt.engine.core.common.businessentities.VmWatchdog in project ovirt-engine by oVirt.
the class ProcessDownVmCommand method createUpdateVmParameters.
private VmManagementParametersBase createUpdateVmParameters() {
// clear non updateable fields got from config
getVm().setExportDate(null);
getVm().setOvfVersion(null);
VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getVm());
updateVmParams.setUpdateWatchdog(true);
updateVmParams.setSoundDeviceEnabled(false);
updateVmParams.setBalloonEnabled(false);
updateVmParams.setVirtioScsiEnabled(false);
updateVmParams.setClearPayload(true);
updateVmParams.setUpdateRngDevice(true);
for (GraphicsType graphicsType : GraphicsType.values()) {
updateVmParams.getGraphicsDevices().put(graphicsType, null);
}
for (VmDevice device : getVm().getManagedVmDeviceMap().values()) {
switch(device.getType()) {
case WATCHDOG:
updateVmParams.setWatchdog(new VmWatchdog(device));
break;
case SOUND:
updateVmParams.setSoundDeviceEnabled(true);
break;
case BALLOON:
updateVmParams.setBalloonEnabled(true);
break;
case CONTROLLER:
if (VmDeviceType.VIRTIOSCSI.getName().equals(device.getDevice())) {
updateVmParams.setVirtioScsiEnabled(true);
}
break;
case DISK:
if (VmPayload.isPayload(device.getSpecParams())) {
updateVmParams.setVmPayload(new VmPayload(device));
}
break;
case CONSOLE:
updateVmParams.setConsoleEnabled(true);
break;
case RNG:
updateVmParams.setRngDevice(new VmRngDevice(device));
break;
case GRAPHICS:
updateVmParams.getGraphicsDevices().put(GraphicsType.fromString(device.getDevice()), new GraphicsDevice(device));
break;
default:
}
}
// clear these fields as these are non updatable
getVm().getManagedVmDeviceMap().clear();
getVm().getUnmanagedDeviceList().clear();
return updateVmParams;
}
use of org.ovirt.engine.core.common.businessentities.VmWatchdog in project ovirt-engine by oVirt.
the class WatchdogMapper method map.
@Mapping(from = VmWatchdog.class, to = Watchdog.class)
public static Watchdog map(VmWatchdog entity, Watchdog template) {
Watchdog model = template == null ? new Watchdog() : template;
if (entity.getAction() != null) {
model.setAction(map(entity.getAction()));
}
if (entity.getModel() != null) {
model.setModel(map(entity.getModel()));
}
model.setId(entity.getId().toString());
return model;
}
Aggregations