Search in sources :

Example 1 with RandomUtils

use of org.ovirt.engine.core.utils.RandomUtils in project ovirt-engine by oVirt.

the class OvfManagerTest method createDisksAndDiskVmElements.

private static ArrayList<DiskImage> createDisksAndDiskVmElements(VM vm) {
    ArrayList<DiskImage> disks = new ArrayList<>();
    RandomUtils rnd = RandomUtils.instance();
    for (int i = 0; i < rnd.nextInt(3, 10); i++) {
        DiskImage disk = createVmDisk(vm);
        disks.add(disk);
    }
    return disks;
}
Also used : RandomUtils(org.ovirt.engine.core.utils.RandomUtils) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with RandomUtils

use of org.ovirt.engine.core.utils.RandomUtils in project ovirt-engine by oVirt.

the class OvfManagerTest method initInterfaces.

private static void initInterfaces(VM vm) {
    List<VmNetworkInterface> ifaces = new ArrayList<>();
    RandomUtils rnd = RandomUtils.instance();
    for (int i = 0; i < rnd.nextInt(2, 10); i++) {
        VmNetworkInterface vmInterface = new VmNetworkInterface();
        vmInterface.setStatistics(new VmNetworkStatistics());
        vmInterface.setId(Guid.newGuid());
        vmInterface.setVmId(vm.getId());
        vmInterface.setName(generateRandomName());
        vmInterface.setVnicProfileName(generateRandomName());
        vmInterface.setNetworkName(generateRandomName());
        vmInterface.setLinked(rnd.nextBoolean());
        vmInterface.setSpeed(rnd.nextInt(1000));
        vmInterface.setType(rnd.nextInt(10));
        vmInterface.setMacAddress(rnd.nextMacAddress());
        ifaces.add(vmInterface);
    }
    vm.setInterfaces(ifaces);
}
Also used : RandomUtils(org.ovirt.engine.core.utils.RandomUtils) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) ArrayList(java.util.ArrayList)

Example 3 with RandomUtils

use of org.ovirt.engine.core.utils.RandomUtils in project ovirt-engine by oVirt.

the class JsonObjectSerializationEntitiesTest method randomRole.

private static Role randomRole() {
    RandomUtils random = RandomUtils.instance();
    Role role = new Role();
    role.setDescription(random.nextString(10));
    role.setId(Guid.newGuid());
    role.setName(random.nextString(10));
    return role;
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) RandomUtils(org.ovirt.engine.core.utils.RandomUtils)

Example 4 with RandomUtils

use of org.ovirt.engine.core.utils.RandomUtils 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 5 with RandomUtils

use of org.ovirt.engine.core.utils.RandomUtils in project ovirt-engine by oVirt.

the class OvfManagerTest method createVmDisk.

private static DiskImage createVmDisk(VM vm) {
    RandomUtils rnd = RandomUtils.instance();
    DiskImage disk = new DiskImage();
    disk.setId(Guid.newGuid());
    disk.setVmSnapshotId(Guid.newGuid());
    disk.setSize(rnd.nextLong(1000));
    disk.setActualSize(rnd.nextLong(1000));
    disk.setVolumeFormat(rnd.nextEnum(VolumeFormat.class));
    disk.setVolumeType(rnd.nextEnum(VolumeType.class));
    disk.setWipeAfterDelete(rnd.nextBoolean());
    disk.setDiskAlias(generateRandomName());
    disk.setDescription(generateRandomName());
    disk.setImageId(Guid.newGuid());
    disk.setStoragePoolId(Guid.newGuid());
    disk.setPlugged(true);
    disk.setAppList(rnd.nextPropertyString(100));
    Image image = new Image();
    image.setActive(true);
    image.setVolumeFormat(rnd.nextEnum(VolumeFormat.class));
    image.setId(disk.getImageId());
    image.setSnapshotId(disk.getSnapshotId());
    image.setStatus(ImageStatus.OK);
    disk.setImage(image);
    DiskVmElement diskVmElement = new DiskVmElement(disk.getId(), vm.getId());
    diskVmElement.setBoot(rnd.nextBoolean());
    diskVmElement.setDiskInterface(rnd.nextEnum(DiskInterface.class));
    diskVmElement.setReadOnly(false);
    diskVmElement.setPlugged(true);
    disk.setDiskVmElements(Collections.singletonList(diskVmElement));
    return disk;
}
Also used : VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) RandomUtils(org.ovirt.engine.core.utils.RandomUtils) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Image(org.ovirt.engine.core.common.businessentities.storage.Image) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

RandomUtils (org.ovirt.engine.core.utils.RandomUtils)10 ArrayList (java.util.ArrayList)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 Date (java.util.Date)1 Role (org.ovirt.engine.core.common.businessentities.Role)1 StorageDomainDynamic (org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)1 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)1 StorageDomainStatus (org.ovirt.engine.core.common.businessentities.StorageDomainStatus)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)1 StoragePoolStatus (org.ovirt.engine.core.common.businessentities.StoragePoolStatus)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VDSStatus (org.ovirt.engine.core.common.businessentities.VDSStatus)1 VDSType (org.ovirt.engine.core.common.businessentities.VDSType)1 VdsDynamic (org.ovirt.engine.core.common.businessentities.VdsDynamic)1 VdsSpmIdMap (org.ovirt.engine.core.common.businessentities.VdsSpmIdMap)1 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)1 VdsStatistics (org.ovirt.engine.core.common.businessentities.VdsStatistics)1 VdsTransparentHugePagesState (org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState)1 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)1