Search in sources :

Example 6 with TimeZone

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

the class V3VmOutAdapter method adapt.

@Override
public V3VM adapt(Vm from) {
    V3VM to = new V3VM();
    // Remove the links for "rels" that are new in version 4 of the API:
    if (from.isSetLinks()) {
        List<Link> links = from.getLinks().stream().filter(link -> !RELS_TO_REMOVE.contains(link.getRel())).collect(toList());
        to.getLinks().addAll(adaptOut(links));
    }
    if (from.isSetActions()) {
        to.setActions(adaptOut(from.getActions()));
        // In version 3 of the API the actions related to snapshots used non standard URL segments, with underscores
        // to separate words: preview_snapshot, commit_snapshot and undo_snapshot. In version 4 of the API all the
        // URL segments use the same style for URL segments, without underscores, there are no exceptions. So in
        // order to keep backwards compatibility we need to add the underscores to the action links generated by
        // version 4 of the API.
        to.getActions().getLinks().stream().filter(this::isSnapshotLink).forEach(this::fixSnapshotLink);
    }
    if (from.isSetBios()) {
        to.setBios(adaptOut(from.getBios()));
    }
    if (from.isSetCdroms()) {
        to.setCdroms(new V3CdRoms());
        to.getCdroms().getCdRoms().addAll(adaptOut(from.getCdroms().getCdroms()));
    }
    if (from.isSetCluster()) {
        to.setCluster(adaptOut(from.getCluster()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetConsole()) {
        to.setConsole(adaptOut(from.getConsole()));
    }
    if (from.isSetCpu()) {
        to.setCpu(adaptOut(from.getCpu()));
    }
    if (from.isSetCpuProfile()) {
        to.setCpuProfile(adaptOut(from.getCpuProfile()));
    }
    if (from.isSetCpuShares()) {
        to.setCpuShares(from.getCpuShares());
    }
    if (from.isSetCreationTime()) {
        to.setCreationTime(from.getCreationTime());
    }
    if (from.isSetCustomCpuModel()) {
        to.setCustomCpuModel(from.getCustomCpuModel());
    }
    if (from.isSetCustomEmulatedMachine()) {
        to.setCustomEmulatedMachine(from.getCustomEmulatedMachine());
    }
    if (from.isSetCustomProperties()) {
        to.setCustomProperties(new V3CustomProperties());
        to.getCustomProperties().getCustomProperty().addAll(adaptOut(from.getCustomProperties().getCustomProperties()));
    }
    if (from.isSetDeleteProtected()) {
        to.setDeleteProtected(from.isDeleteProtected());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDiskAttachments()) {
        V3Disks toDisks = new V3Disks();
        for (DiskAttachment fromDiskAttachment : from.getDiskAttachments().getDiskAttachments()) {
            Disk fromDisk = fromDiskAttachment.getDisk();
            if (fromDisk != null) {
                V3Disk toDisk = adaptOut(fromDisk);
                toDisks.getDisks().add(toDisk);
            }
        }
        to.setDisks(toDisks);
    }
    if (from.isSetDisplay()) {
        to.setDisplay(adaptOut(from.getDisplay()));
    }
    if (from.isSetDomain()) {
        to.setDomain(adaptOut(from.getDomain()));
    }
    if (from.isSetExternalHostProvider()) {
        to.setExternalHostProvider(adaptOut(from.getExternalHostProvider()));
    }
    if (from.isSetFloppies()) {
        to.setFloppies(new V3Floppies());
        to.getFloppies().getFloppies().addAll(adaptOut(from.getFloppies().getFloppies()));
    }
    if (from.isSetGuestOperatingSystem()) {
        to.setGuestOperatingSystem(adaptOut(from.getGuestOperatingSystem()));
    }
    if (from.isSetGuestTimeZone()) {
        to.setGuestTimeZone(adaptOut(from.getGuestTimeZone()));
    }
    if (from.isSetHighAvailability()) {
        to.setHighAvailability(adaptOut(from.getHighAvailability()));
    }
    if (from.isSetHost()) {
        to.setHost(adaptOut(from.getHost()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetInitialization()) {
        to.setInitialization(adaptOut(from.getInitialization()));
    }
    if (from.isSetInstanceType()) {
        to.setInstanceType(adaptOut(from.getInstanceType()));
    }
    if (from.isSetIo()) {
        to.setIo(adaptOut(from.getIo()));
    }
    if (from.isSetKatelloErrata()) {
        to.setKatelloErrata(new V3KatelloErrata());
        to.getKatelloErrata().getKatelloErrata().addAll(adaptOut(from.getKatelloErrata().getKatelloErrata()));
    }
    if (from.isSetLargeIcon()) {
        to.setLargeIcon(adaptOut(from.getLargeIcon()));
    }
    if (from.isSetMemory()) {
        to.setMemory(from.getMemory());
    }
    if (from.isSetMemoryPolicy()) {
        to.setMemoryPolicy(adaptOut(from.getMemoryPolicy()));
    }
    if (from.isSetMigration()) {
        to.setMigration(adaptOut(from.getMigration()));
    }
    if (from.isSetMigrationDowntime()) {
        to.setMigrationDowntime(from.getMigrationDowntime());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNextRunConfigurationExists()) {
        to.setNextRunConfigurationExists(from.isNextRunConfigurationExists());
    }
    if (from.isSetNics()) {
        to.setNics(new V3Nics());
        to.getNics().getNics().addAll(adaptOut(from.getNics().getNics()));
    }
    if (from.isSetNumaTuneMode()) {
        to.setNumaTuneMode(from.getNumaTuneMode().value());
    }
    if (from.isSetOrigin()) {
        to.setOrigin(from.getOrigin());
    }
    if (from.isSetOs()) {
        to.setOs(adaptOut(from.getOs()));
    }
    if (from.isSetPayloads()) {
        to.setPayloads(new V3Payloads());
        to.getPayloads().getPayload().addAll(adaptOut(from.getPayloads().getPayloads()));
    }
    if (from.isSetPermissions()) {
        to.setPermissions(new V3Permissions());
        to.getPermissions().getPermissions().addAll(adaptOut(from.getPermissions().getPermissions()));
    }
    if (from.isSetPlacementPolicy()) {
        to.setPlacementPolicy(adaptOut(from.getPlacementPolicy()));
    }
    if (from.isSetQuota()) {
        to.setQuota(adaptOut(from.getQuota()));
    }
    if (from.isSetReportedDevices()) {
        to.setReportedDevices(new V3ReportedDevices());
        to.getReportedDevices().getReportedDevices().addAll(adaptOut(from.getReportedDevices().getReportedDevices()));
    }
    if (from.isSetRngDevice()) {
        to.setRngDevice(adaptOut(from.getRngDevice()));
    }
    if (from.isSetRunOnce()) {
        to.setRunOnce(from.isRunOnce());
    }
    if (from.isSetSerialNumber()) {
        to.setSerialNumber(adaptOut(from.getSerialNumber()));
    }
    if (from.isSetSmallIcon()) {
        to.setSmallIcon(adaptOut(from.getSmallIcon()));
    }
    if (from.isSetSnapshots()) {
        to.setSnapshots(new V3Snapshots());
        to.getSnapshots().getSnapshots().addAll(adaptOut(from.getSnapshots().getSnapshots()));
    }
    if (from.isSetSoundcardEnabled()) {
        to.setSoundcardEnabled(from.isSoundcardEnabled());
    }
    if (from.isSetSso()) {
        to.setSso(adaptOut(from.getSso()));
    }
    if (from.isSetStartPaused()) {
        to.setStartPaused(from.isStartPaused());
    }
    if (from.isSetStartTime()) {
        to.setStartTime(from.getStartTime());
    }
    if (from.isSetStateless()) {
        to.setStateless(from.isStateless());
    }
    if (from.isSetStatistics()) {
        to.setStatistics(new V3Statistics());
        to.getStatistics().getStatistics().addAll(adaptOut(from.getStatistics().getStatistics()));
    }
    if (from.isSetStatus()) {
        V3Status status = to.getStatus();
        if (status == null) {
            status = new V3Status();
            to.setStatus(status);
        }
        status.setState(from.getStatus().value());
    }
    if (from.isSetStatusDetail()) {
        V3Status status = to.getStatus();
        if (status == null) {
            status = new V3Status();
            to.setStatus(status);
        }
        status.setDetail(from.getStatusDetail());
    }
    if (from.isSetStopReason()) {
        to.setStopReason(from.getStopReason());
    }
    if (from.isSetStopTime()) {
        to.setStopTime(from.getStopTime());
    }
    if (from.isSetStorageDomain()) {
        to.setStorageDomain(adaptOut(from.getStorageDomain()));
    }
    if (from.isSetTags()) {
        to.setTags(new V3Tags());
        to.getTags().getTags().addAll(adaptOut(from.getTags().getTags()));
    }
    if (from.isSetTemplate()) {
        to.setTemplate(adaptOut(from.getTemplate()));
    }
    if (from.isSetTimeZone()) {
        to.setTimeZone(adaptOut(from.getTimeZone()));
    }
    if (from.isSetTunnelMigration()) {
        to.setTunnelMigration(from.isTunnelMigration());
    }
    if (from.isSetType()) {
        to.setType(from.getType().value());
    }
    if (from.isSetUsb()) {
        to.setUsb(adaptOut(from.getUsb()));
    }
    if (from.isSetUseLatestTemplateVersion()) {
        to.setUseLatestTemplateVersion(from.isUseLatestTemplateVersion());
    }
    if (from.isSetVirtioScsi()) {
        to.setVirtioScsi(adaptOut(from.getVirtioScsi()));
    }
    if (from.isSetVmPool()) {
        to.setVmPool(adaptOut(from.getVmPool()));
    }
    if (from.isSetWatchdogs()) {
        to.setWatchdogs(new V3WatchDogs());
        to.getWatchdogs().getWatchDogs().addAll(adaptOut(from.getWatchdogs().getWatchdogs()));
    }
    // new structured "time_zone" element containing the name of the time zone and the UTC offset:
    if (from.isSetTimeZone() && !to.isSetTimezone()) {
        TimeZone timeZone = from.getTimeZone();
        if (timeZone.isSetName()) {
            to.setTimezone(timeZone.getName());
        }
    }
    // If the V4 virtual machine has a value for the "fqdn" element, then copy it to the V3 "guest_info" element:
    if (from.isSetFqdn()) {
        V3GuestInfo guestInfo = to.getGuestInfo();
        if (guestInfo == null) {
            guestInfo = new V3GuestInfo();
            to.setGuestInfo(guestInfo);
        }
        guestInfo.setFqdn(from.getFqdn());
    }
    return to;
}
Also used : V3Tags(org.ovirt.engine.api.v3.types.V3Tags) V3Permissions(org.ovirt.engine.api.v3.types.V3Permissions) Vm(org.ovirt.engine.api.model.Vm) V3WatchDogs(org.ovirt.engine.api.v3.types.V3WatchDogs) TimeZone(org.ovirt.engine.api.model.TimeZone) V3CdRoms(org.ovirt.engine.api.v3.types.V3CdRoms) V3VM(org.ovirt.engine.api.v3.types.V3VM) HashSet(java.util.HashSet) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) Disk(org.ovirt.engine.api.model.Disk) V3GuestInfo(org.ovirt.engine.api.v3.types.V3GuestInfo) V3OutAdapters.adaptOut(org.ovirt.engine.api.v3.adapters.V3OutAdapters.adaptOut) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) V3Status(org.ovirt.engine.api.v3.types.V3Status) V3Adapter(org.ovirt.engine.api.v3.V3Adapter) V3Floppies(org.ovirt.engine.api.v3.types.V3Floppies) V3KatelloErrata(org.ovirt.engine.api.v3.types.V3KatelloErrata) V3ReportedDevices(org.ovirt.engine.api.v3.types.V3ReportedDevices) Set(java.util.Set) V3Statistics(org.ovirt.engine.api.v3.types.V3Statistics) V3Snapshots(org.ovirt.engine.api.v3.types.V3Snapshots) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) V3Nics(org.ovirt.engine.api.v3.types.V3Nics) Link(org.ovirt.engine.api.model.Link) V3Disks(org.ovirt.engine.api.v3.types.V3Disks) V3CustomProperties(org.ovirt.engine.api.v3.types.V3CustomProperties) V3Link(org.ovirt.engine.api.v3.types.V3Link) V3Payloads(org.ovirt.engine.api.v3.types.V3Payloads) V3Floppies(org.ovirt.engine.api.v3.types.V3Floppies) V3Tags(org.ovirt.engine.api.v3.types.V3Tags) V3Permissions(org.ovirt.engine.api.v3.types.V3Permissions) V3KatelloErrata(org.ovirt.engine.api.v3.types.V3KatelloErrata) V3Payloads(org.ovirt.engine.api.v3.types.V3Payloads) V3ReportedDevices(org.ovirt.engine.api.v3.types.V3ReportedDevices) V3Statistics(org.ovirt.engine.api.v3.types.V3Statistics) V3WatchDogs(org.ovirt.engine.api.v3.types.V3WatchDogs) TimeZone(org.ovirt.engine.api.model.TimeZone) V3VM(org.ovirt.engine.api.v3.types.V3VM) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) V3CustomProperties(org.ovirt.engine.api.v3.types.V3CustomProperties) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) V3Snapshots(org.ovirt.engine.api.v3.types.V3Snapshots) V3Disks(org.ovirt.engine.api.v3.types.V3Disks) V3Status(org.ovirt.engine.api.v3.types.V3Status) V3GuestInfo(org.ovirt.engine.api.v3.types.V3GuestInfo) V3Nics(org.ovirt.engine.api.v3.types.V3Nics) Disk(org.ovirt.engine.api.model.Disk) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) Link(org.ovirt.engine.api.model.Link) V3Link(org.ovirt.engine.api.v3.types.V3Link) V3CdRoms(org.ovirt.engine.api.v3.types.V3CdRoms)

