Search in sources :

Example 16 with Cluster

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

the class BackendGlusterVolumesResourceTest method createModel.

private GlusterVolume createModel() {
    GlusterVolume volume = new GlusterVolume();
    volume.setName("testVol1");
    volume.setCluster(new Cluster());
    volume.getCluster().setId(clusterId.toString());
    volume.setVolumeType(org.ovirt.engine.api.model.GlusterVolumeType.DISTRIBUTE);
    volume.setBricks(new GlusterBricks());
    volume.getBricks().getGlusterBricks().add(createBrick("/export/vol1/brick1"));
    return volume;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) Cluster(org.ovirt.engine.api.model.Cluster)

Example 17 with Cluster

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

the class BackendGlusterVolumesResourceTest method setupListExpectations.

/**
 * The method {@link BackendGlusterVolumesResource#list()} internally
 * invokes {@link ClusterResource#get()} to fetch the cluster object,
 * and then invokes the query including the default constraint on cluster name.
 * This method mocks the cluster resource in such a way that the cluster
 * name will be returned as "Default"
 */
private void setupListExpectations() {
    Cluster cluster = new Cluster();
    cluster.setName(defaultClusterName);
    cluster.setId(clusterId.toString());
    parentMock = mock(ClusterResource.class);
    when(parentMock.get()).thenReturn(cluster);
}
Also used : Cluster(org.ovirt.engine.api.model.Cluster) ClusterResource(org.ovirt.engine.api.resource.ClusterResource)

Example 18 with Cluster

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

the class CpuProfileMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.profiles.CpuProfile.class, to = CpuProfile.class)
public static CpuProfile map(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile entity, CpuProfile template) {
    CpuProfile model = template != null ? template : new CpuProfile();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getClusterId() != null) {
        model.setCluster(new Cluster());
        model.getCluster().setId(entity.getClusterId().toString());
    }
    if (entity.getQosId() != null) {
        model.setQos(new Qos());
        model.getQos().setId(entity.getQosId().toString());
    }
    return model;
}
Also used : Qos(org.ovirt.engine.api.model.Qos) CpuProfile(org.ovirt.engine.api.model.CpuProfile) Cluster(org.ovirt.engine.api.model.Cluster)

Example 19 with Cluster

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

the class AffinityGroupMapper method map.

@Mapping(from = org.ovirt.engine.core.common.scheduling.AffinityGroup.class, to = AffinityGroup.class)
public static AffinityGroup map(org.ovirt.engine.core.common.scheduling.AffinityGroup entity, AffinityGroup template) {
    AffinityGroup model = template != null ? template : new AffinityGroup();
    model.setId(entity.getId().toString());
    model.setName(entity.getName());
    model.setDescription(entity.getDescription());
    // These two fields are maintained to keep the backwards compatibility
    // with version 4 of the API and will be removed in future.
    model.setPositive(entity.isVmAffinityEnabled() ? entity.getVmPolarityBooleanObject() : null);
    model.setEnforcing(entity.isVmEnforcing());
    AffinityRule hostsRule = model.getHostsRule();
    if (hostsRule == null) {
        hostsRule = new AffinityRule();
        model.setHostsRule(hostsRule);
    }
    hostsRule.setEnabled(entity.isVdsAffinityEnabled());
    hostsRule.setEnforcing(entity.isVdsEnforcing());
    hostsRule.setPositive(entity.isVdsPositive());
    AffinityRule vmsRule = model.getVmsRule();
    if (vmsRule == null) {
        vmsRule = new AffinityRule();
        model.setVmsRule(vmsRule);
    }
    vmsRule.setEnabled(entity.isVmAffinityEnabled());
    vmsRule.setEnforcing(entity.isVmEnforcing());
    vmsRule.setPositive(entity.isVmPositive());
    Cluster cluster = new Cluster();
    cluster.setId(entity.getClusterId().toString());
    model.setCluster(cluster);
    Hosts hosts = model.getHosts();
    if (hosts == null) {
        hosts = new Hosts();
        model.setHosts(hosts);
    }
    entity.getVdsIds().stream().map(id -> {
        Host host = new Host();
        host.setId(id.toString());
        return host;
    }).forEach(model.getHosts().getHosts()::add);
    Vms vms = model.getVms();
    if (vms == null) {
        vms = new Vms();
        model.setVms(vms);
    }
    entity.getVmIds().stream().map(id -> {
        Vm vm = new Vm();
        vm.setId(id.toString());
        return vm;
    }).forEach(model.getVms().getVms()::add);
    return model;
}
Also used : AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Hosts(org.ovirt.engine.api.model.Hosts) List(java.util.List) Host(org.ovirt.engine.api.model.Host) Guid(org.ovirt.engine.core.compat.Guid) AffinityRule(org.ovirt.engine.api.model.AffinityRule) EntityAffinityRule(org.ovirt.engine.core.common.scheduling.EntityAffinityRule) Vm(org.ovirt.engine.api.model.Vm) Cluster(org.ovirt.engine.api.model.Cluster) GuidUtils(org.ovirt.engine.api.restapi.utils.GuidUtils) ArrayList(java.util.ArrayList) Vms(org.ovirt.engine.api.model.Vms) Hosts(org.ovirt.engine.api.model.Hosts) AffinityRule(org.ovirt.engine.api.model.AffinityRule) EntityAffinityRule(org.ovirt.engine.core.common.scheduling.EntityAffinityRule) Vm(org.ovirt.engine.api.model.Vm) Cluster(org.ovirt.engine.api.model.Cluster) Host(org.ovirt.engine.api.model.Host) Vms(org.ovirt.engine.api.model.Vms) AffinityGroup(org.ovirt.engine.api.model.AffinityGroup)

Example 20 with Cluster

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

the class BackendGlusterBrickResourceTest method setupParentExpectations.

private void setupParentExpectations() {
    volumeResourceMock = mock(BackendGlusterVolumeResource.class);
    when(bricksResourceMock.getParent()).thenReturn(volumeResourceMock);
    when(volumeResourceMock.getId()).thenReturn(volumeId.toString());
    doAnswer(invocation -> {
        GlusterBrick glusterBrick = (GlusterBrick) invocation.getArguments()[0];
        Cluster cluster = new Cluster();
        cluster.setId(clusterId.toString());
        GlusterVolume volume = new GlusterVolume();
        volume.setId(volumeId.toString());
        volume.setCluster(cluster);
        glusterBrick.setGlusterVolume(volume);
        return glusterBrick;
    }).when(bricksResourceMock).addParents(isA(GlusterBrick.class));
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

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