2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 * Copyright (C) 2018 Bell Canada. All rights reserved.
24 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
25 * the License. You may obtain a copy of the License at
27 * http://www.apache.org/licenses/LICENSE-2.0
29 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
30 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
31 * specific language governing permissions and limitations under the License.
33 package org.onap.so.heatbridge;
35 import java.util.List;
36 import org.onap.so.heatbridge.openstack.api.OpenstackClient;
37 import org.openstack4j.model.compute.Flavor;
38 import org.openstack4j.model.compute.Image;
39 import org.openstack4j.model.compute.Server;
40 import org.openstack4j.model.heat.Resource;
43 * Defines the contract to extract Heat Stack Resources from Openstack and inventory it to AAI. This API is used only to
44 * "create" objects in AAI.
46 public interface HeatBridgeApi {
49 * Authenticate with Openstack Keystone. The auth information is read from SO cloud configuration file.
51 * @return Openstack client object with keystone token
52 * @throws HeatBridgeException upon failure to authenticate with keystone
54 OpenstackClient authenticate() throws HeatBridgeException;
57 * Query all the stack based resources from Openstack Heat service
59 * @param heatStackId Heat stack UUID
60 * @return A list of stack based resources
62 List<Resource> queryNestedHeatStackResources(String heatStackId);
65 * Get a filtered list of resource IDs by resource type
67 * @param stackResources A list of stack based resources
68 * @param resourceType Resource type to filter by
69 * @return A list of stack resources matching the specified resource-type
71 List<String> extractStackResourceIdsByResourceType(List<Resource> stackResources, String resourceType);
74 * Get network IDs for a given list of network names. It is assumed that there is a one to one mapping between the
77 * @param networkNameList List of network names
78 * @return List of matching network IDs
80 List<String> extractNetworkIds(List<String> networkNameList);
83 * Query the Openstack server objects from the list of stack resources
85 * @param stackResources A list of stack based resources
86 * @return A list of Openstack Server objects
88 List<Server> getAllOpenstackServers(List<Resource> stackResources);
91 * Extract Openstack Image objects from a a list of Server objects
93 * @param servers A list of Openstack Server objects
94 * @return A list of Openstack Image objects
96 List<Image> extractOpenstackImagesFromServers(List<Server> servers);
99 * Extract Openstack Flavor objects from a a list of Server objects
101 * @param servers A list of Openstack Server objects
102 * @return A list of Openstack Flavor objects
104 List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers);
107 * Query and build AAI actions for Openstack Image resources to AAI's image objects
109 * @param images List of Openstack Image objects
110 * @throws HeatBridgeException when failing to add images to AAI
112 void buildAddImagesToAaiAction(List<Image> images) throws HeatBridgeException;
115 * Query and build AAI actions for Openstack Flavor resources to AAI's flavor objects
117 * @param flavors List of Openstack Flavor objects
118 * @throws HeatBridgeException when failing to add flavors to AAI
120 void buildAddFlavorsToAaiAction(List<Flavor> flavors) throws HeatBridgeException;
123 * Query and build AAI actions for Openstack Compute resources to AAI's vserver objects
125 * @param genericVnfId AAI generic-vnf-id
126 * @param vfModuleId AAI vf-module-id
127 * @param servers Openstack Server list
129 void buildAddVserversToAaiAction(String genericVnfId, String vfModuleId, List<Server> servers);
132 * Query and build AAI actions for Openstack Neutron resources associated with a Compute resource to AAI's
133 * l-interface objects
135 * @param stackResources Openstack Heat stack resource list
136 * @param oobMgtNetIds List of OOB network IDs list
138 void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds);
141 * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects
143 * @param stackResources Openstack StackResources list
145 void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources) throws HeatBridgeException;
148 * Execute AAI restful API to update the Openstack resources
150 * @throws HeatBridgeException when failing to add openstack resource PoJos to AAI
152 void submitToAai() throws HeatBridgeException;
155 * Delete heatbridge data for a given vf-module
157 * @throws HeatBridgeException when failing to remove heatbridge data from AAI for a given vf-module
159 void deleteVfModuleData(String vnfId, String vfModuleId) throws HeatBridgeException;