2 * Copyright (C) 2018 Bell Canada. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5 * the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11 * specific language governing permissions and limitations under the License.
13 package org.onap.so.heatbridge;
15 import java.util.List;
16 import org.onap.so.heatbridge.openstack.api.OpenstackClient;
17 import org.openstack4j.model.compute.Flavor;
18 import org.openstack4j.model.compute.Image;
19 import org.openstack4j.model.compute.Server;
20 import org.openstack4j.model.heat.Resource;
23 * Defines the contract to extract Heat Stack Resources from Openstack and inventory it to AAI. This API is used only to
24 * "create" objects in AAI.
26 public interface HeatBridgeApi {
29 * Authenticate with Openstack Keystone. The auth information is read from SO cloud configuration file.
31 * @return Openstack client object with keystone token
32 * @throws HeatBridgeException upon failure to authenticate with keystone
34 OpenstackClient authenticate() throws HeatBridgeException;
37 * Query all the stack based resources from Openstack Heat service
39 * @param heatStackId Heat stack UUID
40 * @return A list of stack based resources
42 List<Resource> queryNestedHeatStackResources(String heatStackId);
45 * Get a filtered list of resource IDs by resource type
47 * @param stackResources A list of stack based resources
48 * @param resourceType Resource type to filter by
49 * @return A list of stack resources matching the specified resource-type
51 List<String> extractStackResourceIdsByResourceType(List<Resource> stackResources, String resourceType);
54 * Get network IDs for a given list of network names. It is assumed that there is a one to one mapping between the
57 * @param networkNameList List of network names
58 * @return List of matching network IDs
60 List<String> extractNetworkIds(List<String> networkNameList);
63 * Query the Openstack server objects from the list of stack resources
65 * @param stackResources A list of stack based resources
66 * @return A list of Openstack Server objects
68 List<Server> getAllOpenstackServers(List<Resource> stackResources);
71 * Extract Openstack Image objects from a a list of Server objects
73 * @param servers A list of Openstack Server objects
74 * @return A list of Openstack Image objects
76 List<Image> extractOpenstackImagesFromServers(List<Server> servers);
79 * Extract Openstack Flavor objects from a a list of Server objects
81 * @param servers A list of Openstack Server objects
82 * @return A list of Openstack Flavor objects
84 List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers);
87 * Query and build AAI actions for Openstack Image resources to AAI's image objects
89 * @param images List of Openstack Image objects
90 * @throws HeatBridgeException when failing to add images to AAI
92 void buildAddImagesToAaiAction(List<Image> images) throws HeatBridgeException;
95 * Query and build AAI actions for Openstack Flavor resources to AAI's flavor objects
97 * @param flavors List of Openstack Flavor objects
98 * @throws HeatBridgeException when failing to add flavors to AAI
100 void buildAddFlavorsToAaiAction(List<Flavor> flavors) throws HeatBridgeException;
103 * Query and build AAI actions for Openstack Compute resources to AAI's vserver objects
105 * @param genericVnfId AAI generic-vnf-id
106 * @param vfModuleId AAI vf-module-id
107 * @param servers Openstack Server list
109 void buildAddVserversToAaiAction(String genericVnfId, String vfModuleId, List<Server> servers);
112 * Query and build AAI actions for Openstack Neutron resources associated with a Compute resource to AAI's
113 * l-interface objects
115 * @param stackResources Openstack Heat stack resource list
116 * @param oobMgtNetIds List of OOB network IDs list
118 void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds);
121 * Execute AAI restful API to update the Openstack resources
123 * @throws HeatBridgeException when failing to add openstack resource PoJos to AAI
125 void submitToAai() throws HeatBridgeException;