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;
41 import org.openstack4j.model.network.Network;
44 * Defines the contract to extract Heat Stack Resources from Openstack and inventory it to AAI. This API is used only to
45 * "create" objects in AAI.
47 public interface HeatBridgeApi {
50 * Authenticate with Openstack Keystone. The auth information is read from SO cloud configuration file.
52 * @return Openstack client object with keystone token
53 * @throws HeatBridgeException upon failure to authenticate with keystone
55 OpenstackClient authenticate() throws HeatBridgeException;
58 * Query all the stack based resources from Openstack Heat service
60 * @param heatStackId Heat stack UUID
61 * @return A list of stack based resources
63 List<Resource> queryNestedHeatStackResources(String heatStackId);
66 * Get a filtered list of resource IDs by resource type
68 * @param stackResources A list of stack based resources
69 * @param resourceType Resource type to filter by
70 * @return A list of stack resources matching the specified resource-type
72 List<String> extractStackResourceIdsByResourceType(List<Resource> stackResources, String resourceType);
75 * Get network IDs for a given list of network names. It is assumed that there is a one to one mapping between the
78 * @param networkNameList List of network names
79 * @return List of matching network IDs
81 List<String> extractNetworkIds(List<String> networkNameList);
84 * Query the Openstack server objects from the list of stack resources
86 * @param stackResources A list of stack based resources
87 * @return A list of Openstack Server objects
89 List<Server> getAllOpenstackServers(List<Resource> stackResources);
92 * Query the Openstack provider network objects from the list of stack resources
94 * @param stackResources A list of stack based resources
95 * @return A list of Openstack Network objects
97 List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources);
100 * Extract Openstack Image objects from a a list of Server objects
102 * @param servers A list of Openstack Server objects
103 * @return A list of Openstack Image objects
105 List<Image> extractOpenstackImagesFromServers(List<Server> servers);
108 * Extract Openstack Flavor objects from a a list of Server objects
110 * @param servers A list of Openstack Server objects
111 * @return A list of Openstack Flavor objects
113 List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers);
116 * Query and build AAI actions for Openstack Compute resources to AAI's l3-network objects with its subnets
118 * @param genericVnfId AAI generic-vnf-id
119 * @param vfModuleId AAI vf-module-id
120 * @param networks Openstack Network list
122 void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, List<Network> networks);
125 * Query and build AAI actions for Openstack Image resources to AAI's image objects
127 * @param images List of Openstack Image objects
128 * @throws HeatBridgeException when failing to add images to AAI
130 void buildAddImagesToAaiAction(List<Image> images) throws HeatBridgeException;
133 * Query and build AAI actions for Openstack Flavor resources to AAI's flavor objects
135 * @param flavors List of Openstack Flavor objects
136 * @throws HeatBridgeException when failing to add flavors to AAI
138 void buildAddFlavorsToAaiAction(List<Flavor> flavors) throws HeatBridgeException;
141 * Query and build AAI actions for Openstack Compute resources to AAI's vserver objects
143 * @param genericVnfId AAI generic-vnf-id
144 * @param vfModuleId AAI vf-module-id
145 * @param servers Openstack Server list
147 void buildAddVserversToAaiAction(String genericVnfId, String vfModuleId, List<Server> servers);
150 * Query and build AAI actions for Openstack Neutron resources associated with a Compute resource to AAI's
151 * l-interface objects
153 * @param stackResources Openstack Heat stack resource list
154 * @param oobMgtNetIds List of OOB network IDs list
157 void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds,
161 * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects
163 * @param stackResources Openstack StackResources list
165 void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources) throws HeatBridgeException;
168 * Execute AAI restful API to update the Openstack resources
170 * @param dryrun - this will simply log the aai transaction to log if enabled and not write any data
171 * @throws HeatBridgeException when failing to add openstack resource PoJos to AAI
173 void submitToAai(boolean dryrun) throws HeatBridgeException;
176 * Delete heatbridge data for a given vf-module
178 * @throws HeatBridgeException when failing to remove heatbridge data from AAI for a given vf-module
180 void deleteVfModuleData(String vnfId, String vfModuleId) throws HeatBridgeException;