use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class AddEmptyStoragePoolCommand method addDefaultNetworks.
private void addDefaultNetworks() {
Network net = new Network();
net.setId(Guid.newGuid());
net.setName(managementNetworkUtil.getDefaultManagementNetworkName());
NetworkUtils.setNetworkVdsmName(net);
net.setDescription(AddClusterCommand.DefaultNetworkDescription);
net.setDataCenterId(getStoragePool().getId());
net.setVmNetwork(true);
networkDao.save(net);
networkHelper.addPermissionsOnNetwork(getCurrentUser().getId(), net.getId());
VnicProfile profile = networkHelper.createVnicProfile(net);
vnicProfileDao.save(profile);
networkHelper.addPermissionsOnVnicProfile(getCurrentUser().getId(), profile.getId(), true);
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class RemoveStoragePoolCommand method removeNetworks.
private void removeNetworks() {
final List<Network> networks = networkDao.getAllForDataCenter(getStoragePoolId());
for (Network network : networks) {
if (network.isExternal()) {
for (VmNic nic : vmNicDao.getAllForNetwork(network.getId())) {
externalNetworkManagerFactory.create(nic, network).deallocateIfExternal();
}
}
}
TransactionSupport.executeInNewTransaction(() -> {
for (final Network net : networks) {
List<VnicProfile> profiles = vnicProfileDao.getAllForNetwork(net.getId());
for (VnicProfile vnicProfile : profiles) {
getCompensationContext().snapshotEntity(vnicProfile);
vnicProfileDao.remove(vnicProfile.getId());
}
getCompensationContext().snapshotEntity(net);
networkDao.remove(net.getId());
}
getCompensationContext().stateChanged();
return null;
});
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class IscsiBondValidatorTest method addedLogicalNetworkBelongToAnotherDatacenter.
@Test
public void addedLogicalNetworkBelongToAnotherDatacenter() {
IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
List<Network> networks = new ArrayList<>();
networks.add(createNetwork(iscsiBond.getStoragePoolId()));
doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
iscsiBond.getNetworkIds().add(networks.get(0).getId());
iscsiBond.getNetworkIds().add(Guid.newGuid());
ValidationResult res = validator.validateAddedLogicalNetworks(iscsiBond);
assertThat(res, failsWith(EngineMessage.NETWORKS_DONT_EXIST_IN_DATA_CENTER));
assertEquals(2, res.getVariableReplacements().size());
assertEquals("$networkIds " + iscsiBond.getNetworkIds().get(1).toString(), res.getVariableReplacements().get(0));
assertEquals("$dataCenterId " + iscsiBond.getStoragePoolId().toString(), res.getVariableReplacements().get(1));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class IscsiBondValidatorTest method addedRequiredLogicalNetworks.
@Test
public void addedRequiredLogicalNetworks() {
IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
List<Network> networks = new ArrayList<>();
networks.add(createNetwork(iscsiBond.getStoragePoolId()));
networks.add(createNetwork(iscsiBond.getStoragePoolId()));
doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
for (Network network : networks) {
iscsiBond.getNetworkIds().add(network.getId());
}
List<NetworkCluster> networkClusters = new ArrayList<>();
networkClusters.add(createNetworkCluster(true));
doReturn(networkClusters).when(networkClusterDao).getAllForNetwork(any());
ValidationResult res = validator.validateAddedLogicalNetworks(iscsiBond);
assertThat(res, failsWith(EngineMessage.ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class IscsiBondValidatorTest method addedLogicalNetworkBelongToSameDatacenter.
@Test
public void addedLogicalNetworkBelongToSameDatacenter() {
IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
List<Network> networks = new ArrayList<>();
networks.add(createNetwork(iscsiBond.getStoragePoolId()));
networks.add(createNetwork(iscsiBond.getStoragePoolId()));
doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
for (Network network : networks) {
iscsiBond.getNetworkIds().add(network.getId());
}
List<NetworkCluster> networkClusters = new ArrayList<>();
networkClusters.add(createNetworkCluster(false));
doReturn(networkClusters).when(networkClusterDao).getAllForNetwork(any());
assertEquals(ValidationResult.VALID, validator.validateAddedLogicalNetworks(iscsiBond));
}
Aggregations