Example 7 with TimeZone

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

the class VmBaseMapper method mapVmBaseEntityToModel.

/**
 * Common for VM and template
 */
protected static void mapVmBaseEntityToModel(VmBase model, org.ovirt.engine.core.common.businessentities.VmBase entity) {
    mapCommonEntityToModel(model, entity);
    model.setComment(entity.getComment());
    if (entity.getClusterId() != null) {
        Cluster cluster = new Cluster();
        cluster.setId(entity.getClusterId().toString());
        model.setCluster(cluster);
    }
    if (entity.getVmType() != null) {
        model.setType(mapVmType(entity.getVmType()));
    }
    if (entity.getResumeBehavior() != null) {
        model.setStorageErrorResumeBehaviour(mapResumeBehavior(entity.getResumeBehavior()));
    }
    if (entity.getOrigin() != null) {
        model.setOrigin(map(entity.getOrigin(), null));
    }
    model.setBios(new Bios());
    model.getBios().setBootMenu(new BootMenu());
    model.getBios().getBootMenu().setEnabled(entity.isBootMenuEnabled());
    if (entity.getTimeZone() != null) {
        model.setTimeZone(new TimeZone());
        model.getTimeZone().setName(entity.getTimeZone());
    }
    if (entity.getVmInit() != null && entity.getVmInit().getDomain() != null && StringUtils.isNotBlank(entity.getVmInit().getDomain())) {
        Domain domain = new Domain();
        domain.setName(entity.getVmInit().getDomain());
        model.setDomain(domain);
    }
    model.setStateless(entity.isStateless());
    model.setDeleteProtected(entity.isDeleteProtected());
    model.setSso(SsoMapper.map(entity.getSsoMethod(), null));
    model.setTunnelMigration(entity.getTunnelMigration());
    if (entity.getSerialNumberPolicy() != null) {
        model.setSerialNumber(SerialNumberMapper.map(entity, null));
    }
    model.setStartPaused(entity.isRunAndPause());
    if (entity.getCpuProfileId() != null) {
        CpuProfile cpuProfile = new CpuProfile();
        cpuProfile.setId(entity.getCpuProfileId().toString());
        model.setCpuProfile(cpuProfile);
    }
    if (!StringUtils.isEmpty(entity.getCustomProperties())) {
        CustomProperties hooks = new CustomProperties();
        hooks.getCustomProperties().addAll(CustomPropertiesParser.parse(entity.getCustomProperties(), false));
        model.setCustomProperties(hooks);
    }
    model.setCpuShares(entity.getCpuShares());
    if (entity.getLargeIconId() != null) {
        if (!model.isSetLargeIcon()) {
            model.setLargeIcon(new Icon());
        }
        model.getLargeIcon().setId(entity.getLargeIconId().toString());
    }
    if (entity.getSmallIconId() != null) {
        if (!model.isSetSmallIcon()) {
            model.setSmallIcon(new Icon());
        }
        model.getSmallIcon().setId(entity.getSmallIconId().toString());
    }
    if (entity.getQuotaId() != null) {
        Quota quota = new Quota();
        quota.setId(entity.getQuotaId().toString());
        model.setQuota(quota);
    }
    model.setLease(StorageDomainLeaseMapper.map(entity.getLeaseStorageDomainId()));
}
Also used : TimeZone(org.ovirt.engine.api.model.TimeZone) BootMenu(org.ovirt.engine.api.model.BootMenu) Bios(org.ovirt.engine.api.model.Bios) Quota(org.ovirt.engine.api.model.Quota) CpuProfile(org.ovirt.engine.api.model.CpuProfile) Cluster(org.ovirt.engine.api.model.Cluster) Icon(org.ovirt.engine.api.model.Icon) Domain(org.ovirt.engine.api.model.Domain) CustomProperties(org.ovirt.engine.api.model.CustomProperties)

