use of org.onap.so.heatbridge.HeatBridgeApi in project so by onap.
the class CreateAAIInventory method heatbridge.
public void heatbridge(CloudInformation cloudInformation) throws HeatBridgeException, MsoCloudSiteNotFound {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()).orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
if (cloudSite.getOrchestrator() != null && MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.getOrchestrator())) {
logger.debug("Skipping Heatbridge as CloudSite orchestrator is: " + MULTICLOUD_MODE);
return;
}
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
String heatStackId = cloudInformation.getTemplateInstanceId().split("/")[1];
List<String> oobMgtNetNames = new ArrayList<>();
HeatBridgeApi heatBridgeClient = createClient(getAaiClient(), cloudSite, cloudIdentity, cloudInformation);
heatBridgeClient.authenticate();
List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId());
List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources);
heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), osNetworks);
List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources);
heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources);
List<Image> osImages = heatBridgeClient.extractOpenstackImagesFromServers(osServers);
List<Flavor> osFlavors = heatBridgeClient.extractOpenstackFlavorsFromServers(osServers);
logger.debug("Successfully queried heat stack{} for resources.", heatStackId);
// os images
if (osImages != null && !osImages.isEmpty()) {
heatBridgeClient.buildAddImagesToAaiAction(osImages);
logger.debug("Successfully built AAI actions to add images.");
} else {
logger.debug("No images to update to AAI.");
}
// flavors
if (osFlavors != null && !osFlavors.isEmpty()) {
heatBridgeClient.buildAddFlavorsToAaiAction(osFlavors);
logger.debug("Successfully built AAI actions to add flavors.");
} else {
logger.debug("No flavors to update to AAI.");
}
// compute resources
heatBridgeClient.buildAddVserversToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), osServers);
logger.debug("Successfully queried compute resources and built AAI vserver actions.");
// neutron resources
List<String> oobMgtNetIds = new ArrayList<>();
// if no network-id list is provided, however network-name list is
if (!CollectionUtils.isEmpty(oobMgtNetNames)) {
oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames);
}
heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, cloudInformation.getOwner());
logger.debug("Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers.");
heatBridgeClient.buildAddVolumes(stackResources);
// Update AAI
logger.debug("Current Dry Run Value: {}", env.getProperty("heatBridgeDryrun", Boolean.class, false));
heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false));
}
use of org.onap.so.heatbridge.HeatBridgeApi in project so by onap.
the class DeleteAAIInventory method heatbridge.
public void heatbridge(CloudInformation cloudInformation) throws MsoCloudSiteNotFound, HeatBridgeException {
logger.debug("Heatbridge delete executing");
CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()).orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
if (cloudSite.getOrchestrator() != null && MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.getOrchestrator())) {
logger.debug("Skipping Heatbridge as CloudSite orchestrator is: " + MULTICLOUD_MODE);
return;
}
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
HeatBridgeApi heatBridgeClient = createClient(getAaiClient(), cloudSite, cloudIdentity, cloudInformation);
heatBridgeClient.authenticate();
heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
}
Aggregations