use of org.ovirt.engine.core.bll.network.cluster.helper.DisplayNetworkClusterHelper 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.bll.network.cluster.helper.DisplayNetworkClusterHelper in project ovirt-engine by oVirt.
the class UpdateNetworkOnClusterCommand method executeCommand.
@Override
protected void executeCommand() {
final DisplayNetworkClusterHelper displayNetworkClusterHelper = new DisplayNetworkClusterHelper(networkClusterDao, vmDao, clusterDao, getNetworkCluster(), getNetworkName(), auditLogDirector);
if (displayNetworkClusterHelper.isDisplayToBeUpdated()) {
displayNetworkClusterHelper.warnOnActiveVm();
}
preserveStatus();
networkClusterDao.update(getNetworkCluster());
final Network managementNetwork;
if (getNetworkCluster().isManagement() && !getOldNetworkCluster().isManagement()) {
networkClusterDao.setNetworkExclusivelyAsManagement(getClusterId(), getPersistedNetwork().getId());
managementNetwork = getPersistedNetwork();
} else {
managementNetwork = managementNetworkUtil.getManagementNetwork(getClusterId());
}
if (getNetworkCluster().isDisplay() != getOldNetworkCluster().isDisplay()) {
networkClusterDao.setNetworkExclusivelyAsDisplay(getClusterId(), getNetworkCluster().isDisplay() ? getPersistedNetwork().getId() : managementNetwork.getId());
}
if (getNetworkCluster().isMigration() != getOldNetworkCluster().isMigration()) {
networkClusterDao.setNetworkExclusivelyAsMigration(getClusterId(), getNetworkCluster().isMigration() ? getPersistedNetwork().getId() : managementNetwork.getId());
}
if (getNetworkCluster().isGluster() != getOldNetworkCluster().isGluster()) {
networkClusterDao.setNetworkExclusivelyAsGluster(getClusterId(), getNetworkCluster().isGluster() ? getPersistedNetwork().getId() : null);
}
if (getNetworkCluster().isDefaultRoute() != getOldNetworkCluster().isDefaultRoute()) {
networkClusterDao.setNetworkExclusivelyAsDefaultRoute(getClusterId(), getNetworkCluster().isDefaultRoute() ? getPersistedNetwork().getId() : managementNetwork.getId());
}
networkClusterHelper.setStatus(getClusterId(), getPersistedNetwork());
setSucceeded(true);
}
Aggregations