Arik Hadas has uploaded a new change for review. Change subject: userportal: no boot from hard disk for diskless VM ......................................................................
userportal: no boot from hard disk for diskless VM This patch disable the boot from hard disk option, presented in Run Once dialog, for VM that doesn't have bootable disk Change-Id: Ie2752fb8308731c1e922600a81e410a374b0ba38 Bug-Url: https://bugzilla.redhat.com/885994 Signed-off-by: Arik Hadas <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java 4 files changed, 97 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/35/11735/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java index b0dd866..d9999d2 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java @@ -451,6 +451,16 @@ } }); + // Hard disk change handling + bootSequenceModel.getHardDiskOption().getPropertyChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + boolean isEnabled = bootSequenceModel.getHardDiskOption().getIsChangable(); + String itemName = bootSequenceModel.getHardDiskOption().getTitle(); + updateItemAvailability(itemName, isEnabled); + } + }); + // Change boot option handling bootSequenceBox.addChangeHandler(new ChangeHandler() { @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java index 6804efe..752f98e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java @@ -17,6 +17,7 @@ import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VmManagementParametersBase; +import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.MigrationSupport; @@ -34,6 +35,7 @@ import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.businessentities.vm_pools; import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; +import org.ovirt.engine.core.common.queries.GetAllDisksByVmIdParameters; import org.ovirt.engine.core.common.queries.IdQueryParameters; import org.ovirt.engine.core.common.queries.VdcQueryParametersBase; import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; @@ -806,6 +808,8 @@ Frontend.RunQuery(VdcQueryType.GetVmInterfacesByVmId, new IdQueryParameters(vm.getId()), _asyncQuery2); + setIsBootFromHardDiskAllowedForVm(vm); + UICommand tempVar3 = new UICommand("OnRunOnce", this); //$NON-NLS-1$ tempVar3.setTitle(ConstantsManager.getInstance().getConstants().ok()); tempVar3.setIsDefault(true); @@ -816,6 +820,40 @@ model.getCommands().add(tempVar4); } + private void setIsBootFromHardDiskAllowedForVm(VM vm) { + AsyncQuery vmDisksQuery = new AsyncQuery(); + vmDisksQuery.setModel(this); + + vmDisksQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void OnSuccess(Object model, Object returnValue) + { + UserPortalListModel userPortalListModel = (UserPortalListModel) model; + ArrayList<Disk> vmDisks = (ArrayList<Disk>) ((VdcQueryReturnValue) returnValue).getReturnValue(); + + boolean hasBootableDisk = false; + for (Disk disk : vmDisks) { + if (disk.isBoot()) { + hasBootableDisk = true; + break; + } + } + + if (!hasBootableDisk) + { + BootSequenceModel bootSequenceModel = + ((RunOnceModel) userPortalListModel.getWindow()).getBootSequence(); + bootSequenceModel.getHardDiskOption().setIsChangable(false); + bootSequenceModel.getHardDiskOption() + .getChangeProhibitionReasons() + .add("Virtual Machine must have at least one bootable disk defined to boot from hard disk."); //$NON-NLS-1$ + } + } + }; + + Frontend.RunQuery(VdcQueryType.GetAllDisksByVmId, new GetAllDisksByVmIdParameters(vm.getId()), vmDisksQuery); + } + protected void fillIsoList(VM vm) { AsyncQuery getIsoImagesQuery = new AsyncQuery(); getIsoImagesQuery.setModel(this); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java index 9ed144a..4174775 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java @@ -46,6 +46,19 @@ super.setItems(value); } + public EntityModel getHardDiskOption() + { + for (EntityModel a : getItems()) + { + if ((BootSequence) a.getEntity() == BootSequence.C) + { + return a; + } + } + + throw new IndexOutOfBoundsException(); + } + public EntityModel getNetworkOption() { for (EntityModel a : getItems()) diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java index 5a9035b..ffcaf5f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java @@ -1443,6 +1443,42 @@ }; Frontend.RunQuery(VdcQueryType.GetVmInterfacesByVmId, new IdQueryParameters(vm.getId()), _asyncQuery); + + setIsBootFromHardDiskAllowedForVm(vm); + } + + private void setIsBootFromHardDiskAllowedForVm(VM vm) { + AsyncQuery vmDisksQuery = new AsyncQuery(); + vmDisksQuery.setModel(this); + + vmDisksQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void OnSuccess(Object model, Object returnValue) + { + VmListModel userPortalListModel = (VmListModel) model; + ArrayList<Disk> vmDisks = (ArrayList<Disk>) ((VdcQueryReturnValue) returnValue).getReturnValue(); + + boolean hasBootableDisk = false; + for (Disk disk : vmDisks) { + if (disk.isBoot()) { + hasBootableDisk = true; + break; + } + } + + if (!hasBootableDisk) + { + BootSequenceModel bootSequenceModel = + ((RunOnceModel) userPortalListModel.getWindow()).getBootSequence(); + bootSequenceModel.getHardDiskOption().setIsChangable(false); + bootSequenceModel.getHardDiskOption() + .getChangeProhibitionReasons() + .add("Virtual Machine must have at least one bootable disk defined to boot from hard disk."); //$NON-NLS-1$ + } + } + }; + + Frontend.RunQuery(VdcQueryType.GetAllDisksByVmId, new GetAllDisksByVmIdParameters(vm.getId()), vmDisksQuery); } private void RunOnceUpdateDomains() -- To view, visit http://gerrit.ovirt.org/11735 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2752fb8308731c1e922600a81e410a374b0ba38 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
