public org.ovirt.engine.core.common.businessentities.network.Network lookupClusterNetwork(Network net) { List<org.ovirt.engine.core.common.businessentities.network.Network> networks = getClusterNetworks(); if(net.isSetId()){ for(org.ovirt.engine.core.common.businessentities.network.Network nwk : networks){ if (nwk.getId().toString().equals(net.getId())) { return nwk; } } }else{ String networkName = net.getName(); for(org.ovirt.engine.core.common.businessentities.network.Network nwk : networks){ if(nwk.getName().equals(networkName)) { return nwk; } } } return notFound(org.ovirt.engine.core.common.businessentities.network.Network.class); } }
public NetworkAttachment mapNetworkAttachment(Map<Guid, NetworkAttachment> attachmentsById, org.ovirt.engine.api.model.NetworkAttachment model) { Mapper<org.ovirt.engine.api.model.NetworkAttachment, NetworkAttachment> networkAttachmentMapper = getMapper(org.ovirt.engine.api.model.NetworkAttachment.class, NetworkAttachment.class); NetworkAttachment attachment = null; if (model.isSetId()) { attachment = attachmentsById.get(asGuid(model.getId())); } else if (model.isSetNetwork() && (model.getNetwork().isSetName() || model.getNetwork().isSetId())) { for (Map.Entry<Guid, NetworkAttachment> backendNetworkAttachmentMapEntry : attachmentsById.entrySet()) { NetworkAttachment backendNetworkAttachment = backendNetworkAttachmentMapEntry.getValue(); String backendNetworkName = backendNetworkAttachment.getNetworkName(); String backendNetworkId = backendNetworkAttachment.getNetworkId().toString(); if (backendNetworkName.equals(model.getNetwork().getName()) || backendNetworkId.equals(model.getNetwork().getId())) { attachment = backendNetworkAttachment; break; } } } return networkAttachmentMapper.map(model, attachment); }
@Override public Response add(VnicProfile vnicProfile) { if (!vnicProfile.isSetNetwork() || !vnicProfile.getNetwork().isSetId()) { vnicProfile.setNetwork(new Network()); vnicProfile.getNetwork().setId(networkId); } return super.add(vnicProfile); }
Guid getManagementNetworkId(Cluster cluster, Guid dataCenterId) { Guid managementNetworkId = null; if (cluster.isSetManagementNetwork()) { backendResource.validateParameters(cluster.getManagementNetwork(), "id|name"); final Network rawManagementNetwork = cluster.getManagementNetwork(); if (rawManagementNetwork.isSetId()) { managementNetworkId = GuidUtils.asGuid(rawManagementNetwork.getId()); } else { final org.ovirt.engine.core.common.businessentities.network.Network managementNetwork = backendResource.getEntity(org.ovirt.engine.core.common.businessentities.network.Network.class, QueryType.GetNetworkByNameAndDataCenter, new IdAndNameQueryParameters(dataCenterId, rawManagementNetwork.getName()), String.format("Network: %s", rawManagementNetwork.getName())); managementNetworkId = managementNetwork.getId(); } } return managementNetworkId; } }
@Override protected VdsNetworkInterface map(HostNic entity, VdsNetworkInterface template) { VdsNetworkInterface iface = super.map(entity, template); if (entity.isSetNetwork()) { if (entity.getNetwork().isSetId() || entity.getNetwork().isSetName()) { org.ovirt.engine.core.common.businessentities.network.Network net = lookupNetwork(entity.getNetwork()); iface.setNetworkName(net.getName()); } else { iface.setNetworkName(null); } } return iface; }
List<org.ovirt.engine.core.common.businessentities.network.Network> networks = getNetworks(); if (network.isSetId()) { org.ovirt.engine.core.common.businessentities.network.Network net = getNetworkById(network.getId(), networks); if (!network.isSetId()) { network.setId(networkId); } else if (network.isSetName() && !network.getId().equals(networkId)) {
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())); ProviderNetwork providerNetwork = new ProviderNetwork(); providerNetwork.setProviderId(GuidUtils.asGuid(model.getExternalProvider().getId())); if (model.isSetExternalProviderPhysicalNetwork() && model.getExternalProviderPhysicalNetwork().isSetId()) { providerNetwork.setPhysicalNetworkId( GuidUtils.asGuid(model.getExternalProviderPhysicalNetwork().getId()));
if (networkModel.isSetId()) { entity.setNetworkId(GuidUtils.asGuid(networkModel.getId()));
to.setDisplay(from.isDisplay()); if (from.isSetId()) { to.setId(from.getId());
entity.setDescription(model.getDescription()); if (model.isSetNetwork() && model.getNetwork().isSetId()) { entity.setNetworkId(GuidUtils.asGuid(model.getNetwork().getId()));