Search in sources :

Example 1 with StorageType

use of org.ovirt.engine.api.model.StorageType in project ovirt-engine by oVirt.

the class AbstractBackendStorageDomainDisksResource method validateDiskForCreation.

private void validateDiskForCreation(Disk disk) {
    if (DiskResourceUtils.isLunDisk(disk)) {
        // when creating a LUN disk, user must specify type.
        validateParameters(disk.getLunStorage(), 2, "type");
        StorageType storageType = disk.getLunStorage().getType();
        if (storageType != null && storageType == StorageType.ISCSI) {
            validateParameters(disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0), 3, "address", "target", "port", "id");
        }
    } else if (disk.isSetLunStorage() && (!disk.getLunStorage().isSetLogicalUnits() || !disk.getLunStorage().getLogicalUnits().isSetLogicalUnits())) {
        // TODO: Implement nested entity existence validation infra for validateParameters()
        throw new WebFaultException(null, localize(Messages.INCOMPLETE_PARAMS_REASON), localize(Messages.INCOMPLETE_PARAMS_DETAIL_TEMPLATE, "LogicalUnit", "", "add"), Response.Status.BAD_REQUEST);
    } else {
        // Non lun disks require size and format
        validateParameters(disk, 2, "provisionedSize|size", "format");
    }
}
Also used : StorageType(org.ovirt.engine.api.model.StorageType)

Example 2 with StorageType

use of org.ovirt.engine.api.model.StorageType in project ovirt-engine by oVirt.

the class BackendDiskAttachmentsResource method validateDiskForCreation.

protected void validateDiskForCreation(Disk disk) {
    validateParameters(disk);
    if (DiskResourceUtils.isLunDisk(disk)) {
        // when creating a LUN disk, user must specify type.
        validateParameters(disk.getLunStorage(), 4, "type");
        StorageType storageType = disk.getLunStorage().getType();
        if (storageType != null && storageType == StorageType.ISCSI) {
            validateParameters(disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0), 4, "address", "target", "port", "id");
        }
    } else if (disk.isSetLunStorage() && (!disk.getLunStorage().isSetLogicalUnits() || !disk.getLunStorage().getLogicalUnits().isSetLogicalUnits())) {
        // TODO: Implement nested entity existence validation infra for validateParameters()
        throw new WebFaultException(null, localize(Messages.INCOMPLETE_PARAMS_REASON), localize(Messages.INCOMPLETE_PARAMS_DETAIL_TEMPLATE, "LogicalUnit", "", "add"), Response.Status.BAD_REQUEST);
    } else {
        // Non lun disks require size and format
        validateParameters(disk, 4, "provisionedSize|size", "format");
    }
}
Also used : StorageType(org.ovirt.engine.api.model.StorageType)

Example 3 with StorageType

use of org.ovirt.engine.api.model.StorageType in project ovirt-engine by oVirt.

the class StorageDomainMapper method map.

@Mapping(from = StorageDomain.class, to = StorageServerConnections.class)
public static StorageServerConnections map(StorageDomain model, StorageServerConnections template) {
    StorageServerConnections entity = template != null ? template : new StorageServerConnections();
    if (model.isSetStorage() && model.getStorage().isSetType()) {
        HostStorage storage = model.getStorage();
        StorageType storageType = storage.getType();
        if (storageType != null) {
            entity.setStorageType(map(storageType, null));
            switch(storageType) {
                case ISCSI:
                    break;
                case FCP:
                    break;
                case GLANCE:
                    break;
                case NFS:
                    if (storage.isSetAddress() && storage.isSetPath()) {
                        entity.setConnection(storage.getAddress() + ":" + storage.getPath());
                    }
                    if (storage.getNfsRetrans() != null) {
                        entity.setNfsRetrans(storage.getNfsRetrans().shortValue());
                    }
                    if (storage.getNfsTimeo() != null) {
                        entity.setNfsTimeo(storage.getNfsTimeo().shortValue());
                    }
                    if (storage.getNfsVersion() != null) {
                        entity.setNfsVersion(map(storage.getNfsVersion(), null));
                    }
                    if (storage.isSetMountOptions()) {
                        entity.setMountOptions(storage.getMountOptions());
                    }
                    break;
                case LOCALFS:
                    if (storage.isSetPath()) {
                        entity.setConnection(storage.getPath());
                    }
                    break;
                case POSIXFS:
                case GLUSTERFS:
                    if (storage.isSetAddress() && storage.isSetPath()) {
                        entity.setConnection(storage.getAddress() + ":" + storage.getPath());
                    } else if (storage.isSetPath()) {
                        entity.setConnection(storage.getPath());
                    }
                    if (storage.isSetMountOptions()) {
                        entity.setMountOptions(storage.getMountOptions());
                    }
                    if (storage.isSetVfsType()) {
                        entity.setVfsType(storage.getVfsType());
                    }
                default:
                    break;
            }
        }
    }
    return entity;
}
Also used : StorageType(org.ovirt.engine.api.model.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage)

Example 4 with StorageType

use of org.ovirt.engine.api.model.StorageType in project ovirt-engine by oVirt.

the class BackendDisksResource method validateDiskForCreation.

protected void validateDiskForCreation(Disk disk) {
    if (DiskResourceUtils.isLunDisk(disk)) {
        // when creating a LUN disk, user must specify type.
        validateParameters(disk.getLunStorage(), 2, "type");
        StorageType storageType = disk.getLunStorage().getType();
        if (storageType != null && storageType == StorageType.ISCSI) {
            validateParameters(disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0), 3, "address", "target", "port", "id");
        }
    } else if (disk.isSetLunStorage() && (!disk.getLunStorage().isSetLogicalUnits() || !disk.getLunStorage().getLogicalUnits().isSetLogicalUnits())) {
        // TODO: Implement nested entity existence validation infra for validateParameters()
        throw new WebFaultException(null, localize(Messages.INCOMPLETE_PARAMS_REASON), localize(Messages.INCOMPLETE_PARAMS_DETAIL_TEMPLATE, "LogicalUnit", "", "add"), Response.Status.BAD_REQUEST);
    } else {
        // Non lun disks require size and format
        validateParameters(disk, 2, "provisionedSize", "format");
    }
}
Also used : StorageType(org.ovirt.engine.api.model.StorageType)

Aggregations

StorageType (org.ovirt.engine.api.model.StorageType)4 HostStorage (org.ovirt.engine.api.model.HostStorage)1 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)1