Search in sources :

Example 31 with VdsStatic

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;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic)

Example 32 with VdsStatic

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);
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Before(org.junit.Before)

Example 33 with VdsStatic

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);
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) Network(org.ovirt.engine.core.common.businessentities.network.Network) Guid(org.ovirt.engine.core.compat.Guid)

Example 34 with VdsStatic

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);
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic)

Example 35 with VdsStatic

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;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) Guid(org.ovirt.engine.core.compat.Guid) AffinityRulesUtils(org.ovirt.engine.core.bll.scheduling.arem.AffinityRulesUtils) ArrayList(java.util.ArrayList) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) Map(java.util.Map) AffinityGroupDao(org.ovirt.engine.core.dao.scheduling.AffinityGroupDao) AffinityGroupCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Iterator(java.util.Iterator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Set(java.util.Set) CommandBase(org.ovirt.engine.core.bll.CommandBase) Collectors(java.util.stream.Collectors) VdsStaticDao(org.ovirt.engine.core.dao.VdsStaticDao) Objects(java.util.Objects) List(java.util.List) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) Collections(java.util.Collections) VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Aggregations

VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)49 Test (org.junit.Test)10 Guid (org.ovirt.engine.core.compat.Guid)8 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 Objects (java.util.Objects)3 Before (org.junit.Before)3 HostProviderProxy (org.ovirt.engine.core.bll.host.provider.HostProviderProxy)3 VdsDynamic (org.ovirt.engine.core.common.businessentities.VdsDynamic)3 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 StringUtils (org.apache.commons.lang.StringUtils)2 Host (org.ovirt.engine.api.model.Host)2