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