Search in sources :

Example 1 with DisplayNetworkClusterHelper

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);
}
Also used : DisplayNetworkClusterHelper(org.ovirt.engine.core.bll.network.cluster.helper.DisplayNetworkClusterHelper) VDS(org.ovirt.engine.core.common.businessentities.VDS) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) HostNetworkAttachmentsPersister(org.ovirt.engine.core.vdsbroker.vdsbroker.HostNetworkAttachmentsPersister)

Example 2 with DisplayNetworkClusterHelper

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);
}
Also used : DisplayNetworkClusterHelper(org.ovirt.engine.core.bll.network.cluster.helper.DisplayNetworkClusterHelper) Network(org.ovirt.engine.core.common.businessentities.network.Network)

Aggregations

DisplayNetworkClusterHelper (org.ovirt.engine.core.bll.network.cluster.helper.DisplayNetworkClusterHelper)2 Network (org.ovirt.engine.core.common.businessentities.network.Network)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)1 HostNetworkAttachmentsPersister (org.ovirt.engine.core.vdsbroker.vdsbroker.HostNetworkAttachmentsPersister)1