Search in sources :

Example 6 with StoragePoolIsoMap

use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.

the class JsonObjectSerializationEntitiesTest method data.

@Parameterized.Parameters
public static Object[] data() {
    RandomUtils random = RandomUtils.instance();
    VdsStatic vdsStatic = new VdsStatic(random.nextString(10), random.nextString(10), random.nextInt(), random.nextInt(), random.nextString(10), Guid.newGuid(), Guid.newGuid(), random.nextString(10), random.nextBoolean(), random.nextEnum(VDSType.class), Guid.newGuid());
    return new Object[] { vdsStatic, randomVdsDynamic(), randomVdsStatistics(), new VdsSpmIdMap(Guid.newGuid(), Guid.newGuid(), random.nextInt()), randomStorageDomainStatic(), new StorageDomainDynamic(random.nextInt(), Guid.newGuid(), random.nextInt()), randomStoragePool(), new StoragePoolIsoMap(Guid.newGuid(), Guid.newGuid(), random.nextEnum(StorageDomainStatus.class)), randomRole(), new IdContainerClass<>(new VdsSpmIdMap(Guid.newGuid(), Guid.newGuid(), random.nextInt())), new IdContainerClass<>(Guid.newGuid()) };
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) RandomUtils(org.ovirt.engine.core.utils.RandomUtils) VDSType(org.ovirt.engine.core.common.businessentities.VDSType) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus)

Example 7 with StoragePoolIsoMap

use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.

the class RunVmValidator method validateIsoPath.

protected ValidationResult validateIsoPath(VM vm, String diskPath, String floppyPath, Guid activeIsoDomainId) {
    if (vm.isAutoStartup()) {
        return ValidationResult.VALID;
    }
    if (StringUtils.isEmpty(vm.getIsoPath()) && StringUtils.isEmpty(diskPath) && StringUtils.isEmpty(floppyPath)) {
        return ValidationResult.VALID;
    }
    if (!StringUtils.isEmpty(floppyPath) && activeIsoDomainId == null) {
        return new ValidationResult(EngineMessage.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO);
    }
    String effectiveIsoPath = StringUtils.isEmpty(diskPath) ? vm.getIsoPath() : diskPath;
    if (!StringUtils.isEmpty(effectiveIsoPath)) {
        if (effectiveIsoPath.matches(ValidationUtils.GUID)) {
            BaseDisk disk = diskDao.get(Guid.createGuidFromString(effectiveIsoPath));
            if (disk == null || disk.getContentType() != DiskContentType.ISO) {
                return new ValidationResult(EngineMessage.ERROR_CANNOT_FIND_ISO_IMAGE_PATH);
            }
            Guid domainId = ((DiskImage) disk).getStorageIds().get(0);
            StoragePoolIsoMap spim = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(domainId, vm.getStoragePoolId()));
            if (spim == null || spim.getStatus() != StorageDomainStatus.Active) {
                return new ValidationResult(EngineMessage.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO);
            }
        } else if (activeIsoDomainId == null) {
            return new ValidationResult(EngineMessage.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO);
        } else if (!isRepoImageExists(effectiveIsoPath, activeIsoDomainId, ImageFileType.ISO)) {
            return new ValidationResult(EngineMessage.ERROR_CANNOT_FIND_ISO_IMAGE_PATH);
        }
        return ValidationResult.VALID;
    }
    if (!StringUtils.isEmpty(floppyPath) && !isRepoImageExists(floppyPath, activeIsoDomainId, ImageFileType.Floppy)) {
        return new ValidationResult(EngineMessage.ERROR_CANNOT_FIND_FLOPPY_IMAGE_PATH);
    }
    return ValidationResult.VALID;
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 8 with StoragePoolIsoMap

use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.

the class AddDiskCommandTest method mockStoragePoolIsoMap.

/**
 * Mock a good {@link StoragePoolIsoMap}.
 */
private void mockStoragePoolIsoMap() {
    StoragePoolIsoMap spim = new StoragePoolIsoMap();
    when(storagePoolIsoMapDao.get(any())).thenReturn(spim);
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Example 9 with StoragePoolIsoMap

use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.

the class AttachDiskToVmCommandTest method mockStoragePoolIsoMap.

private void mockStoragePoolIsoMap() {
    StoragePoolIsoMap spim = new StoragePoolIsoMap();
    when(storagePoolIsoMapDao.get(any())).thenReturn(spim);
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Example 10 with StoragePoolIsoMap

use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.

the class UpdateStorageServerConnectionCommandTest method succeedUpdateNFSCommandWithDomain.

@Test
public void succeedUpdateNFSCommandWithDomain() {
    StorageServerConnections newNFSConnection = createNFSConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data2", StorageType.NFS, NfsVersion.V4, 300, 0);
    parameters.setStorageServerConnection(newNFSConnection);
    VDSReturnValue returnValueConnectSuccess = new VDSReturnValue();
    StoragePoolIsoMap map = new StoragePoolIsoMap();
    returnValueConnectSuccess.setSucceeded(true);
    StorageDomain domain = createDomain();
    doReturn(Collections.singletonList(map)).when(command).getStoragePoolIsoMap(domain);
    returnValueConnectSuccess.setReturnValue(domain);
    doReturn(returnValueConnectSuccess).when(command).getStatsForDomain(domain);
    doReturn(true).when(command).connectToStorage();
    List<StorageDomain> domains = Collections.singletonList(domain);
    doReturn(domains).when(command).getStorageDomainsByConnId(newNFSConnection.getId());
    doNothing().when(command).changeStorageDomainStatusInTransaction(StorageDomainStatus.Locked);
    doNothing().when(command).disconnectFromStorage();
    doNothing().when(command).updateStorageDomain(domains);
    command.executeCommand();
    CommandAssertUtils.checkSucceeded(command, true);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Test(org.junit.Test)

Aggregations

StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)40 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15 Guid (org.ovirt.engine.core.compat.Guid)14 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)9 Test (org.junit.Test)8 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)8 ArrayList (java.util.ArrayList)6 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)6 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Pair (org.ovirt.engine.core.common.utils.Pair)4 HashMap (java.util.HashMap)3 List (java.util.List)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 StorageDomainDynamic (org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Event (org.ovirt.engine.core.common.eventqueue.Event)3 EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)3 ConnectStoragePoolVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)3