Example 8 with TimeZone

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

the class V3InstanceTypeOutAdapter method adapt.

@Override
public V3InstanceType adapt(InstanceType from) {
    V3InstanceType to = new V3InstanceType();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptOut(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptOut(from.getActions()));
    }
    if (from.isSetBios()) {
        to.setBios(adaptOut(from.getBios()));
    }
    if (from.isSetCluster()) {
        to.setCluster(adaptOut(from.getCluster()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetConsole()) {
        to.setConsole(adaptOut(from.getConsole()));
    }
    if (from.isSetCpu()) {
        to.setCpu(adaptOut(from.getCpu()));
    }
    if (from.isSetCpuProfile()) {
        to.setCpuProfile(adaptOut(from.getCpuProfile()));
    }
    if (from.isSetCpuShares()) {
        to.setCpuShares(from.getCpuShares());
    }
    if (from.isSetCreationTime()) {
        to.setCreationTime(from.getCreationTime());
    }
    if (from.isSetCustomCpuModel()) {
        to.setCustomCpuModel(from.getCustomCpuModel());
    }
    if (from.isSetCustomEmulatedMachine()) {
        to.setCustomEmulatedMachine(from.getCustomEmulatedMachine());
    }
    if (from.isSetCustomProperties()) {
        to.setCustomProperties(new V3CustomProperties());
        to.getCustomProperties().getCustomProperty().addAll(adaptOut(from.getCustomProperties().getCustomProperties()));
    }
    if (from.isSetDeleteProtected()) {
        to.setDeleteProtected(from.isDeleteProtected());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDisplay()) {
        to.setDisplay(adaptOut(from.getDisplay()));
    }
    if (from.isSetDomain()) {
        to.setDomain(adaptOut(from.getDomain()));
    }
    if (from.isSetHighAvailability()) {
        to.setHighAvailability(adaptOut(from.getHighAvailability()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetIo()) {
        to.setIo(adaptOut(from.getIo()));
    }
    if (from.isSetLargeIcon()) {
        to.setLargeIcon(adaptOut(from.getLargeIcon()));
    }
    if (from.isSetMemory()) {
        to.setMemory(from.getMemory());
    }
    if (from.isSetMemoryPolicy()) {
        to.setMemoryPolicy(adaptOut(from.getMemoryPolicy()));
    }
    if (from.isSetMigration()) {
        to.setMigration(adaptOut(from.getMigration()));
    }
    if (from.isSetMigrationDowntime()) {
        to.setMigrationDowntime(from.getMigrationDowntime());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetOrigin()) {
        to.setOrigin(from.getOrigin());
    }
    if (from.isSetOs()) {
        to.setOs(adaptOut(from.getOs()));
    }
    if (from.isSetRngDevice()) {
        to.setRngDevice(adaptOut(from.getRngDevice()));
    }
    if (from.isSetSerialNumber()) {
        to.setSerialNumber(adaptOut(from.getSerialNumber()));
    }
    if (from.isSetSmallIcon()) {
        to.setSmallIcon(adaptOut(from.getSmallIcon()));
    }
    if (from.isSetSoundcardEnabled()) {
        to.setSoundcardEnabled(from.isSoundcardEnabled());
    }
    if (from.isSetSso()) {
        to.setSso(adaptOut(from.getSso()));
    }
    if (from.isSetStartPaused()) {
        to.setStartPaused(from.isStartPaused());
    }
    if (from.isSetStateless()) {
        to.setStateless(from.isStateless());
    }
    if (from.isSetStatus()) {
        V3Status status = new V3Status();
        status.setState(from.getStatus().value());
        to.setStatus(status);
    }
    if (from.isSetStorageDomain()) {
        to.setStorageDomain(adaptOut(from.getStorageDomain()));
    }
    if (from.isSetTimeZone()) {
        to.setTimeZone(adaptOut(from.getTimeZone()));
    }
    if (from.isSetTunnelMigration()) {
        to.setTunnelMigration(from.isTunnelMigration());
    }
    if (from.isSetType()) {
        to.setType(from.getType().value());
    }
    if (from.isSetUsb()) {
        to.setUsb(adaptOut(from.getUsb()));
    }
    if (from.isSetVersion()) {
        to.setVersion(adaptOut(from.getVersion()));
    }
    if (from.isSetVirtioScsi()) {
        to.setVirtioScsi(adaptOut(from.getVirtioScsi()));
    }
    if (from.isSetVm()) {
        to.setVm(adaptOut(from.getVm()));
    }
    // new structured "time_zone" element containing the name of the time zone and the UTC offset:
    if (from.isSetTimeZone() && !to.isSetTimezone()) {
        TimeZone timeZone = from.getTimeZone();
        if (timeZone.isSetName()) {
            to.setTimezone(timeZone.getName());
        }
    }
    return to;
}
Also used : TimeZone(org.ovirt.engine.api.model.TimeZone) V3InstanceType(org.ovirt.engine.api.v3.types.V3InstanceType) V3CustomProperties(org.ovirt.engine.api.v3.types.V3CustomProperties) V3Status(org.ovirt.engine.api.v3.types.V3Status)

Example 9 with TimeZone

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

the class VmMapperTest method postPopulate.

@Override
protected Vm postPopulate(Vm from) {
    from.setType(MappingTestHelper.shuffle(VmType.class));
    from.setStorageErrorResumeBehaviour(MappingTestHelper.shuffle(VmStorageErrorResumeBehaviour.class));
    from.setOrigin(OriginType.VMWARE.name().toLowerCase());
    from.getDisplay().setType(MappingTestHelper.shuffle(DisplayType.class));
    from.getPayloads().getPayloads().get(0).setType(MappingTestHelper.shuffle(VmDeviceType.class));
    List<BootDevice> devices = from.getOs().getBoot().getDevices().getDevices();
    for (int i = 0; i < devices.size(); i++) {
        devices.set(i, MappingTestHelper.shuffle(BootDevice.class));
    }
    while (from.getCpu().getTopology().getSockets() == 0) {
        from.getCpu().getTopology().setSockets(MappingTestHelper.rand(100));
    }
    while (from.getCpu().getTopology().getCores() == 0) {
        from.getCpu().getTopology().setCores(MappingTestHelper.rand(100));
    }
    CpuTune cpuTune = new CpuTune();
    VcpuPin pin = new VcpuPin();
    pin.setVcpu(33);
    pin.setCpuSet("1-4,6");
    VcpuPins pins = new VcpuPins();
    pins.getVcpuPins().add(pin);
    cpuTune.setVcpuPins(pins);
    from.getCpu().setCpuTune(cpuTune);
    from.setTimeZone(new TimeZone());
    from.getTimeZone().setName("Australia/Darwin");
    // VmPlacement - multiple hosts
    from.setPlacementPolicy(createPlacementPolicy(Guid.EVERYONE, Guid.SYSTEM));
    // Guest Nics configurations
    for (NicConfiguration guestNic : from.getInitialization().getNicConfigurations().getNicConfigurations()) {
        guestNic.setBootProtocol(MappingTestHelper.shuffle(BootProtocol.class, BootProtocol.AUTOCONF));
    }
    from.getDisplay().setType(DisplayType.SPICE);
    from.getSerialNumber().setPolicy(SerialNumberPolicy.CUSTOM);
    from.getDisplay().setFileTransferEnabled(true);
    from.getDisplay().setCopyPasteEnabled(true);
    from.getMigration().setAutoConverge(InheritableBoolean.TRUE);
    from.getMigration().setCompressed(InheritableBoolean.TRUE);
    from.getDisplay().setDisconnectAction(DisplayDisconnectAction.LOCK_SCREEN.toString());
    return from;
}
Also used : DisplayType(org.ovirt.engine.api.model.DisplayType) VmDeviceType(org.ovirt.engine.api.model.VmDeviceType) BootDevice(org.ovirt.engine.api.model.BootDevice) NicConfiguration(org.ovirt.engine.api.model.NicConfiguration) VmStorageErrorResumeBehaviour(org.ovirt.engine.api.model.VmStorageErrorResumeBehaviour) VcpuPin(org.ovirt.engine.api.model.VcpuPin) TimeZone(org.ovirt.engine.api.model.TimeZone) VcpuPins(org.ovirt.engine.api.model.VcpuPins) CpuTune(org.ovirt.engine.api.model.CpuTune) VmType(org.ovirt.engine.api.model.VmType) BootProtocol(org.ovirt.engine.api.model.BootProtocol)

Example 10 with TimeZone

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

the class TemplateMapperTest method postPopulate.

@Override
protected Template postPopulate(Template from) {
    from.setType(MappingTestHelper.shuffle(VmType.class));
    from.setStorageErrorResumeBehaviour(MappingTestHelper.shuffle(VmStorageErrorResumeBehaviour.class));
    from.setOrigin(OriginType.VMWARE.name().toLowerCase());
    List<BootDevice> devices = from.getOs().getBoot().getDevices().getDevices();
    for (int i = 0; i < devices.size(); i++) {
        devices.set(i, MappingTestHelper.shuffle(BootDevice.class));
    }
    while (from.getCpu().getTopology().getSockets() == 0) {
        from.getCpu().getTopology().setSockets(MappingTestHelper.rand(100));
    }
    while (from.getCpu().getTopology().getCores() == 0) {
        from.getCpu().getTopology().setCores(MappingTestHelper.rand(100));
    }
    from.setTimeZone(new TimeZone());
    from.getTimeZone().setName("Australia/Darwin");
    from.getSerialNumber().setPolicy(SerialNumberPolicy.CUSTOM);
    from.getMigration().setAutoConverge(InheritableBoolean.TRUE);
    from.getMigration().setCompressed(InheritableBoolean.TRUE);
    from.getDisplay().setDisconnectAction(DisplayDisconnectAction.LOCK_SCREEN.toString());
    for (NicConfiguration nicConfiguration : from.getInitialization().getNicConfigurations().getNicConfigurations()) {
        nicConfiguration.setBootProtocol(MappingTestHelper.shuffle(BootProtocol.class, BootProtocol.AUTOCONF));
    }
    return from;
}
Also used : TimeZone(org.ovirt.engine.api.model.TimeZone) BootDevice(org.ovirt.engine.api.model.BootDevice) VmType(org.ovirt.engine.api.model.VmType) NicConfiguration(org.ovirt.engine.api.model.NicConfiguration) VmStorageErrorResumeBehaviour(org.ovirt.engine.api.model.VmStorageErrorResumeBehaviour) BootProtocol(org.ovirt.engine.api.model.BootProtocol)

Aggregations

TimeZone (org.ovirt.engine.api.model.TimeZone)10 V3Status (org.ovirt.engine.api.v3.types.V3Status)4 CustomProperties (org.ovirt.engine.api.model.CustomProperties)3 Template (org.ovirt.engine.api.model.Template)3 Vm (org.ovirt.engine.api.model.Vm)3 V3CustomProperties (org.ovirt.engine.api.v3.types.V3CustomProperties)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 Collectors.toList (java.util.stream.Collectors.toList)2 BootDevice (org.ovirt.engine.api.model.BootDevice)2 BootProtocol (org.ovirt.engine.api.model.BootProtocol)2 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)2 InstanceType (org.ovirt.engine.api.model.InstanceType)2 Link (org.ovirt.engine.api.model.Link)2 NicConfiguration (org.ovirt.engine.api.model.NicConfiguration)2 VmStorageErrorResumeBehaviour (org.ovirt.engine.api.model.VmStorageErrorResumeBehaviour)2 VmType (org.ovirt.engine.api.model.VmType)2 V3Adapter (org.ovirt.engine.api.v3.V3Adapter)2 V3OutAdapters.adaptOut (org.ovirt.engine.api.v3.adapters.V3OutAdapters.adaptOut)2