use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class PersistentHostSetupNetworksParametersFactory method create.
/**
* @param hostId host on which networks to be updated reside
* @param networks networks to be updated; it is assumed, that all those networks belongs to given host.
*
* @return PersistentHostSetupNetworksParameters to refresh all given networks.
*/
public PersistentHostSetupNetworksParameters create(Guid hostId, List<Network> networks) {
Map<Network, NetworkAttachment> networksToSync = getNetworksToSync(hostId, networks);
PersistentHostSetupNetworksParameters parameters = new PersistentHostSetupNetworksParameters(hostId);
parameters.setRollbackOnFailure(true);
parameters.setShouldBeLogged(false);
parameters.setNetworkNames(getNetworkNames(networksToSync.keySet()));
parameters.setNetworkAttachments(new ArrayList<>(networksToSync.values()));
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNetworkNotAttachedToHostWhenAttached.
@Test
public void testNetworkNotAttachedToHostWhenAttached() {
Network network = createNetwork();
when(networkDaoMock.get(network.getId())).thenReturn(network);
when(vdsDaoMock.getAllForNetwork(eq(network.getId()))).thenReturn(Collections.singletonList(host));
String networkName = NETWORK_NAME;
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(network.getId());
attachment.setNetworkName(networkName);
assertThat(createNetworkAttachmentValidator(attachment).networkNotAttachedToHost(), failsWith(EngineMessage.NETWORK_ALREADY_ATTACHED_TO_HOST, ReplacementUtils.createSetVariableString(NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(HOST_NAME, host.getName())));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNetworkNotAttachedToHost.
@Test
public void testNetworkNotAttachedToHost() {
Network network = createNetwork();
when(networkDaoMock.get(network.getId())).thenReturn(network);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(network.getId());
assertThat(createNetworkAttachmentValidator(attachment).networkNotAttachedToHost(), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNetworkExistWhenOnlyNetworkNameIsSet.
@Test
public void testNetworkExistWhenOnlyNetworkNameIsSet() {
NetworkAttachment networkAttachment = new NetworkAttachment();
networkAttachment.setNetworkName(NETWORK_NAME);
NetworkAttachmentValidator validator = createNetworkAttachmentValidator(networkAttachment);
EngineMessage engineMessage = EngineMessage.NETWORK_HAVING_NAME_NOT_EXISTS;
assertThat(validator.networkExists(), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, NETWORK_NAME)));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNotExternalNetwork.
@Test
public void testNotExternalNetwork() {
Network notExternalNetwork = new Network();
notExternalNetwork.setId(Guid.newGuid());
notExternalNetwork.setProvidedBy(null);
when(networkDaoMock.get(eq(notExternalNetwork.getId()))).thenReturn(notExternalNetwork);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(notExternalNetwork.getId());
NetworkAttachmentValidator validator = createNetworkAttachmentValidator(attachment);
assertThat(validator.notExternalNetwork(), isValid());
}
Aggregations