Daniel Erez has uploaded a new change for review. Change subject: core,restapi: DirectLUN disk - validate LUN visibilty ......................................................................
core,restapi: DirectLUN disk - validate LUN visibilty Validate LUN visibility on DirectLUN disk creation: * core - Added a validation method to DiskValidator that verifies visibility of a LUN by querying GetDeviceList. - Execute the validation on AddDiskCommand only when a host is specified in parameters. - Added relevant AppError messages. * REST-API - When optional 'host' element is specified within the 'lun_storage' element, pass it to the parameters object. - Updated rsdl yaml accordingly. Change-Id: I339c999ebdfa69b8e2cbe4f55f8fe12e455810e4 Bug-Url: https://bugzilla.redhat.com/1123754 Buf-Url: https://bugzilla.redhat.com/1096217 Signed-off-by: Daniel Erez <de...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmDiskOperationParameterBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDisksResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmDisksResource.java M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 12 files changed, 74 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/31676/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java index ce30b87..20dc1ec 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractDiskVmCommand.java @@ -21,6 +21,7 @@ import org.ovirt.engine.core.common.businessentities.LunDisk; import org.ovirt.engine.core.common.businessentities.StorageServerConnections; import org.ovirt.engine.core.common.businessentities.StorageType; +import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VmDevice; @@ -278,6 +279,12 @@ } @Override + public VDS getVds() { + setVdsId(getParameters().getVdsId()); + return super.getVds(); + } + + @Override public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java index 297260d..166ddda 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java @@ -162,6 +162,10 @@ return false; } + if (getVds() != null && !validate(diskValidator.isLunDiskVisible(lun, getVds()))) { + return false; + } + return true; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java index ce10244..2a1faa2 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskValidator.java @@ -2,19 +2,27 @@ import java.util.List; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.Predicate; +import org.ovirt.engine.core.bll.Backend; import org.ovirt.engine.core.bll.ValidationResult; import org.ovirt.engine.core.bll.utils.VmDeviceUtils; import org.ovirt.engine.core.common.FeatureSupported; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType; import org.ovirt.engine.core.common.businessentities.DiskInterface; +import org.ovirt.engine.core.common.businessentities.LUNs; +import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.interfaces.VDSBrokerFrontend; import org.ovirt.engine.core.common.osinfo.OsRepository; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.utils.SimpleDependecyInjector; +import org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dao.VmDAO; @@ -137,6 +145,37 @@ return ValidationResult.VALID; } + /** + * Determines whether the specified LUN is visible to the specified host. + * + * @param lun the LUN to examine. + * @param vds the host to query from. + * + * @return whether the specified lun is visible. + */ + @SuppressWarnings("unchecked") + public ValidationResult isLunDiskVisible(final LUNs lun, VDS vds) { + GetDeviceListVDSCommandParameters parameters = + new GetDeviceListVDSCommandParameters(vds.getId(), lun.getLunType()); + List<LUNs> luns = (List<LUNs>) getVdsBroker().RunVdsCommand( + VDSCommandType.GetDeviceList, parameters).getReturnValue(); + + // Search LUN in the device list + boolean lunExists = CollectionUtils.exists(luns, new Predicate() { + @Override + public boolean evaluate(Object o) { + return ((LUNs) o).getId().equals(lun.getId()); + } + }); + + return lunExists ? ValidationResult.VALID : + new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_DISK_LUN_NOT_VALID); + } + + protected VDSBrokerFrontend getVdsBroker() { + return Backend.getInstance().getResourceManager(); + } + private static OsRepository getOsRepository() { return SimpleDependecyInjector.getInstance().get(OsRepository.class); } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmDiskOperationParameterBase.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmDiskOperationParameterBase.java index c6d5f20..9a5bdff 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmDiskOperationParameterBase.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmDiskOperationParameterBase.java @@ -12,6 +12,7 @@ @Valid private Disk diskInfo; private Guid snapshotId; + private Guid vdsId; public VmDiskOperationParameterBase() { } @@ -36,4 +37,12 @@ public void setSnapshotId(Guid snapshotId) { this.snapshotId = snapshotId; } + + public Guid getVdsId() { + return vdsId; + } + + public void setVdsId(Guid vdsId) { + this.vdsId = vdsId; + } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index fe7d357..21771a3 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -201,6 +201,7 @@ ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE(ErrorType.CONFLICT), ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE(ErrorType.CONFLICT), ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_DISK_LUN_NOT_VALID(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_UNSUPPORTED_DISK_STORAGE_TYPE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_STORAGE_DOMAIN_UNAVAILABLE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED(ErrorType.BAD_PARAMETERS), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 143dc34..09e733a 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -220,6 +220,7 @@ ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The provided lun is used by another disk. ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The provided lun has no valid lun type. ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} ${type}. The provided lun is missing at least one connection parameter (address/port/iqn). +ACTION_TYPE_FAILED_DISK_LUN_NOT_VALID=Cannot ${action} ${type}. The provided LUN is not visible by the specified host, please check storage server connectivity. ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM migration is in progress ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and destination is the same. ACTION_TYPE_FAILED_INVALID_CUSTOM_PROPERTIES_INVALID_SYNTAX=Cannot ${action} ${type} if custom properties are in invalid format. Please check the input. diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index 75b38b6..62b7096 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -709,6 +709,7 @@ disk.wipe_after_delete: xs:boolean disk.quota.id: xs:string disk.sgio: xs:string + disk.lun_storage.host: xs:string disk.storage_domains.storage_domain--COLLECTION: {storage_domain.id|name: 'xs:string'} description: add a new direct lun disk to the virtual machine, this operation does not require size but needs lun connection details - mandatoryArguments: {disk.id: 'xs:string'} @@ -1206,6 +1207,7 @@ disk.wipe_after_delete: xs:boolean disk.quota.id: xs:string disk.sgio: xs:string + disk.lun_storage.host: xs:string disk.storage_domains.storage_domain--COLLECTION: {storage_domain.id|name: 'xs:string'} description: add a new lun disk to the system, this operation does not require size but requires lun connection details urlparams: {} diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDisksResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDisksResource.java index 9efeaf7..538b6d5 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDisksResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDisksResource.java @@ -43,6 +43,9 @@ params.setStorageDomainId(storageDomainId); } } + if (disk.isSetLunStorage() && disk.getLunStorage().isSetHost()) { + params.setVdsId(getHostId(disk.getLunStorage().getHost())); + } return performCreate(VdcActionType.AddDisk, params, new QueryIdResolver<Guid>(VdcQueryType.GetDiskByDiskId, IdQueryParameters.class)); } diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmDisksResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmDisksResource.java index d21a048..d3db8d9 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmDisksResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmDisksResource.java @@ -150,6 +150,9 @@ if (disk.isSetActive()) { parameters.setPlugDiskToVm(disk.isActive()); } + if (disk.isSetLunStorage() && disk.getLunStorage().isSetHost()) { + parameters.setVdsId(getHostId(disk.getLunStorage().getHost())); + } return parameters; } diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 0bb9ae3..7c3345e 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -598,6 +598,9 @@ @DefaultStringValue("Cannot ${action} ${type}. The provided lun is missing at least one connection parameter (address/port/iqn).") String ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS(); + @DefaultStringValue("Cannot ${action} ${type}. The provided LUN is not visible by the specified host, please check storage server connectivity.") + String ACTION_TYPE_FAILED_DISK_LUN_NOT_VALID(); + @DefaultStringValue("Cannot ${action} ${type}. source and destination is the same.") String ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index dd5db8d..9afd4ac 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -207,6 +207,7 @@ ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The provided lun is used by another disk. ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The provided lun has no valid lun type. ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} ${type}. The provided lun is missing at least one connection parameter (address/port/iqn). +ACTION_TYPE_FAILED_DISK_LUN_NOT_VALID=Cannot ${action} ${type}. The provided LUN is not visible by the specified host, please check storage server connectivity. ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM migration is in progress ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and destination is the same. ACTION_TYPE_FAILED_INVALID_CUSTOM_PROPERTIES_INVALID_SYNTAX=Cannot ${action} ${type} if custom properties are in invalid format. Please check the input. diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 2e2d293..439b0d5 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -217,6 +217,7 @@ ACTION_TYPE_FAILED_OVF_CONFIGURATION_NOT_SUPPORTED=Cannot ${action} ${type}. The OVF configuration could not be parsed. ACTION_TYPE_FAILED_DISK_LUN_HAS_NO_VALID_TYPE=Cannot ${action} ${type}. The provided lun has no valid lun type. ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} ${type}. The provided lun is missing at least one connection parameter (address/port/iqn). +ACTION_TYPE_FAILED_DISK_LUN_NOT_VALID=Cannot ${action} ${type}. The provided LUN is not visible by the specified host, please check storage server connectivity. ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The provided lun is used by another disk. ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM migration is in progress ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and destination is the same. -- To view, visit http://gerrit.ovirt.org/31676 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I339c999ebdfa69b8e2cbe4f55f8fe12e455810e4 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Daniel Erez <de...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches