use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class ExternalNetworkManagerTest method createNetwork.
private Network createNetwork() {
final Network network = new Network();
providerNetwork = new ProviderNetwork();
providerNetwork.setProviderId(PROVIDER_ID);
network.setProvidedBy(providerNetwork);
return network;
}
use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork 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.ProviderNetwork in project ovirt-engine by oVirt.
the class BackendOpenStackNetworkResourceTest method getEntity.
@Override
protected Network getEntity(int index) {
Network network = mock(Network.class);
when(network.getId()).thenReturn(GUIDS[index]);
when(network.getName()).thenReturn(NAMES[index]);
ProviderNetwork providedBy = new ProviderNetwork();
providedBy.setProviderId(GUIDS[0]);
providedBy.setExternalId(string2hex(NAMES[index]));
when(network.getProvidedBy()).thenReturn(providedBy);
return network;
}
use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class BackendOpenStackNetworksResourceTest method getEntity.
@Override
protected Network getEntity(int index) {
Network network = mock(Network.class);
when(network.getId()).thenReturn(GUIDS[index]);
when(network.getName()).thenReturn(NAMES[index]);
ProviderNetwork providedBy = new ProviderNetwork();
providedBy.setProviderId(GUIDS[0]);
providedBy.setExternalId(string2hex(NAMES[index]));
when(network.getProvidedBy()).thenReturn(providedBy);
return network;
}
use of org.ovirt.engine.core.common.businessentities.network.ProviderNetwork in project ovirt-engine by oVirt.
the class BackendOpenStackNetworkResource method doImport.
@Override
public Response doImport(Action action) {
validateParameters(action, "dataCenter.id|name");
Guid dataCenterId = getDataCenterId(action);
ProviderNetwork providerNetwork = new ProviderNetwork(new Guid(providerId), id);
Network network = new Network();
network.setProvidedBy(providerNetwork);
network.setDataCenterId(dataCenterId);
network.setName(getNetwork().getName());
AddNetworkStoragePoolParameters parameters = new AddNetworkStoragePoolParameters(dataCenterId, network);
return doAction(ActionType.AddNetwork, parameters, action);
}
Aggregations