use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.
the class VmBaseListModel method saveNewVm.
private void saveNewVm(final UnitVmModel model) {
if (model.getProgress() != null) {
return;
}
model.startProgress();
VM vm = getcurrentVm();
if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
vm.setId(new Guid(model.getVmId().getEntity()));
}
vm.setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
AddVmParameters parameters = new AddVmParameters(vm);
parameters.setDiskInfoDestinationMap(model.getDisksAllocationModel().getImageToDestinationDomainMap());
parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
parameters.setBalloonEnabled(balloonEnabled(model));
parameters.setCopyTemplatePermissions(model.getCopyPermissions().getEntity());
parameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
parameters.setVmLargeIcon(IconUtils.filterPredefinedIcons(model.getIcon().getEntity().getIcon()));
parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
setVmWatchdogToParams(model, parameters);
setRngDeviceToParams(model, parameters);
if (model.getIsHeadlessModeEnabled().getEntity()) {
parameters.getVmStaticData().setDefaultDisplayType(DisplayType.none);
}
BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
parameters.setVmId(new Guid(model.getVmId().getEntity()));
}
Frontend.getInstance().runAction(model.getProvisioning().getEntity() ? ActionType.AddVmFromTemplate : ActionType.AddVm, parameters, createUnitVmModelNetworkAsyncCallback(vm, model), this);
}
use of org.ovirt.engine.core.common.action.AddVmParameters 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.action.AddVmParameters in project ovirt-engine by oVirt.
the class AddUnmanagedVmsCommand method addExternallyManagedVm.
// Visible for testing
protected void addExternallyManagedVm(VmStatic vmStatic) {
ActionReturnValue returnValue = runInternalAction(ActionType.AddVmFromScratch, new AddVmParameters(vmStatic), createAddExternalVmContext(vmStatic));
if (!returnValue.getSucceeded()) {
log.debug("Failed adding Externally managed VM '{}'", vmStatic.getName());
return;
}
resourceManager.getVmManager(vmStatic.getId()).update(vmStatic);
}
use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.
the class BackendVmsResource method cloneVmFromTemplate.
private Response cloneVmFromTemplate(VmStatic staticVm, Vm vm, VmTemplate template, InstanceType instanceType, Cluster cluster) {
AddVmParameters params = new AddVmParameters(staticVm);
params.setDiskInfoDestinationMap(getDisksToClone(vm.getDiskAttachments(), template.getId()));
params.setVmPayload(getPayload(vm));
addDevicesToParams(params, vm, template, instanceType, staticVm, cluster);
IconHelper.setIconToParams(vm, params);
params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
setupCloneTemplatePermissions(params);
DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
return performCreate(ActionType.AddVmFromTemplate, params, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
use of org.ovirt.engine.core.common.action.AddVmParameters in project ovirt-engine by oVirt.
the class BackendVmsResource method addVm.
protected Response addVm(VmStatic staticVm, Vm vm, Guid storageDomainId, VmTemplate template, InstanceType instanceType, Cluster cluster) {
AddVmParameters params = new AddVmParameters(staticVm);
params.setVmPayload(getPayload(vm));
params.setStorageDomainId(storageDomainId);
params.setDiskInfoDestinationMap(getDisksToClone(vm.getDiskAttachments(), template.getId()));
params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
setupCloneTemplatePermissions(params);
addDevicesToParams(params, vm, template, instanceType, staticVm, cluster);
IconHelper.setIconToParams(vm, params);
DisplayHelper.setGraphicsToParams(vm.getDisplay(), params);
return performCreate(ActionType.AddVm, params, new QueryIdResolver<Guid>(QueryType.GetVmByVmId, IdQueryParameters.class));
}
Aggregations