use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class InstanceTypeListModel method onEditInstanceType.
private void onEditInstanceType() {
UnitVmModel model = (UnitVmModel) getWindow();
if (!model.validateInstanceTypePart()) {
return;
}
VmTemplate instanceType = (VmTemplate) Cloner.clone(selectedItem);
instanceType.setTemplateType(VmEntityType.INSTANCE_TYPE);
buildVmStatic(instanceType);
instanceType.setDescription(model.getDescription().getEntity());
UpdateVmTemplateParameters updateInstanceTypeParameters = new UpdateVmTemplateParameters(instanceType);
updateInstanceTypeParameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
updateInstanceTypeParameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
updateInstanceTypeParameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
updateInstanceTypeParameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
if (model.getIsHeadlessModeEnabled().getEntity()) {
updateInstanceTypeParameters.getVmTemplateData().setDefaultDisplayType(DisplayType.none);
}
setVmWatchdogToParams(model, updateInstanceTypeParameters);
setRngDeviceToParams(model, updateInstanceTypeParameters);
BuilderExecutor.build(model, updateInstanceTypeParameters, new UnitToGraphicsDeviceParamsBuilder());
getWindow().startProgress();
Frontend.getInstance().runAction(ActionType.UpdateVmTemplate, updateInstanceTypeParameters, new UnitVmModelNetworkAsyncCallback(model, addInstanceTypeNetworkManager, instanceType.getId()), this);
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class NetworkTemplateListModel method remove.
private void remove() {
if (getWindow() != null) {
return;
}
List<VmNetworkInterface> vnics = new ArrayList<>();
for (PairQueryable<VmNetworkInterface, VmTemplate> pair : getSelectedItems()) {
vnics.add(pair.getFirst());
}
RemoveVmTemplateInterfaceModel model = new RemoveVmTemplateInterfaceModel(this, vnics, true);
setWindow(model);
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class VnicProfileTemplateListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
IdQueryParameters params = new IdQueryParameters(getEntity().getId());
params.setRefresh(getIsQueryFirstTime());
Frontend.getInstance().runQuery(QueryType.GetTemplatesByVnicProfileId, params, new AsyncQuery<QueryReturnValue>(returnValue -> setItems((Collection<VmTemplate>) returnValue.getReturnValue())));
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class VmInstanceTypeManager method updateNetworkInterfacesByTemplate.
public void updateNetworkInterfacesByTemplate(VmBase vmBase) {
QueryType queryType = (vmBase instanceof VmTemplate) ? QueryType.GetTemplateInterfacesByTemplateId : QueryType.GetVmInterfacesByVmId;
AsyncQuery<QueryReturnValue> query = new AsyncQuery<>(returnValue -> {
if (returnValue == null) {
return;
}
List<VmNetworkInterface> nics = returnValue.getReturnValue();
updateNetworkInterfaces(getNetworkProfileBehavior(), nics);
});
Frontend.getInstance().runQuery(queryType, new IdQueryParameters(vmBase.getId()), query);
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class AddVmCommand method init.
@Override
protected void init() {
super.init();
T parameters = getParameters();
if (parameters.getVmStaticData() != null) {
Guid templateIdToUse = getParameters().getVmStaticData().getVmtGuid();
if (parameters.getVmStaticData().isUseLatestVersion()) {
VmTemplate latest = vmTemplateDao.getTemplateWithLatestVersionInChain(templateIdToUse);
if (latest != null) {
// as it may have different set of disks
if (!templateIdToUse.equals(latest.getId())) {
getParameters().setDiskInfoDestinationMap(new HashMap<>());
}
setVmTemplate(latest);
templateIdToUse = latest.getId();
getParameters().getVmStaticData().setVmtGuid(templateIdToUse);
}
}
setVmTemplateId(templateIdToUse);
// API backward compatibility
if (getVmDeviceUtils().shouldOverrideSoundDevice(getParameters().getVmStaticData(), getEffectiveCompatibilityVersion(), getParameters().isSoundDeviceEnabled())) {
parameters.setSoundDeviceEnabled(true);
}
if (parameters.isConsoleEnabled() == null) {
parameters.setConsoleEnabled(false);
}
vmDevicesSourceId = (getInstanceTypeId() != null) ? getInstanceTypeId() : parameters.getVmStaticData().getVmtGuid();
imageTypeId = parameters.getVmStaticData().getImageTypeId();
vmInterfacesSourceId = parameters.getVmStaticData().getVmtGuid();
vmDisksSource = getVmTemplate();
}
parameters.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId()));
// override values here for validate to run with correct values, has to come before init-disks
if (isCompatibilityVersionSupportedByCluster(getEffectiveCompatibilityVersion())) {
updateVmObject();
}
if (getParameters().getVmStaticData().getDefaultDisplayType() == DisplayType.none && !parameters.isConsoleEnabled()) {
parameters.getVmStaticData().setUsbPolicy(UsbPolicy.DISABLED);
}
initTemplateDisks();
initStoragePoolId();
diskInfoDestinationMap = getParameters().getDiskInfoDestinationMap();
if (diskInfoDestinationMap == null) {
diskInfoDestinationMap = new HashMap<>();
}
vmHandler.updateDefaultTimeZone(parameters.getVmStaticData());
vmHandler.autoSelectResumeBehavior(getParameters().getVmStaticData(), getCluster());
// Fill the migration policy if it was omitted
if (getParameters().getVmStaticData() != null && getParameters().getVmStaticData().getMigrationSupport() == null) {
setDefaultMigrationPolicy();
}
if (vmDisksSource != null) {
parameters.setUseCinderCommandCallback(!vmDisksSource.getDiskTemplateMap().isEmpty());
}
}
Aggregations