use of org.onap.aai.domain.yang.Pserver in project so by onap.
the class AAIRestClientImpl method getListOfPservers.
protected List<Pserver> getListOfPservers(String jsonInput) throws IOException {
ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper();
Results<Map<String, Pserver>> resultsFromJson = mapper.readValue(jsonInput, new TypeReference<Results<Map<String, Pserver>>>() {
});
List<Pserver> results = new ArrayList<>();
for (Map<String, Pserver> m : resultsFromJson.getResult()) {
results.add(m.get("pserver"));
}
return results;
}
use of org.onap.aai.domain.yang.Pserver in project so by onap.
the class AAIValidatorImpl method isPhysicalServerLocked.
@Override
public boolean isPhysicalServerLocked(String vnfId) throws IOException {
List<Pserver> pservers;
boolean isLocked = false;
pservers = client.getPhysicalServerByVnfId(vnfId);
if (pservers != null) {
for (Pserver pserver : pservers) {
if (pserver.isInMaint()) {
isLocked = true;
return isLocked;
}
}
}
return isLocked;
}
use of org.onap.aai.domain.yang.Pserver in project so by onap.
the class AAIValidatorTest method getPserversNotLocked.
public List<Pserver> getPserversNotLocked() {
Pserver pserver1 = new Pserver();
pserver1.setInMaint(false);
Pserver pserver2 = new Pserver();
pserver2.setInMaint(false);
List<Pserver> pservers = new ArrayList<Pserver>();
pservers.add(pserver1);
pservers.add(pserver2);
return pservers;
}
use of org.onap.aai.domain.yang.Pserver in project so by onap.
the class HeatBridgeImpl method createPserversAndPinterfacesIfNotPresentInAai.
@Override
public void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources) throws HeatBridgeException {
if (stackResources == null) {
return;
}
Map<String, Pserver> serverHostnames = getPserverMapping(stackResources);
createPServerIfNotExists(serverHostnames);
List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE);
for (String portId : portIds) {
Port port = osClient.getPortById(portId);
if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
Pserver foundServer = serverHostnames.get(port.getHostId());
if (foundServer != null) {
createPServerPInterfaceIfNotExists(foundServer.getHostname(), aaiHelper.buildPInterface(port));
}
}
}
}
use of org.onap.aai.domain.yang.Pserver in project so by onap.
the class HeatBridgeImpl method createTransactionToDeleteSriovPfFromPserver.
private void createTransactionToDeleteSriovPfFromPserver(List<AAIResourceUri> vserverUris) {
Map<String, List<String>> pserverToPciIdMap = getPserverToPciIdMap(vserverUris);
for (Map.Entry<String, List<String>> entry : pserverToPciIdMap.entrySet()) {
String pserverName = entry.getKey();
List<String> pciIds = entry.getValue();
Optional<Pserver> pserver = resourcesClient.get(Pserver.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName)).depth(Depth.TWO));
if (pserver.isPresent()) {
// For each pserver/p-interface match sriov-vfs by pic-id and delete them.
pserver.get().getPInterfaces().getPInterface().stream().filter(pIf -> pIf.getSriovPfs() != null && CollectionUtils.isNotEmpty(pIf.getSriovPfs().getSriovPf())).forEach(pIf -> pIf.getSriovPfs().getSriovPf().forEach(sriovPf -> {
if (pciIds.contains(sriovPf.getPfPciId())) {
logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName() + " from PServer: " + pserverName);
if (env.getProperty("heatBridgeDryrun", Boolean.class, false)) {
logger.debug("Would delete Sriov Pf: {}", AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName).pInterface(pIf.getInterfaceName()).sriovPf(sriovPf.getPfPciId())).build());
} else {
resourcesClient.delete(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName).pInterface(pIf.getInterfaceName()).sriovPf(sriovPf.getPfPciId())));
}
}
}));
}
}
}
Aggregations