use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster 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.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class GetClustersAndNetworksByNetworkIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
List<PairQueryable<Cluster, NetworkCluster>> networkClusterPairs = new ArrayList<>();
Network network = networkDao.get(getParameters().getId());
if (network != null && network.getDataCenterId() != null) {
List<Cluster> clusters = clusterDao.getAllForStoragePool(network.getDataCenterId());
List<NetworkCluster> networkClusters = networkClusterDao.getAllForNetwork(getParameters().getId());
final Map<NetworkClusterId, NetworkCluster> networkClustersById = Entities.businessEntitiesById(networkClusters);
for (Cluster cluster : clusters) {
networkClusterPairs.add(new PairQueryable<>(cluster, networkClustersById.get(new NetworkClusterId(cluster.getId(), getParameters().getId()))));
}
}
getQueryReturnValue().setReturnValue(networkClusterPairs);
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkClustersToSetupNetworksParametersTransformerImpl method transform.
@Override
public List<PersistentHostSetupNetworksParameters> transform(Collection<NetworkCluster> attachments, Collection<NetworkCluster> detachments, Collection<NetworkCluster> updates) {
final Map<Guid, List<Network>> attachNetworksByHost = new HashMap<>();
final Map<Guid, Map<String, VdsNetworkInterface>> labelsToNicsByHost = new HashMap<>();
for (NetworkCluster networkCluster : attachments) {
final Network network = networkDao.get(networkCluster.getNetworkId());
final List<VdsNetworkInterface> nics = interfaceDao.getAllInterfacesByLabelForCluster(networkCluster.getClusterId(), network.getLabel());
for (VdsNetworkInterface nic : nics) {
if (!attachNetworksByHost.containsKey(nic.getVdsId())) {
attachNetworksByHost.put(nic.getVdsId(), new ArrayList<>());
labelsToNicsByHost.put(nic.getVdsId(), new HashMap<>());
}
labelsToNicsByHost.get(nic.getVdsId()).put(network.getLabel(), nic);
attachNetworksByHost.get(nic.getVdsId()).add(network);
}
}
Map<Guid, List<Network>> detachNetworksByHost = new HashMap<>();
for (NetworkCluster networkCluster : detachments) {
final Network network = networkDao.get(networkCluster.getNetworkId());
final List<VdsNetworkInterface> nics = interfaceDao.getAllInterfacesByLabelForCluster(networkCluster.getClusterId(), network.getLabel());
for (VdsNetworkInterface nic : nics) {
if (!detachNetworksByHost.containsKey(nic.getVdsId())) {
detachNetworksByHost.put(nic.getVdsId(), new ArrayList<>());
}
detachNetworksByHost.get(nic.getVdsId()).add(network);
}
}
return createSetupNetworksParameters(attachNetworksByHost, labelsToNicsByHost, detachNetworksByHost, getUpdatedNetworksByHost(updates));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class AddBricksToGlusterVolumeCommandTest method getNetworks.
private List<Network> getNetworks() {
List<Network> networks = new ArrayList<>();
Network nw = new Network();
nw.setName(GLUSTER_NW);
NetworkCluster nc = new NetworkCluster();
nc.setGluster(true);
nw.setCluster(nc);
networks.add(nw);
return networks;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class VmInfoBuildUtils method getDisplayNetwork.
public Network getDisplayNetwork(VM vm) {
List<NetworkCluster> all = networkClusterDao.getAllForCluster(vm.getClusterId());
NetworkCluster networkCluster = null;
for (NetworkCluster tempNetworkCluster : all) {
if (tempNetworkCluster.isDisplay()) {
networkCluster = tempNetworkCluster;
break;
}
}
if (networkCluster != null) {
List<Network> allNetworks = networkDao.getAll();
for (Network tempNetwork : allNetworks) {
if (tempNetwork.getId().equals(networkCluster.getNetworkId())) {
return tempNetwork;
}
}
}
return null;
}
Aggregations