use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class ChangeVDSClusterCommand method executeCommand.
@Override
protected void executeCommand() {
final Guid targetClusterId = getParameters().getClusterId();
if (getSourceCluster().getId().equals(targetClusterId)) {
setSucceeded(true);
return;
}
// save the new cluster id
TransactionSupport.executeInNewTransaction(() -> {
VdsStatic staticData = getVds().getStaticData();
getCompensationContext().snapshotEntity(staticData);
// of the host is needed to reconfigure the firewall.
if (targetCluster.getFirewallType() != getSourceCluster().getFirewallType()) {
staticData.setReinstallRequired(true);
}
staticData.setClusterId(targetClusterId);
vdsStaticDao.update(staticData);
getCompensationContext().stateChanged();
// remove the server from resource manager and add it back
initializeVds();
return null;
});
if (targetStoragePool != null && (getSourceCluster().getStoragePoolId() == null || !targetStoragePool.getId().equals(getSourceCluster().getStoragePoolId()))) {
VdsActionParameters addVdsSpmIdParams = new VdsActionParameters(getVdsIdRef());
addVdsSpmIdParams.setSessionId(getParameters().getSessionId());
addVdsSpmIdParams.setCompensationEnabled(true);
ActionReturnValue addVdsSpmIdReturn = runInternalAction(ActionType.AddVdsSpmId, addVdsSpmIdParams, cloneContext().withoutLock().withoutExecutionContext());
if (!addVdsSpmIdReturn.getSucceeded()) {
setSucceeded(false);
getReturnValue().setFault(addVdsSpmIdReturn.getFault());
return;
}
}
if (getSourceCluster().supportsGlusterService() && clusterUtils.hasServers(getSourceCluster().getId())) {
if (!glusterHostRemove(getSourceCluster().getId())) {
setSucceeded(false);
return;
}
}
if (getTargetCluster().supportsGlusterService() && clusterUtils.hasMultipleServers(getTargetCluster().getId())) {
if (!glusterHostAdd(getTargetCluster().getId())) {
setSucceeded(false);
return;
}
}
if (getSourceCluster().getStoragePoolId() != null && (targetStoragePool == null || !getSourceCluster().getStoragePoolId().equals(targetStoragePool.getId()))) {
vdsSpmIdMapDao.removeByVdsAndStoragePool(getVds().getId(), getSourceCluster().getStoragePoolId());
}
HostNetworkAttachmentsPersister persister = new HostNetworkAttachmentsPersister(this.networkAttachmentDao, getVdsId(), interfaceDao.getAllInterfacesForVds(getVdsId()), Collections.emptyList(), getTargetClusterNetworks());
persister.persistNetworkAttachments();
if (VDSStatus.PendingApproval != getVds().getStatus()) {
configureNetworks();
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class GetVdsStaticByNameQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
VdsStatic vds = vdsStaticDao.getByVdsName(getParameters().getName());
getQueryReturnValue().setReturnValue(vds);
}
use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class GlusterTasksSyncJob method updateVolumeBricksAndLock.
private void updateVolumeBricksAndLock(Cluster cluster, GlusterAsyncTask task, final GlusterVolumeEntity vol) {
try {
// acquire lock on volume
acquireLock(vol.getId());
// update volume with task id
volumeDao.updateVolumeTask(vol.getId(), task.getTaskId());
if (GlusterTaskType.REMOVE_BRICK == task.getType()) {
// update bricks associated with task id
String[] bricks = task.getTaskParameters().getBricks();
if (bricks != null) {
List<GlusterBrickEntity> brickEntities = new ArrayList<>();
for (String brick : bricks) {
String[] brickParts = brick.split(":", -1);
String hostnameOrIp = brickParts[0];
String brickDir = brickParts[1];
GlusterBrickEntity brickEntity = new GlusterBrickEntity();
VdsStatic server = glusterDBUtils.getServer(cluster.getId(), hostnameOrIp);
if (server == null) {
log.warn("Could not find server '{}' in cluster '{}'", hostnameOrIp, cluster.getId());
} else {
brickEntity.setServerId(server.getId());
brickEntity.setBrickDirectory(brickDir);
brickEntity.setAsyncTask(new GlusterAsyncTask());
brickEntity.getAsyncTask().setTaskId(task.getTaskId());
brickEntities.add(brickEntity);
}
}
brickDao.updateAllBrickTasksByHostIdBrickDirInBatch(brickEntities);
}
}
logTaskStartedFromCLI(cluster, task, vol);
} catch (Exception e) {
log.error("Exception", e);
// Release the lock only if there is any exception,
// otherwise the lock will be released once the task is completed
releaseLock(vol.getId());
throw new EngineException(EngineError.GeneralException, e.getMessage());
}
}
use of org.ovirt.engine.core.common.businessentities.VdsStatic in project ovirt-engine by oVirt.
the class GlusterCommandBase method updateBrickServerAndInterfaceName.
protected boolean updateBrickServerAndInterfaceName(GlusterBrickEntity brick, boolean addValidationMessage) {
VdsStatic server = vdsStaticDao.get(brick.getServerId());
if (server == null || !server.getClusterId().equals(getClusterId())) {
if (addValidationMessage) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_INVALID_BRICK_SERVER_ID);
}
return false;
}
brick.setServerName(server.getHostName());
// engine will get the gluster network, if present
if (brick.getNetworkId() == null) {
Network network = getGlusterNetwork();
if (network != null) {
brick.setNetworkId(network.getId());
brick.setNetworkAddress(getGlusterNetworkAddress(server.getId(), network.getName()));
}
} else {
// network id has been set, update the address
Network network = networkDao.get(brick.getNetworkId());
if (network != null) {
brick.setNetworkAddress(getGlusterNetworkAddress(server.getId(), network.getName()));
}
}
return true;
}
Aggregations