use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNotExternalNetworkWhenExternalNetworkIsProvided.
@Test
public void testNotExternalNetworkWhenExternalNetworkIsProvided() {
Network externalNetwork = new Network();
externalNetwork.setId(Guid.newGuid());
externalNetwork.setProvidedBy(new ProviderNetwork(Guid.newGuid(), ""));
when(networkDaoMock.get(eq(externalNetwork.getId()))).thenReturn(externalNetwork);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(externalNetwork.getId());
assertThat(createNetworkAttachmentValidator(attachment).notExternalNetwork(), failsWith(EngineMessage.EXTERNAL_NETWORK_HAVING_NAME_CANNOT_BE_PROVISIONED));
}
use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class Cloner method cloneProviderNetwork.
private static ProviderNetwork cloneProviderNetwork(ProviderNetwork instance) {
ProviderNetwork obj = new ProviderNetwork();
obj.setExternalId(instance.getExternalId());
obj.setProviderId(instance.getProviderId());
return obj;
}
use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class OpenStackNetworkMapper method map.
@Mapping(from = Network.class, to = OpenStackNetwork.class)
public static OpenStackNetwork map(Network entity, OpenStackNetwork template) {
OpenStackNetwork model = template != null ? template : new OpenStackNetwork();
ProviderNetwork providedBy = entity.getProvidedBy();
if (providedBy != null) {
if (providedBy.getExternalId() != null) {
model.setId(providedBy.getExternalId());
}
}
if (entity.getName() != null) {
model.setName(entity.getName());
}
return model;
}
use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class GetAllExternalNetworksOnProviderQueryTest method testExecuteQueryCommand.
@Test
@SuppressWarnings("unchecked")
public void testExecuteQueryCommand() {
when(params.getId()).thenReturn(mock(Guid.class));
when((Provider<AdditionalProperties>) providerDao.get(any())).thenReturn(networkProvider);
when(providerProxyFactory.create(networkProvider)).thenReturn(client);
Network network = mock(Network.class);
ProviderNetwork providerNetwork = mock(ProviderNetwork.class);
when(client.getAll()).thenReturn(Collections.singletonList(network));
when(network.getProvidedBy()).thenReturn(providerNetwork);
when(providerNetwork.getExternalId()).thenReturn("");
Guid id = mock(Guid.class);
when(dcDao.getDcIdByExternalNetworkId(any())).thenReturn(Collections.singletonList(id));
Map<Network, Set<Guid>> expected = new HashMap<>();
expected.put(network, Collections.singleton(id));
query = getQuery();
query.executeQueryCommand();
assertEquals("Wrong result returned", expected, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class SyncNetworkProviderCommandTest method getNetworkList.
private List<Network> getNetworkList(String externalId) {
ProviderNetwork providerNetwork = new ProviderNetwork();
providerNetwork.setExternalId(externalId);
providerNetwork.setProviderId(PROVIDER_ID);
Network network = new Network();
network.setProvidedBy(providerNetwork);
return Collections.singletonList(network);
}
Aggregations