use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkClusterDaoTest method testGetAllForNetwork.
/**
* Ensures that the right set is returned for the specified network.
*/
@Test
public void testGetAllForNetwork() {
List<NetworkCluster> result = dao.getAllForNetwork(network.getId());
assertNotNull(result);
assertFalse(result.isEmpty());
for (NetworkCluster cluster : result) {
assertEquals(network.getId(), cluster.getNetworkId());
}
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class AbstractBackendNetworksResourceTest method getEntity.
@Override
protected org.ovirt.engine.core.common.businessentities.network.Network getEntity(int index) {
org.ovirt.engine.core.common.businessentities.network.Network network = new org.ovirt.engine.core.common.businessentities.network.Network();
NetworkCluster networkCluster = new NetworkCluster();
networkCluster.setDisplay(false);
networkCluster.setMigration(false);
networkCluster.setRequired(false);
networkCluster.setDefaultRoute(false);
network.setCluster(networkCluster);
network.setId(GUIDS[index]);
network.setName(NAMES[index]);
network.setDescription(DESCRIPTIONS[index]);
network.setDataCenterId(GUIDS[1]);
return network;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkMapper method map.
@Mapping(from = Network.class, to = org.ovirt.engine.core.common.businessentities.network.Network.class)
public static org.ovirt.engine.core.common.businessentities.network.Network map(Network model, org.ovirt.engine.core.common.businessentities.network.Network template) {
org.ovirt.engine.core.common.businessentities.network.Network entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.network.Network();
entity.setCluster(template != null && template.getCluster() != null ? template.getCluster() : new NetworkCluster());
if (model.isSetId()) {
entity.setId(GuidUtils.asGuid(model.getId()));
}
if (model.isSetName()) {
entity.setName(model.getName());
}
if (model.isSetDescription()) {
entity.setDescription(model.getDescription());
}
if (model.isSetComment()) {
entity.setComment(model.getComment());
}
if (model.isSetDataCenter() && model.getDataCenter().isSetId()) {
entity.setDataCenterId(GuidUtils.asGuid(model.getDataCenter().getId()));
}
if (model.isSetIp()) {
if (model.getIp().isSetAddress()) {
entity.setAddr(model.getIp().getAddress());
}
if (model.getIp().isSetNetmask()) {
entity.setSubnet(model.getIp().getNetmask());
}
if (model.getIp().isSetGateway()) {
entity.setGateway(model.getIp().getGateway());
}
}
if (model.isSetVlan()) {
entity.setVlanId(model.getVlan().getId());
}
if (model.isSetStp()) {
entity.setStp(model.isStp());
}
if (model.isSetDisplay()) {
// for backward compatibility use display tag or usage tag
entity.getCluster().setDisplay(model.isDisplay());
}
if (model.isSetUsages()) {
List<NetworkUsage> networkUsages = new ArrayList<>();
for (NetworkUsage usage : model.getUsages().getUsages()) {
networkUsages.add(usage);
}
entity.getCluster().setDisplay(networkUsages.contains(NetworkUsage.DISPLAY));
entity.getCluster().setMigration(networkUsages.contains(NetworkUsage.MIGRATION));
entity.getCluster().setManagement(networkUsages.contains(NetworkUsage.MANAGEMENT));
entity.getCluster().setGluster(networkUsages.contains(NetworkUsage.GLUSTER));
entity.getCluster().setDefaultRoute(networkUsages.contains(NetworkUsage.DEFAULT_ROUTE));
entity.setVmNetwork(networkUsages.contains(NetworkUsage.VM));
}
if (model.isSetMtu()) {
entity.setMtu(model.getMtu());
}
if (model.isSetRequired()) {
entity.getCluster().setRequired(model.isRequired());
}
if (model.isSetQos()) {
entity.setQosId(Guid.createGuidFromString(model.getQos().getId()));
}
if (model.isSetDnsResolverConfiguration()) {
entity.setDnsResolverConfiguration(DnsResolverConfigurationMapper.map(entity.getDnsResolverConfiguration(), model.getDnsResolverConfiguration()));
}
if (model.isSetExternalProvider() && model.getExternalProvider().isSetId()) {
ProviderNetwork providerNetwork = new ProviderNetwork();
providerNetwork.setProviderId(GuidUtils.asGuid(model.getExternalProvider().getId()));
if (model.isSetExternalProviderPhysicalNetwork() && model.getExternalProviderPhysicalNetwork().isSetId()) {
providerNetwork.setPhysicalNetworkId(GuidUtils.asGuid(model.getExternalProviderPhysicalNetwork().getId()));
}
entity.setProvidedBy(providerNetwork);
}
return entity;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkClusterHelper method removeNetworkAndReassignRoles.
public void removeNetworkAndReassignRoles(NetworkCluster networkCluster) {
NetworkCluster oldNetworkCluster = networkClusterDao.get(networkCluster.getId());
networkClusterDao.remove(networkCluster.getClusterId(), networkCluster.getNetworkId());
networkAttachmentDao.removeByNetworkId(networkCluster.getNetworkId());
boolean updateManagementNetwork = false;
final NetworkCluster managementNetworkCluster = getManagementNetworkCluster(networkCluster);
if (oldNetworkCluster.isDisplay()) {
managementNetworkCluster.setDisplay(true);
updateManagementNetwork = true;
}
if (oldNetworkCluster.isMigration()) {
managementNetworkCluster.setMigration(true);
updateManagementNetwork = true;
}
if (oldNetworkCluster.isDefaultRoute()) {
managementNetworkCluster.setDefaultRoute(true);
updateManagementNetwork = true;
}
if (updateManagementNetwork) {
networkClusterDao.update(managementNetworkCluster);
}
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster in project ovirt-engine by oVirt.
the class NetworkClusterValidatorBase method findMissingIpNic.
private VdsNetworkInterface findMissingIpNic(final String networkName) {
IsRoleNetworkIpConfigurationValid isRoleNetworkIpConfigurationValid = new IsRoleNetworkIpConfigurationValid(networkCluster);
final List<VdsNetworkInterface> interfacesByClusterId = interfaceDao.getAllInterfacesByClusterId(networkCluster.getClusterId());
final VdsNetworkInterface missingIpNic = interfacesByClusterId.stream().filter(nic -> networkName.equals(nic.getNetworkName())).filter(isRoleNetworkIpConfigurationValid::isIpAddressMissingForRole).findFirst().orElse(null);
return missingIpNic;
}
Aggregations