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;
}
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);
}
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;
}
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;
}
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));
}
Aggregations