use of org.ovirt.engine.core.vdsbroker.vdsbroker.HostNetworkAttachmentsPersister in project ovirt-engine by oVirt.
the class AttachNetworkToClusterInternalCommand method attachNetwork.
private void attachNetwork(Guid clusterId, NetworkCluster networkClusterFromUserRequest, Network network) {
networkClusterDao.save(new NetworkCluster(clusterId, network.getId(), NetworkStatus.OPERATIONAL, false, networkClusterFromUserRequest.isRequired(), false, false, false, false));
List<VDS> hosts = vdsDao.getAllForCluster(clusterId);
List<Network> networksOfCluster = networkDao.getAllForCluster(clusterId);
for (VDS host : hosts) {
HostNetworkAttachmentsPersister persister = new HostNetworkAttachmentsPersister(this.networkAttachmentDao, host.getId(), interfaceDao.getAllInterfacesForVds(host.getId()), Collections.emptyList(), networksOfCluster);
persister.persistNetworkAttachments();
}
if (network.getCluster().isDisplay()) {
final DisplayNetworkClusterHelper displayNetworkClusterHelper = new DisplayNetworkClusterHelper(networkClusterDao, vmDao, clusterDao, networkClusterFromUserRequest, network.getName(), auditLogDirector);
if (displayNetworkClusterHelper.isDisplayToBeUpdated()) {
displayNetworkClusterHelper.warnOnActiveVm();
}
networkClusterDao.setNetworkExclusivelyAsDisplay(clusterId, network.getId());
}
if (network.getCluster().isMigration()) {
networkClusterDao.setNetworkExclusivelyAsMigration(clusterId, network.getId());
}
if (network.getCluster().isGluster()) {
networkClusterDao.setNetworkExclusivelyAsGluster(clusterId, network.getId());
}
if (network.getCluster().isDefaultRoute()) {
networkClusterDao.setNetworkExclusivelyAsDefaultRoute(clusterId, network.getId());
}
networkClusterHelper.setStatus(clusterId, network);
}
use of org.ovirt.engine.core.vdsbroker.vdsbroker.HostNetworkAttachmentsPersister 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);
}
Aggregations