use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class AddBricksToGlusterVolumeCommandTest method getVdsStatic.
private VdsStatic getVdsStatic() {
VdsStatic vds = new VdsStatic();
vds.setId(serverId);
vds.setClusterId(clusterId);
vds.setHostName(serverName);
return vds;
}
use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class LabelDaoTest method setUp.
@Override
@Before
public void setUp() {
Cluster cluster = new Cluster();
cluster.setName("test-cluster");
cluster.setId(Guid.newGuid());
cluster.setCompatibilityVersion(Version.v3_6);
cluster.setArchitecture(ArchitectureType.x86);
cluster.setMacPoolId(FixturesTool.DEFAULT_MAC_POOL_ID);
cluster.setFirewallType(FirewallType.IPTABLES);
clusterDao.save(cluster);
host = new VdsStatic();
host.setId(Guid.newGuid());
host.setName("test-host");
host.setHostName("host-ip");
host.setClusterId(cluster.getId());
vdsDao.save(host);
}
use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class GlusterVolumesListReturn method getBrick.
private GlusterBrickEntity getBrick(Guid clusterId, Guid volumeId, Map<String, Object> brickInfoMap, int brickOrder) {
String brickName = (String) brickInfoMap.get(NAME);
String[] brickParts = brickName.split(":", -1);
if (brickParts.length != 2) {
throw new RuntimeException("Invalid brick representation [" + brickName + "]");
}
String hostUuid = (String) brickInfoMap.get(HOST_UUID);
String brickDir = brickParts[1];
String hostAddress = brickParts[0];
boolean isArbiter = brickInfoMap.containsKey(IS_ARBITER) ? Boolean.valueOf(brickInfoMap.get(IS_ARBITER).toString()) : Boolean.FALSE;
GlusterServer glusterServer = dbUtils.getServerByUuid(Guid.createGuidFromString(hostUuid));
if (glusterServer == null) {
log.warn("Could not add brick '{}' to volume '{}' - server uuid '{}' not found in cluster '{}'", brickName, volumeId, hostUuid, clusterId);
return null;
}
VdsStatic server = DbFacade.getInstance().getVdsStaticDao().get(glusterServer.getId());
String networkAddress = null;
Guid networkId = null;
if (!server.getHostName().equals(hostAddress)) {
networkAddress = hostAddress;
Network network = getGlusterNetworkId(server, networkAddress);
if (network != null) {
networkId = network.getId();
} else {
log.warn("Could not associate brick '{}' of volume '{}' with correct network as no gluster network found in cluster '{}'", brickName, volumeId, clusterId);
}
}
return getBrickEntity(clusterId, volumeId, brickOrder, server, brickDir, networkAddress, networkId, isArbiter);
}
use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class GlusterVolumesListReturn method getBrick.
/**
* Returns a brick object for given cluster and brick representation of the form hostnameOrIp:brickDir
* @param clusterId ID of the Cluster to which the brick belongs
* @param volumeId ID of the Volume to which the brick belongs
* @param brickInfo brick representation of the form hostnameOrIp:brickDir
* @param brickOrder Order number of the brick
* @return The brick object if representation passed is valid
*/
private GlusterBrickEntity getBrick(Guid clusterId, Guid volumeId, String brickInfo, int brickOrder) {
String[] brickParts = brickInfo.split(":", -1);
if (brickParts.length != 2) {
throw new RuntimeException("Invalid brick representation [" + brickInfo + "]");
}
String hostnameOrIp = brickParts[0];
String brickDir = brickParts[1];
VdsStatic server = dbUtils.getServer(clusterId, hostnameOrIp);
if (server == null) {
log.warn("Could not add brick '{}' to volume '{}' - server '{}' not found in cluster '{}'", brickInfo, volumeId, hostnameOrIp, clusterId);
return null;
}
return getBrickEntity(clusterId, volumeId, brickOrder, server, brickDir, null, null, false);
}
use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class AffinityGroupCRUDCommand method validateHosts.
private boolean validateHosts() {
List<Guid> hostIds = getParameters().getAffinityGroup().getVdsIds();
if (hostIds.isEmpty()) {
return true;
}
Map<Guid, VdsStatic> hosts = vdsStaticDao.getByIds(hostIds).stream().collect(Collectors.toMap(VdsStatic::getId, host -> host));
Set<Guid> vdsSet = new HashSet<>();
for (Guid vdsId : hostIds) {
VdsStatic vdsStatic = hosts.get(vdsId);
if (vdsStatic == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_INVALID_ENTITY_FOR_AFFINITY_GROUP, String.format("$entity %s", Entity_VDS));
}
if (!Objects.equals(vdsStatic.getClusterId(), getClusterId())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_ENTITY_NOT_IN_AFFINITY_GROUP_CLUSTER, String.format("$entity %s", Entity_VDS));
}
if (vdsSet.contains(vdsStatic.getId())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_DUPLICATE_ENTITY_IN_AFFINITY_GROUP, String.format("$entity %s", Entity_VDS));
}
vdsSet.add(vdsStatic.getId());
}
return true;
}
Aggregations