Search in sources :

Example 6 with Cluster

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

the class GlusterHookMapper method map.

@Mapping(from = GlusterHookEntity.class, to = GlusterHook.class)
public static GlusterHook map(GlusterHookEntity entity, GlusterHook hook) {
    GlusterHook model = hook != null ? hook : new GlusterHook();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getClusterId() != null) {
        model.setCluster(new Cluster());
        model.getCluster().setId(entity.getClusterId().toString());
    }
    if (entity.getHookKey() != null) {
        model.setName(entity.getHookKey());
    }
    if (entity.getGlusterCommand() != null) {
        model.setGlusterCommand(entity.getGlusterCommand());
    }
    if (entity.getStage() != null) {
        model.setStage(map(entity.getStage(), null));
    }
    if (entity.getStatus() != null) {
        model.setStatus(mapHookStatus(entity.getStatus()));
    }
    if (entity.getContentType() != null) {
        model.setContentType(map(entity.getContentType(), null));
    }
    if (entity.getChecksum() != null) {
        model.setChecksum(entity.getChecksum());
    }
    if (entity.getContent() != null) {
        model.setContent(entity.getContent());
    }
    if (entity.getConflictStatus() != null) {
        model.setConflictStatus(entity.getConflictStatus());
        model.setConflicts(mapConflicts(entity));
    }
    if (entity.getServerHooks() != null && !entity.getServerHooks().isEmpty()) {
        model.setServerHooks(new GlusterServerHooks());
        for (GlusterServerHook serverHookEntity : entity.getServerHooks()) {
            model.getServerHooks().getGlusterServerHooks().add(map(serverHookEntity));
        }
    }
    return model;
}
Also used : GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook) Cluster(org.ovirt.engine.api.model.Cluster) GlusterServerHooks(org.ovirt.engine.api.model.GlusterServerHooks) GlusterHook(org.ovirt.engine.api.model.GlusterHook)

Example 7 with Cluster

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

the class VmPoolMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.VmPool.class, to = VmPool.class)
public static VmPool map(org.ovirt.engine.core.common.businessentities.VmPool entity, VmPool template) {
    VmPool model = template != null ? template : new VmPool();
    model.setId(entity.getVmPoolId().toString());
    model.setName(entity.getName());
    model.setDescription(entity.getVmPoolDescription());
    model.setComment(entity.getComment());
    model.setSize(entity.getAssignedVmsCount());
    model.setPrestartedVms(entity.getPrestartedVms());
    if (entity.getClusterId() != null || entity.getClusterName() != null) {
        model.setCluster(new Cluster());
        model.getCluster().setId(entity.getClusterId().toString());
    }
    model.setMaxUserVms(entity.getMaxAssignedVmsPerUser());
    if (StringUtils.isNotBlank(entity.getSpiceProxy())) {
        Display display = new Display();
        display.setProxy(entity.getSpiceProxy());
        model.setDisplay(display);
    }
    model.setType(map(entity.getVmPoolType(), null));
    model.setStateful(entity.isStateful());
    model.setAutoStorageSelect(entity.isAutoStorageSelect());
    return model;
}
Also used : VmPool(org.ovirt.engine.api.model.VmPool) Cluster(org.ovirt.engine.api.model.Cluster) Display(org.ovirt.engine.api.model.Display)

Example 8 with Cluster

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

the class BrickStatisticalQuery method clone.

private GlusterBrick clone(GlusterBrick brick) {
    // Needed to avoid NPE in LinkHelper due to unsetting of grandparent in LinkHelper#addLinks.
    GlusterBrick cloned = new GlusterBrick();
    cloned.setId(brick.getId());
    cloned.setGlusterVolume(new GlusterVolume());
    cloned.getGlusterVolume().setId(brick.getGlusterVolume().getId());
    cloned.getGlusterVolume().setCluster(new Cluster());
    cloned.getGlusterVolume().getCluster().setId(brick.getGlusterVolume().getCluster().getId());
    return cloned;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 9 with Cluster

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

the class AbstractBackendCpuProfilesResourceTest method testAddCpuProfile.

@Test
public void testAddCpuProfile() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpClusterQueryExpectations();
    setUpCreationExpectations(ActionType.AddCpuProfile, CpuProfileParameters.class, new String[] {}, new Object[] {}, true, true, GUIDS[0], QueryType.GetCpuProfileById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { Guid.Empty }, getEntity(0));
    CpuProfile model = getModel(0);
    model.setCluster(new Cluster());
    model.getCluster().setId(CLUSTER_ID.toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof CpuProfile);
    verifyModel((CpuProfile) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) CpuProfile(org.ovirt.engine.api.model.CpuProfile) Cluster(org.ovirt.engine.api.model.Cluster) Test(org.junit.Test)

Example 10 with Cluster

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

Aggregations

Cluster (org.ovirt.engine.api.model.Cluster)33 Host (org.ovirt.engine.api.model.Host)7 Test (org.junit.Test)6 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)5 CpuProfile (org.ovirt.engine.api.model.CpuProfile)4 Vm (org.ovirt.engine.api.model.Vm)4 VmPool (org.ovirt.engine.api.model.VmPool)4 ClusterResource (org.ovirt.engine.api.resource.ClusterResource)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Response (javax.ws.rs.core.Response)3 DataCenter (org.ovirt.engine.api.model.DataCenter)3 V3Cluster (org.ovirt.engine.api.v3.types.V3Cluster)3 Consumes (javax.ws.rs.Consumes)2 AffinityGroup (org.ovirt.engine.api.model.AffinityGroup)2 Display (org.ovirt.engine.api.model.Display)2 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)2 Quota (org.ovirt.engine.api.model.Quota)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Template (org.ovirt.engine.api.model.Template)2 BackendClusterResource (org.ovirt.engine.api.restapi.resource.BackendClusterResource)2