Search in sources :

Example 1 with Files

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

the class VmMapper method map.

@Mapping(from = VmPayload.class, to = Payload.class)
public static Payload map(VmPayload entity, Payload template) {
    if (entity.getDeviceType() != null || entity.getFiles().isEmpty()) {
        Payload model = template != null ? template : new Payload();
        if (entity.getDeviceType() != null) {
            org.ovirt.engine.api.model.VmDeviceType deviceType = map(entity.getDeviceType(), null);
            if (deviceType != null) {
                model.setType(deviceType);
            }
        }
        model.setVolumeId(entity.getVolumeId());
        if (entity.getFiles().size() > 0) {
            model.setFiles(new Files());
            for (Map.Entry<String, String> entry : entity.getFiles().entrySet()) {
                File file = new File();
                file.setName(entry.getKey());
                file.setContent(entry.getValue());
                model.getFiles().getFiles().add(file);
            }
        }
        return model;
    }
    return null;
}
Also used : VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) Payload(org.ovirt.engine.api.model.Payload) Files(org.ovirt.engine.api.model.Files) Map(java.util.Map) File(org.ovirt.engine.api.model.File)

Example 2 with Files

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

the class V3PayloadInAdapter method adapt.

@Override
public Payload adapt(V3Payload from) {
    Payload to = new Payload();
    if (from.isSetFiles()) {
        to.setFiles(new Files());
        to.getFiles().getFiles().addAll(adaptIn(from.getFiles().getFiles()));
    }
    to.setType(VmDeviceType.fromValue(from.getType()));
    if (from.isSetVolumeId()) {
        to.setVolumeId(from.getVolumeId());
    }
    return to;
}
Also used : V3Payload(org.ovirt.engine.api.v3.types.V3Payload) Payload(org.ovirt.engine.api.model.Payload) Files(org.ovirt.engine.api.model.Files)

Example 3 with Files

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

the class V3CloudInitInAdapter method adapt.

@Override
public CloudInit adapt(V3CloudInit from) {
    CloudInit to = new CloudInit();
    if (from.isSetAuthorizedKeys()) {
        to.setAuthorizedKeys(new AuthorizedKeys());
        to.getAuthorizedKeys().getAuthorizedKeys().addAll(adaptIn(from.getAuthorizedKeys().getAuthorizedKeys()));
    }
    if (from.isSetFiles()) {
        to.setFiles(new Files());
        to.getFiles().getFiles().addAll(adaptIn(from.getFiles().getFiles()));
    }
    if (from.isSetHost()) {
        to.setHost(adaptIn(from.getHost()));
    }
    if (from.isSetNetworkConfiguration()) {
        to.setNetworkConfiguration(adaptIn(from.getNetworkConfiguration()));
    }
    if (from.isSetRegenerateSshKeys()) {
        to.setRegenerateSshKeys(from.isRegenerateSshKeys());
    }
    if (from.isSetTimezone()) {
        to.setTimezone(from.getTimezone());
    }
    if (from.isSetUsers()) {
        to.setUsers(new Users());
        to.getUsers().getUsers().addAll(adaptIn(from.getUsers().getUsers()));
    }
    return to;
}
Also used : AuthorizedKeys(org.ovirt.engine.api.model.AuthorizedKeys) V3CloudInit(org.ovirt.engine.api.v3.types.V3CloudInit) CloudInit(org.ovirt.engine.api.model.CloudInit) Users(org.ovirt.engine.api.model.Users) Files(org.ovirt.engine.api.model.Files)

Example 4 with Files

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

the class V3FilesInAdapter method adapt.

@Override
public Files adapt(V3Files from) {
    Files to = new Files();
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.getActive());
    }
    if (from.isSetSize()) {
        to.setSize(from.getSize());
    }
    if (from.isSetTotal()) {
        to.setTotal(from.getTotal());
    }
    to.getFiles().addAll(adaptIn(from.getFiles()));
    return to;
}
Also used : V3Files(org.ovirt.engine.api.v3.types.V3Files) Files(org.ovirt.engine.api.model.Files)

Aggregations

Files (org.ovirt.engine.api.model.Files)4 Payload (org.ovirt.engine.api.model.Payload)2 Map (java.util.Map)1 AuthorizedKeys (org.ovirt.engine.api.model.AuthorizedKeys)1 CloudInit (org.ovirt.engine.api.model.CloudInit)1 File (org.ovirt.engine.api.model.File)1 Users (org.ovirt.engine.api.model.Users)1 V3CloudInit (org.ovirt.engine.api.v3.types.V3CloudInit)1 V3Files (org.ovirt.engine.api.v3.types.V3Files)1 V3Payload (org.ovirt.engine.api.v3.types.V3Payload)1 VmPayload (org.ovirt.engine.core.common.businessentities.VmPayload)1