use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class GlusterBrickValidator method canStopOrCommitRemoveBrick.
public ValidationResult canStopOrCommitRemoveBrick(GlusterVolumeEntity volumeEntity, List<GlusterBrickEntity> paramBricks) {
GlusterAsyncTask asyncTask = volumeEntity.getAsyncTask();
if (asyncTask == null || asyncTask.getType() != GlusterTaskType.REMOVE_BRICK) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_INVALID_TASK_TYPE);
}
if (paramBricks.isEmpty()) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_BRICKS_REQUIRED);
}
List<GlusterBrickEntity> bricksForTask = getGlusterBrickDao().getGlusterVolumeBricksByTaskId(asyncTask.getTaskId());
if (paramBricks.size() != bricksForTask.size() || !areBricksInTheList(volumeEntity, paramBricks, bricksForTask)) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_PARAMS_INVALID, String.format("$validBricks [%s]", getValidBrickNames(bricksForTask)));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class NetworkAttachmentIpConfigurationValidator method validateIpv6Configuration.
private ValidationResult validateIpv6Configuration(NetworkAttachment networkAttachment) {
final IpConfiguration ipConfiguration = networkAttachment.getIpConfiguration();
if (!ipConfiguration.hasIpv6PrimaryAddressSet()) {
return ValidationResult.VALID;
}
IpV6Address ipv6Address = ipConfiguration.getIpv6PrimaryAddress();
String networkName = networkAttachment.getNetworkName();
String nicName = networkAttachment.getNicName();
if (ipv6Address.getBootProtocol() == null) {
return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_MISSING_BOOT_PROTOCOL, networkName, nicName);
}
Ipv6BootProtocol bootProtocol = ipv6Address.getBootProtocol();
if (bootProtocol == Ipv6BootProtocol.STATIC_IP) {
if (!validStaticIpv6AddressDetails(ipv6Address)) {
return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_STATIC_BOOT_PROTOCOL_MISSING_IP_ADDRESS_DETAILS, networkName, nicName);
}
} else {
if (!isEmptyIpv6AddressDetails(ipv6Address)) {
return new ValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_INCOMPATIBLE_BOOT_PROTOCOL_AND_IP_ADDRESS_DETAILS, ReplacementUtils.createSetVariableString(VAR_NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(VAR_INTERFACE_NAME, nicName), ReplacementUtils.createSetVariableString(VAR_BOOT_PROTOCOL, bootProtocol.getDisplayName()));
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class MultipleVmsValidator method vmNotHavingPluggedDiskSnapshots.
/**
* @return ValidationResult indicating whether there are plugged disk snapshots
*/
public ValidationResult vmNotHavingPluggedDiskSnapshots(EngineMessage message) {
List<String> vmPluggedDiskSnapshotsInfo = null;
for (VM vm : vms) {
List<DiskImage> pluggedDiskSnapshots = DbFacade.getInstance().getDiskImageDao().getAttachedDiskSnapshotsToVm(vm.getId(), Boolean.TRUE);
if (!pluggedDiskSnapshots.isEmpty()) {
if (vmPluggedDiskSnapshotsInfo == null) {
vmPluggedDiskSnapshotsInfo = new LinkedList<>();
}
List<String> pluggedDiskSnapshotAliases = new LinkedList<>();
for (BaseDisk disk : pluggedDiskSnapshots) {
pluggedDiskSnapshotAliases.add(disk.getDiskAlias());
}
vmPluggedDiskSnapshotsInfo.add(String.format("%s / %s", vm.getName(), StringUtils.join(pluggedDiskSnapshotAliases, ",")));
}
}
if (vmPluggedDiskSnapshotsInfo != null) {
return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(vmPluggedDiskSnapshotsInfo, "%n"))));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class NetworkAttachmentValidator method networkExists.
public ValidationResult networkExists() {
Guid networkId = attachment.getNetworkId();
String networkName = attachment.getNetworkName();
// User did not specify neither id nor name.
if (networkId == null && networkName == null) {
return new ValidationResult(EngineMessage.NETWORK_ATTACHMENT_NETWORK_ID_OR_NAME_IS_NOT_SET);
}
// User specified id, for which completors did not find Network record.
if (networkId != null && networkName == null) {
EngineMessage engineMessage = EngineMessage.NETWORK_HAVING_ID_NOT_EXISTS;
return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, networkId.toString()));
}
// User specified name, for which completors did not find Network record.
if (networkId == null && networkName != null) {
EngineMessage engineMessage = EngineMessage.NETWORK_HAVING_NAME_NOT_EXISTS;
return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, networkName));
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class NetworkValidator method qosExistsInDc.
/**
* @return An error iff the QoS entity attached to the network isn't null, but doesn't exist in the database or
* belongs to the wrong DC.
*/
public ValidationResult qosExistsInDc() {
HostNetworkQosValidator qosValidator = new HostNetworkQosValidator(getDbFacade().getHostNetworkQosDao().get(network.getQosId()));
ValidationResult res = qosValidator.qosExists();
return (res == ValidationResult.VALID) ? qosValidator.consistentDataCenter() : res;
}
Aggregations