Gilad Chaplik has uploaded a new change for review. Change subject: core: disk profile commands and queries ......................................................................
core: disk profile commands and queries commands: create/update/delete disk profile queries: GetDiskProfileById, GetAllDiskProfiles, GetDiskProfilesByStorageDomainId. Change-Id: I0d871f1603671bc14ce88c68f85638b1af67f5e1 Signed-off-by: Gilad Chaplik <gchap...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/AddDiskProfileCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileCommandBase.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileValidator.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetAllDiskProfilesQuery.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfileByIdQuery.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfilesByStorageDomainIdQuery.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/RemoveDiskProfileCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/UpdateDiskProfileCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/DiskProfileParameters.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ProfileParametersBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 20 files changed, 475 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/31810/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java index d6d977c..bd48fc0 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java @@ -44,7 +44,8 @@ "org.ovirt.engine.core.bll.provider.network", "org.ovirt.engine.core.bll.qos", "org.ovirt.engine.core.bll.scheduling.commands", - "org.ovirt.engine.core.bll.scheduling.queries" }; + "org.ovirt.engine.core.bll.scheduling.queries", + "org.ovirt.engine.core.bll.profiles" }; private static ConcurrentMap<String, Class<CommandBase<? extends VdcActionParametersBase>>> commandsCache = new ConcurrentHashMap<String, Class<CommandBase<? extends VdcActionParametersBase>>>(VdcActionType.values().length); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/AddDiskProfileCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/AddDiskProfileCommand.java new file mode 100644 index 0000000..10a96b8 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/AddDiskProfileCommand.java @@ -0,0 +1,54 @@ +package org.ovirt.engine.core.bll.profiles; + +import java.util.Collections; +import java.util.List; + +import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.DiskProfileParameters; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.compat.Guid; + +public class AddDiskProfileCommand extends DiskProfileCommandBase { + + public AddDiskProfileCommand(DiskProfileParameters parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + DiskProfileValidator validator = new DiskProfileValidator(getParameters().getProfile()); + return validate(validator.diskProfileIsSet()) + && validate(validator.storageDomainExists()) + && validate(validator.qosExistsOrNull()) + && validate(validator.diskProfileNameNotUsed()); + } + + @Override + protected void executeCommand() { + getParameters().getProfile().setId(Guid.newGuid()); + getDiskProfileDao().save(getParameters().getProfile()); + getReturnValue().setActionReturnValue(getParameters().getProfile().getId()); + setSucceeded(true); + } + + @Override + public List<PermissionSubject> getPermissionCheckSubjects() { + return Collections.singletonList(new PermissionSubject(getParameters().getProfile() != null ? getParameters().getProfile() + .getStorageDomainId() + : null, + VdcObjectType.Storage, getActionType().getActionGroup())); + } + + @Override + protected void setActionMessageParameters() { + super.setActionMessageParameters(); + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__ADD); + } + + @Override + public AuditLogType getAuditLogTypeValue() { + return getSucceeded() ? AuditLogType.USER_ADDED_DISK_PROFILE : AuditLogType.USER_FAILED_TO_ADD_DISK_PROFILE; + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileCommandBase.java new file mode 100644 index 0000000..4806246 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileCommandBase.java @@ -0,0 +1,42 @@ +package org.ovirt.engine.core.bll.profiles; + +import org.ovirt.engine.core.bll.CommandBase; +import org.ovirt.engine.core.common.action.DiskProfileParameters; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dao.profiles.ProfilesDao; + +public abstract class DiskProfileCommandBase extends CommandBase<DiskProfileParameters> { + private DiskProfile profile; + private Guid profileId; + + public DiskProfileCommandBase(DiskProfileParameters parameters) { + super(parameters); + } + + public DiskProfile getProfile() { + if (profile == null) { + if (getParameters().getProfile() != null) { + profile = getParameters().getProfile(); + } else if (getParameters().getProfileId() != null) { + profile = getProfileDao().get(getParameters().getProfileId()); + } + } + return profile; + } + + public Guid getProfileId() { + if (profileId == null) { + if (getParameters().getProfileId() != null) { + profileId = getParameters().getProfileId(); + } else if (getParameters().getProfile() != null) { + profileId = getParameters().getProfile().getId(); + } + } + return profileId; + } + + protected ProfilesDao<DiskProfile> getProfileDao() { + return getDiskProfileDao(); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileValidator.java new file mode 100644 index 0000000..d5a0e80 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/DiskProfileValidator.java @@ -0,0 +1,105 @@ +package org.ovirt.engine.core.bll.profiles; + +import java.util.Collection; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.ovirt.engine.core.bll.ValidationResult; +import org.ovirt.engine.core.bll.validator.StorageDomainValidator; +import org.ovirt.engine.core.common.businessentities.Nameable; +import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; +import org.ovirt.engine.core.utils.ReplacementUtils; + +public class DiskProfileValidator { + + private final DiskProfile diskProfile; + private DiskProfile diskProfileFromDb; + private StorageDomain storageDomain; + private List<DiskProfile> diskProfiles; + + public DiskProfileValidator(DiskProfile diskProfile) { + this.diskProfile = diskProfile; + } + + protected DbFacade getDbFacade() { + return DbFacade.getInstance(); + } + + public ValidationResult diskProfileIsSet() { + return diskProfile == null + ? new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_PROFILE_NOT_EXISTS) + : ValidationResult.VALID; + } + + public ValidationResult diskProfileExists() { + return getDiskProfileFromDb() == null + ? new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_PROFILE_NOT_EXISTS) + : ValidationResult.VALID; + } + + public ValidationResult storageDomainExists() { + return new StorageDomainValidator(getStorageDomain()).isDomainExist(); + } + + public ValidationResult qosExistsOrNull() { + return diskProfile.getQosId() == null + || getDbFacade().getStorageQosDao().get(diskProfile.getQosId()) != null + ? ValidationResult.VALID + : new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_QOS_NOT_FOUND); + } + + public ValidationResult diskProfileNameNotUsed() { + for (DiskProfile profile : getDiskProfiles()) { + if (profile.getName().equals(diskProfile.getName()) && !profile.getId().equals(diskProfile.getId())) { + return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_PROFILE_NAME_IN_USE); + } + } + + return ValidationResult.VALID; + } + + public ValidationResult storageDomainNotChanged() { + if (ObjectUtils.equals(diskProfile.getStorageDomainId(), getDiskProfileFromDb().getStorageDomainId())) { + return ValidationResult.VALID; + } + + return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_CHANGE_PROFILE); + } + + protected ValidationResult diskProfileNotUsed(List<? extends Nameable> entities, VdcBllMessages entitiesReplacement) { + if (entities.isEmpty()) { + return ValidationResult.VALID; + } + + Collection<String> replacements = ReplacementUtils.replaceWithNameable("ENTITIES_USING_PROFILE", entities); + replacements.add(entitiesReplacement.name()); + return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_PROFILE_IN_USE, replacements); + } + + protected StorageDomain getStorageDomain() { + if (storageDomain == null) { + storageDomain = getDbFacade().getStorageDomainDao().get(diskProfile.getStorageDomainId()); + } + + return storageDomain; + } + + protected List<DiskProfile> getDiskProfiles() { + if (diskProfiles == null) { + diskProfiles = getDbFacade().getDiskProfileDao().getAllForStorageDomain(diskProfile.getStorageDomainId()); + } + + return diskProfiles; + } + + protected DiskProfile getDiskProfileFromDb() { + if (diskProfileFromDb == null) { + diskProfileFromDb = getDbFacade().getDiskProfileDao().get(diskProfile.getId()); + } + + return diskProfileFromDb; + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetAllDiskProfilesQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetAllDiskProfilesQuery.java new file mode 100644 index 0000000..1076fd4 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetAllDiskProfilesQuery.java @@ -0,0 +1,17 @@ +package org.ovirt.engine.core.bll.profiles; + +import org.ovirt.engine.core.bll.QueriesCommandBase; +import org.ovirt.engine.core.common.queries.VdcQueryParametersBase; + +public class GetAllDiskProfilesQuery extends QueriesCommandBase<VdcQueryParametersBase> { + + public GetAllDiskProfilesQuery(VdcQueryParametersBase parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + getQueryReturnValue().setReturnValue(getDbFacade().getDiskProfileDao().getAll()); + } + +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfileByIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfileByIdQuery.java new file mode 100644 index 0000000..57ba5c6 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfileByIdQuery.java @@ -0,0 +1,17 @@ +package org.ovirt.engine.core.bll.profiles; + +import org.ovirt.engine.core.bll.QueriesCommandBase; +import org.ovirt.engine.core.common.queries.IdQueryParameters; + +public class GetDiskProfileByIdQuery extends QueriesCommandBase<IdQueryParameters> { + + public GetDiskProfileByIdQuery(IdQueryParameters parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + getQueryReturnValue().setReturnValue(getDbFacade().getDiskProfileDao().get(getParameters().getId())); + } + +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfilesByStorageDomainIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfilesByStorageDomainIdQuery.java new file mode 100644 index 0000000..32ef1bd --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/GetDiskProfilesByStorageDomainIdQuery.java @@ -0,0 +1,18 @@ +package org.ovirt.engine.core.bll.profiles; + +import org.ovirt.engine.core.bll.QueriesCommandBase; +import org.ovirt.engine.core.common.queries.IdQueryParameters; + +public class GetDiskProfilesByStorageDomainIdQuery extends QueriesCommandBase<IdQueryParameters> { + + public GetDiskProfilesByStorageDomainIdQuery(IdQueryParameters parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + getQueryReturnValue().setReturnValue(getDbFacade().getDiskProfileDao() + .getAllForStorageDomain(getParameters().getId())); + } + +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/RemoveDiskProfileCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/RemoveDiskProfileCommand.java new file mode 100644 index 0000000..a68b0ea --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/RemoveDiskProfileCommand.java @@ -0,0 +1,48 @@ +package org.ovirt.engine.core.bll.profiles; + +import java.util.Collections; +import java.util.List; + +import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.DiskProfileParameters; +import org.ovirt.engine.core.common.errors.VdcBllMessages; + +public class RemoveDiskProfileCommand extends DiskProfileCommandBase { + + public RemoveDiskProfileCommand(DiskProfileParameters parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + DiskProfileValidator validator = new DiskProfileValidator(getProfile()); + return validate(validator.diskProfileIsSet()) + && validate(validator.diskProfileExists()); + } + + @Override + protected void executeCommand() { + getDbFacade().getDiskProfileDao().remove(getParameters().getProfileId()); + setSucceeded(true); + } + + @Override + public List<PermissionSubject> getPermissionCheckSubjects() { + return Collections.singletonList(new PermissionSubject(getParameters().getProfileId(), + VdcObjectType.DiskProfile, getActionType().getActionGroup())); + } + + @Override + protected void setActionMessageParameters() { + super.setActionMessageParameters(); + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE); + } + + @Override + public AuditLogType getAuditLogTypeValue() { + return getSucceeded() ? AuditLogType.USER_REMOVED_DISK_PROFILE + : AuditLogType.USER_FAILED_TO_REMOVE_DISK_PROFILE; + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/UpdateDiskProfileCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/UpdateDiskProfileCommand.java new file mode 100644 index 0000000..c847146 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/profiles/UpdateDiskProfileCommand.java @@ -0,0 +1,52 @@ +package org.ovirt.engine.core.bll.profiles; + +import java.util.Collections; +import java.util.List; + +import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.DiskProfileParameters; +import org.ovirt.engine.core.common.errors.VdcBllMessages; + +public class UpdateDiskProfileCommand extends DiskProfileCommandBase { + + public UpdateDiskProfileCommand(DiskProfileParameters parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + DiskProfileValidator validator = new DiskProfileValidator(getParameters().getProfile()); + return validate(validator.diskProfileIsSet()) + && validate(validator.diskProfileExists()) + && validate(validator.diskProfileNameNotUsed()) + && validate(validator.storageDomainNotChanged()) + && validate(validator.qosExistsOrNull()); + } + + @Override + protected void executeCommand() { + getDiskProfileDao().update(getParameters().getProfile()); + getReturnValue().setActionReturnValue(getParameters().getProfile().getId()); + setSucceeded(true); + } + + @Override + public List<PermissionSubject> getPermissionCheckSubjects() { + return Collections.singletonList(new PermissionSubject(getParameters().getProfileId(), + VdcObjectType.DiskProfile, getActionType().getActionGroup())); + } + + @Override + protected void setActionMessageParameters() { + super.setActionMessageParameters(); + addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE); + } + + @Override + public AuditLogType getAuditLogTypeValue() { + return getSucceeded() ? AuditLogType.USER_UPDATED_DISK_PROFILE + : AuditLogType.USER_FAILED_TO_UPDATE_DISK_PROFILE; + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java index d60db00..d7552de 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java @@ -24,16 +24,24 @@ private static final long INITIAL_BLOCK_ALLOCATION_SIZE = 1024L * 1024L * 1024L; private static final long EMPTY_QCOW_HEADER_SIZE = 1024L * 1024L; - private StorageDomain storageDomain; + private final StorageDomain storageDomain; public StorageDomainValidator(StorageDomain domain) { storageDomain = domain; } - public ValidationResult isDomainExistAndActive() { + public ValidationResult isDomainExist() { if (storageDomain == null) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST); } + return ValidationResult.VALID; + } + + public ValidationResult isDomainExistAndActive() { + ValidationResult domainExistValidation = isDomainExist(); + if (!ValidationResult.VALID.equals(domainExistValidation)) { + return domainExistValidation; + } if (storageDomain.getStatus() != StorageDomainStatus.Active) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL2, String.format("$%1$s %2$s", "status", storageDomain.getStatus().name())); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index 5c1eb29..9cdb7ab 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -1002,6 +1002,14 @@ USER_UPDATED_QOS(10114), USER_FAILED_TO_UPDATE_QOS(10115, AuditLogSeverity.ERROR), + // Disk Profile + USER_ADDED_DISK_PROFILE(10120), + USER_FAILED_TO_ADD_DISK_PROFILE(10121, AuditLogSeverity.ERROR), + USER_REMOVED_DISK_PROFILE(10122), + USER_FAILED_TO_REMOVE_DISK_PROFILE(10123, AuditLogSeverity.ERROR), + USER_UPDATED_DISK_PROFILE(10124), + USER_FAILED_TO_UPDATE_DISK_PROFILE(10125, AuditLogSeverity.ERROR), + //mom policies USER_UPDATED_MOM_POLICIES(10200), USER_FAILED_TO_UPDATE_MOM_POLICIES(10201, AuditLogSeverity.WARNING), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/DiskProfileParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/DiskProfileParameters.java new file mode 100644 index 0000000..1364f2a --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/DiskProfileParameters.java @@ -0,0 +1,16 @@ +package org.ovirt.engine.core.common.action; + +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.core.compat.Guid; + +public class DiskProfileParameters extends ProfileParametersBase<DiskProfile> { + + private static final long serialVersionUID = 1303388881254823324L; + + public DiskProfileParameters() { + } + + public DiskProfileParameters(DiskProfile diskProfile, Guid diskProfileId) { + super(diskProfile, diskProfileId); + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ProfileParametersBase.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ProfileParametersBase.java new file mode 100644 index 0000000..c0c07f2 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/ProfileParametersBase.java @@ -0,0 +1,41 @@ +package org.ovirt.engine.core.common.action; + +import javax.validation.Valid; + +import org.ovirt.engine.core.common.businessentities.profiles.ProfileBase; +import org.ovirt.engine.core.compat.Guid; + +public class ProfileParametersBase<T extends ProfileBase> extends VdcActionParametersBase { + + private static final long serialVersionUID = 1303387921254823324L; + + public ProfileParametersBase() { + + } + + public ProfileParametersBase(T profile, Guid profileId) { + this.profile = profile; + this.profileId = profileId; + } + + @Valid + private T profile; + private Guid profileId; + + public T getProfile() { + return profile; + } + + public void setProfile(T profile) { + this.profile = profile; + } + + public Guid getProfileId() { + return profileId; + } + + public void setProfileId(Guid profileId) { + this.profileId = profileId; + } + +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index f8bf499..5f03344 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -332,6 +332,10 @@ AddStorageQos(1753, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), UpdateStorageQos(1754, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), RemoveStorageQos(1755, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), + // disk profiles + AddDiskProfile(1760, ActionGroup.CREATE_STORAGE_DISK_PROFILE, false, QuotaDependency.NONE), + UpdateDiskProfile(1761, ActionGroup.CONFIGURE_STORAGE_DISK_PROFILE, false, QuotaDependency.NONE), + RemoveDiskProfile(1762, ActionGroup.DELETE_STORAGE_DISK_PROFILE, false, QuotaDependency.NONE), // External Tasks AddExternalJob(1800, ActionGroup.INJECT_EXTERNAL_TASKS, false, QuotaDependency.NONE), 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 2b2e9b9..44dc03a 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 @@ -1006,6 +1006,12 @@ // CPU QoS features QOS_CPU_SHARES_OUT_OF_RANGE(ErrorType.BAD_PARAMETERS), + // profiles + ACTION_TYPE_FAILED_PROFILE_NOT_EXISTS(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_PROFILE_NAME_IN_USE(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_CANNOT_CHANGE_PROFILE(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_PROFILE_IN_USE(ErrorType.BAD_PARAMETERS), + // Affinity Groups AFFINITY_GROUP_NAME_TOO_LONG(ErrorType.BAD_PARAMETERS), AFFINITY_GROUP_NAME_INVALID(ErrorType.BAD_PARAMETERS), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index a03ed4b..d46e95c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -362,6 +362,12 @@ GetAllDisksPartialDataByVmId(VdcQueryAuthType.User), GetVmTemplateCount, + + //Disk Profiles + GetDiskProfileById, + GetAllDiskProfiles, + GetDiskProfilesByStorageDomainId, + // Default type instead of having to null check Unknown(VdcQueryAuthType.User); diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java index 701c6a6..41d130e 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java @@ -48,6 +48,7 @@ import org.ovirt.engine.core.dao.network.VmNetworkInterfaceDao; import org.ovirt.engine.core.dao.network.VmNicDao; import org.ovirt.engine.core.dao.network.VnicProfileDao; +import org.ovirt.engine.core.dao.profiles.DiskProfileDao; import org.ovirt.engine.core.dao.provider.ProviderDao; import org.ovirt.engine.core.utils.log.Log; import org.ovirt.engine.core.utils.log.LogFactory; @@ -661,6 +662,10 @@ return getDbFacade().getAuditLogDao(); } + public DiskProfileDao getDiskProfileDao() { + return getDbFacade().getDiskProfileDao(); + } + protected DbFacade getDbFacade() { return DbFacade.getInstance(); } 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 0609c9d..f9f04bc 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -1134,6 +1134,12 @@ ACTION_TYPE_FAILED_QOS_NAME_EXIST=Cannot ${action} ${type}. QoS element name already exists. ACTION_TYPE_FAILED_QOS_NOT_FOUND=Cannot ${action} ${type}. QoS element not found. +# profiles +ACTION_TYPE_FAILED_PROFILE_NOT_EXISTS=Cannot ${action} ${type}. Profile not exists. +ACTION_TYPE_FAILED_PROFILE_NAME_IN_USE=Cannot ${action} ${type}. Profile name is in use. +ACTION_TYPE_FAILED_CANNOT_CHANGE_PROFILE=Cannot ${action} ${type}. Cannot change profile. +ACTION_TYPE_FAILED_PROFILE_IN_USE=Cannot ${action} ${type}. Profile is in use. + # cluster policy errors ACTION_TYPE_FAILED_CLUSTER_POLICY_PARAMETERS_INVALID=Cannot ${action} ${type}. Parameters are invalid. ACTION_TYPE_FAILED_CLUSTER_POLICY_DUPLICATE_POLICY_UNIT=Cannot ${action} ${type}. policy unit already exists in Cluster Policy. 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 2e88900..6a242c0 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 @@ -3081,6 +3081,18 @@ @DefaultStringValue("Cannot ${action} ${type}. QoS element not found.") String ACTION_TYPE_FAILED_QOS_NOT_FOUND(); + @DefaultStringValue("Cannot ${action} ${type}. Profile not exists.") + String ACTION_TYPE_FAILED_PROFILE_NOT_EXISTS(); + + @DefaultStringValue("Cannot ${action} ${type}. Profile name is in use.") + String ACTION_TYPE_FAILED_PROFILE_NAME_IN_USE(); + + @DefaultStringValue("Cannot ${action} ${type}. Cannot change profile.") + String ACTION_TYPE_FAILED_CANNOT_CHANGE_PROFILE(); + + @DefaultStringValue("Cannot ${action} ${type}. Profile is in use.") + String ACTION_TYPE_FAILED_PROFILE_IN_USE(); + @DefaultStringValue("Cannot ${action}. New disk size cannot be smaller than the current.") String ACTION_TYPE_FAILED_REQUESTED_DISK_SIZE_IS_TOO_SMALL(); 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 f12e50f..3b183bc 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 @@ -1109,6 +1109,12 @@ ACTION_TYPE_FAILED_QOS_NAME_EXIST=Cannot ${action} ${type}. QoS element name already exists. ACTION_TYPE_FAILED_QOS_NOT_FOUND=Cannot ${action} ${type}. QoS element not found. +# profiles +ACTION_TYPE_FAILED_PROFILE_NOT_EXISTS=Cannot ${action} ${type}. Profile not exists. +ACTION_TYPE_FAILED_PROFILE_NAME_IN_USE=Cannot ${action} ${type}. Profile name is in use. +ACTION_TYPE_FAILED_CANNOT_CHANGE_PROFILE=Cannot ${action} ${type}. Cannot change profile. +ACTION_TYPE_FAILED_PROFILE_IN_USE=Cannot ${action} ${type}. Profile is in use. + # cluster policy errors ACTION_TYPE_FAILED_CLUSTER_POLICY_PARAMETERS_INVALID=Cannot ${action} ${type}. Parameters are invalid. ACTION_TYPE_FAILED_CLUSTER_POLICY_DUPLICATE_POLICY_UNIT=Cannot ${action} ${type}. policy unit already exists in Cluster Policy. -- To view, visit http://gerrit.ovirt.org/31810 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0d871f1603671bc14ce88c68f85638b1af67f5e1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches