public void updateBootableFrom(List<Disk> vmDisks) { getIsBootable().setEntity(true); getIsBootable().setIsChangeable(true); if (getDisk() == null || !getDisk().isDiskSnapshot()) { for (Disk disk : vmDisks) { if (disk.isBoot() && !disk.equals(getDisk())) { getIsBootable().setEntity(false); if (!disk.isDiskSnapshot()) { getIsBootable().setChangeProhibitionReason(constants.onlyOneBootableDisk()); getIsBootable().setIsChangeable(false); break; } } } } if (!getIsNew()) { getIsBootable().setEntity(getDisk().isBoot()); } }
@Override protected void executeVmCommand() { if (getVm().getStatus().isUpOrPaused()) { updateDisksFromDb(); performPlugCommand(getPlugAction(), getDisk(), oldVmDevice); } // At this point disk is already plugged to or unplugged from VM (depends on the command), // so we can update the needed device properties updateDeviceProperties(); // Now after updating 'isPlugged' property of the plugged/unplugged device, its time to // update the boot order for all VM devices. Failure to do that doesn't change the fact that // device is already plugged to or unplugged from VM. if (disk.isBoot()) { updateBootOrder(); } getVmStaticDao().incrementDbGeneration(getVm().getId()); setSucceeded(true); }
@Override protected Map<String, Pair<String, String>> getExclusiveLocks() { if (disk == null) { return null; } Map<String, Pair<String, String>> locks = new HashMap<>(); if (!disk.isShareable()) { locks.put( disk.getId().toString(), LockMessagesMatchUtil.makeLockingPair( LockingGroup.DISK, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED)); } if (disk.isBoot()) { locks.put( getParameters().getVmId().toString(), LockMessagesMatchUtil.makeLockingPair( LockingGroup.VM_DISK_BOOT, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED)); } return locks; }