Search in sources :

Example 6 with CustomProperties

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

the class VmMapper method map.

@Mapping(from = String.class, to = CustomProperties.class)
public static CustomProperties map(String entity, CustomProperties template) {
    CustomProperties model = template != null ? template : new CustomProperties();
    if (entity != null) {
        for (String envStr : entity.split(";", -1)) {
            String[] parts = envStr.split("=", 2);
            if (parts.length >= 1) {
                CustomProperty env = new CustomProperty();
                env.setName(parts[0]);
                if (parts.length == 1) {
                    env.setValue(parts[1]);
                }
                model.getCustomProperties().add(env);
            }
        }
    }
    return model;
}
Also used : CustomProperty(org.ovirt.engine.api.model.CustomProperty) CustomProperties(org.ovirt.engine.api.model.CustomProperties)

Example 7 with CustomProperties

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

the class V3CustomPropertiesInAdapter method adapt.

@Override
public CustomProperties adapt(V3CustomProperties from) {
    CustomProperties to = new CustomProperties();
    to.getCustomProperties().addAll(adaptIn(from.getCustomProperty()));
    return to;
}
Also used : CustomProperties(org.ovirt.engine.api.model.CustomProperties) V3CustomProperties(org.ovirt.engine.api.v3.types.V3CustomProperties)

Example 8 with CustomProperties

use of org.ovirt.engine.api.model.CustomProperties 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)

Aggregations

CustomProperties (org.ovirt.engine.api.model.CustomProperties)8 TimeZone (org.ovirt.engine.api.model.TimeZone)3 VnicProfile (org.ovirt.engine.api.model.VnicProfile)2 Bios (org.ovirt.engine.api.model.Bios)1 BootMenu (org.ovirt.engine.api.model.BootMenu)1 Cdroms (org.ovirt.engine.api.model.Cdroms)1 Cluster (org.ovirt.engine.api.model.Cluster)1 CpuProfile (org.ovirt.engine.api.model.CpuProfile)1 CustomProperty (org.ovirt.engine.api.model.CustomProperty)1 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)1 DiskAttachments (org.ovirt.engine.api.model.DiskAttachments)1 Domain (org.ovirt.engine.api.model.Domain)1 Floppies (org.ovirt.engine.api.model.Floppies)1 Icon (org.ovirt.engine.api.model.Icon)1 InstanceType (org.ovirt.engine.api.model.InstanceType)1 KatelloErrata (org.ovirt.engine.api.model.KatelloErrata)1 Network (org.ovirt.engine.api.model.Network)1 NetworkFilter (org.ovirt.engine.api.model.NetworkFilter)1 Nics (org.ovirt.engine.api.model.Nics)1 Payloads (org.ovirt.engine.api.model.Payloads)1