use of org.onap.aai.domain.yang.SriovVf in project so by onap.
the class AaiHelper method getPserverToPciIdMap.
/**
* From the list vserver objects build a map of compute hosts's name and the PCI IDs linked to it.
*
* @param vservers List of vserver AAI objects
* @return a map of compute names to the PCI ids associated with the compute
*/
public Map<String, List<String>> getPserverToPciIdMap(final List<Vserver> vservers) {
Map<String, List<String>> pserverToPciIdMap = new HashMap<>();
for (Vserver vserver : vservers) {
if (vserver.getLInterfaces() != null) {
List<String> pciIds = vserver.getLInterfaces().getLInterface().stream().filter(lInterface -> lInterface.getSriovVfs() != null && CollectionUtils.isNotEmpty(lInterface.getSriovVfs().getSriovVf())).flatMap(lInterface -> lInterface.getSriovVfs().getSriovVf().stream()).map(SriovVf::getPciId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(pciIds)) {
List<String> matchingPservers = extractRelationshipDataValue(vserver.getRelationshipList(), HeatBridgeConstants.AAI_PSERVER, HeatBridgeConstants.AAI_PSERVER_HOSTNAME);
Preconditions.checkState(matchingPservers != null && matchingPservers.size() == 1, "Invalid pserver relationships for vserver: " + vserver.getVserverName());
pserverToPciIdMap.put(matchingPservers.get(0), pciIds);
}
}
}
return pserverToPciIdMap;
}
use of org.onap.aai.domain.yang.SriovVf in project so by onap.
the class HeatBridgeImpl method createVlanAndSriovVF.
protected void createVlanAndSriovVF(final Port port, final LInterface lIf, final String hostName) throws HeatBridgeException {
// add back all vlan logic
Vlan vlan = new Vlan();
Network network = osClient.getNetworkById(port.getNetworkId());
if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) {
vlan.setVlanInterface(port.getName() + network.getProviderSegID());
vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID()));
vlan.setVlanIdInner(0L);
vlan.setInMaint(false);
vlan.setIsIpUnnumbered(false);
vlan.setIsPrivate(false);
transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).vlan(vlan.getVlanInterface())), Optional.of(vlan));
}
if (!lIf.getInterfaceType().equals(SRIOV)) {
if (nodeType == NodeType.GREENFIELD) {
validatePhysicalNetwork(port, network);
processOVS(lIf, hostName, NodeType.GREENFIELD.getInterfaceName());
} else {
processOVS(lIf, hostName, NodeType.BROWNFIELD.getInterfaceName());
}
}
List<String> privateVlans = (ArrayList<String>) port.getProfile().get(PRIVATE_VLANS);
List<String> publicVlans = (ArrayList<String>) port.getProfile().get(PUBLIC_VLANS);
List<String> vlans = null;
if (publicVlans != null && !publicVlans.isEmpty()) {
vlans = publicVlans.stream().filter(publicVlan -> !Strings.isNullOrEmpty(publicVlan)).collect(Collectors.toList());
} else {
vlans = new ArrayList<>();
}
if (privateVlans != null && !privateVlans.isEmpty()) {
List<String> temp = privateVlans.stream().filter(privateVlan -> !Strings.isNullOrEmpty(privateVlan)).collect(Collectors.toList());
vlans.addAll(temp);
}
vlans.stream().forEach(vlanLocal -> logger.debug("Vlan Id: {}", vlanLocal));
processVlanTag(lIf, vlans);
if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
SriovVf sriovVf = new SriovVf();
sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString());
sriovVf.setNeutronNetworkId(port.getNetworkId());
sriovVf.setVfVlanFilter("0");
sriovVf.setVfVlanAntiSpoofCheck(false);
sriovVf.setVfMacAntiSpoofCheck(false);
transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf(sriovVf.getPciId())), Optional.of(sriovVf));
}
}
Aggregations