use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class AppcOrchestratorPreProcessor method getVserversForAppc.
protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception {
AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf);
if (aaiRW != null && aaiRW.getRelationships().isPresent()) {
Relationships relationships = aaiRW.getRelationships().get();
if (relationships != null) {
List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER);
ArrayList<String> vserverIds = new ArrayList<String>();
ArrayList<String> vserverSelfLinks = new ArrayList<String>();
for (AAIResourceUri j : vserverUris) {
String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId);
vserverIds.add(vserverId);
Optional<Vserver> oVserver = aaiVnfResources.getVserver(j);
if (oVserver.isPresent()) {
Vserver vserver = oVserver.get();
String vserverSelfLink = vserver.getVserverSelflink();
vserverSelfLinks.add(vserverSelfLink);
}
}
logger.debug("vmIdsArray is: {}", vserverSelfLinks);
logger.debug("vserverIdsArray is: {}", vserverIds);
execution.setVariable("vmIdList", vserverSelfLinks);
execution.setVariable("vserverIdList", vserverIds);
}
}
}
use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class CreateAAInventory method doExecute.
@Override
public void doExecute(TestContext context) {
final Logger logger = LoggerFactory.getLogger(CreateAAInventory.class);
try {
String stackName = context.getVariable("stackName");
if (stackName != null && stackName.equals("replace_module")) {
String vServerId = "92272b67-d23f-42ca-87fa-7b06a9ec81f3";
AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
AAICommonObjectMapperProvider aaiMapper = new AAICommonObjectMapperProvider();
InputStream vserverFile = new ClassPathResource("openstack/gr_api/CreateAAIInventory.json").getInputStream();
Vserver vserver = aaiMapper.getMapper().readValue(vserverFile, Vserver.class);
AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("cloudOwner", "regionOne").tenant("0422ffb57ba042c0800a29dc85ca70f8").vserver(vServerId));
aaiResourceClient.create(vserverURI, vserver);
}
} catch (Exception e) {
logger.debug("Exception in CreateAAInventory.doExecute", e);
}
}
use of org.onap.aai.domain.yang.Vserver in project so by onap.
the class HeatBridgeImpl method getPserverToPciIdMap.
private Map<String, List<String>> getPserverToPciIdMap(List<AAIResourceUri> vserverUris) {
Map<String, List<String>> pserverToPciIdMap = new HashMap<>();
for (AAIResourceUri vserverUri : vserverUris) {
AAIResultWrapper vserverWrapper = resourcesClient.get(vserverUri.depth(Depth.TWO));
Optional<Relationships> vserverRelationships = vserverWrapper.getRelationships();
if (vserverRelationships.isPresent() && CollectionUtils.isNotEmpty(vserverRelationships.get().getRelatedLinks(Types.PSERVER))) {
Vserver vserver = vserverWrapper.asBean(Vserver.class).get();
List<String> pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver);
if (CollectionUtils.isNotEmpty(pciIds)) {
List<AAIResourceUri> matchingPservers = vserverRelationships.get().getRelatedUris(Types.PSERVER);
if (matchingPservers != null && matchingPservers.size() == 1) {
pserverToPciIdMap.put(matchingPservers.get(0).getURIKeys().get("hostname"), pciIds);
}
}
}
}
return pserverToPciIdMap;
}
use of org.onap.aai.domain.yang.Vserver 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.Vserver in project so by onap.
the class AaiHelper method buildVserver.
/**
* Transform Openstack Server object to AAI Vserver object
*
* @param serverId Openstack server identifier
* @param server Openstack server object
* @return AAI Vserver object
*/
public Vserver buildVserver(final String serverId, final Server server) {
Vserver vserver = new Vserver();
vserver.setInMaint(false);
vserver.setIsClosedLoopDisabled(false);
vserver.setVserverId(serverId);
vserver.setVserverName(server.getName());
vserver.setVserverName2(server.getName());
server.getLinks().stream().filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY)).findFirst().ifPresent(link -> vserver.setVserverSelflink(link.getHref()));
return vserver;
}
Aggregations