Search in sources :

Example 1 with File

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

the class FileMapper method map.

@Mapping(from = String.class, to = File.class)
public static File map(String entity, File template) {
    File model = template != null ? template : new File();
    model.setId(entity);
    model.setName(entity);
    return model;
}
Also used : File(org.ovirt.engine.api.model.File)

Example 2 with File

use of org.ovirt.engine.api.model.File 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 3 with File

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

the class BackendVmCdromResourceTest method getCdrom.

private Cdrom getCdrom(String path) {
    Cdrom cdrom = new Cdrom();
    cdrom.setFile(new File());
    cdrom.getFile().setId(path);
    return cdrom;
}
Also used : Cdrom(org.ovirt.engine.api.model.Cdrom) File(org.ovirt.engine.api.model.File)

Example 4 with File

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

the class BackendExternalVmImportsResourceTest method createVmImport.

private ExternalVmImport createVmImport() {
    File file = new File();
    file.setId(DRIVERS_ISO);
    ExternalVmImport vmImport = new ExternalVmImport();
    vmImport.setName(EXTERNAL_VM_NAME);
    vmImport.setVm(new Vm());
    vmImport.getVm().setName(CREATED_VM_NAME);
    vmImport.setCluster(new Cluster());
    vmImport.getCluster().setId(CLUSTER_ID.toString());
    vmImport.setStorageDomain(new StorageDomain());
    vmImport.getStorageDomain().setId(STORAGE_DOMAIN_ID.toString());
    vmImport.setHost(new Host());
    vmImport.getHost().setId(HOST_ID.toString());
    vmImport.setSparse(true);
    vmImport.setProvider(ExternalVmProviderType.VMWARE);
    vmImport.setDriversIso(file);
    vmImport.setUsername(USERNAME);
    vmImport.setPassword(PASSWORD);
    vmImport.setUrl(VMWARE_URL);
    return vmImport;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) ExternalVmImport(org.ovirt.engine.api.model.ExternalVmImport) Vm(org.ovirt.engine.api.model.Vm) Cluster(org.ovirt.engine.api.model.Cluster) Host(org.ovirt.engine.api.model.Host) File(org.ovirt.engine.api.model.File)

Example 5 with File

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

the class LinkHelperTest method testFileLinks.

@Test
public void testFileLinks() throws Exception {
    File file = new File();
    file.setId(FILE_ID);
    file.setStorageDomain(new StorageDomain());
    file.getStorageDomain().setId(STORAGE_DOMAIN_ID);
    LinkHelper.addLinks(file);
    assertEquals(FILE_HREF, file.getHref());
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) File(org.ovirt.engine.api.model.File) Test(org.junit.Test)

Aggregations

File (org.ovirt.engine.api.model.File)11 Cdrom (org.ovirt.engine.api.model.Cdrom)6 Test (org.junit.Test)3 Host (org.ovirt.engine.api.model.Host)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Vm (org.ovirt.engine.api.model.Vm)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Action (org.ovirt.engine.api.model.Action)1 AuthorizedKey (org.ovirt.engine.api.model.AuthorizedKey)1 Cdroms (org.ovirt.engine.api.model.Cdroms)1 Cluster (org.ovirt.engine.api.model.Cluster)1 ExternalVmImport (org.ovirt.engine.api.model.ExternalVmImport)1 Files (org.ovirt.engine.api.model.Files)1 Floppies (org.ovirt.engine.api.model.Floppies)1 Floppy (org.ovirt.engine.api.model.Floppy)1 Nic (org.ovirt.engine.api.model.Nic)1 Payload (org.ovirt.engine.api.model.Payload)1 User (org.ovirt.engine.api.model.User)1