Merge "added in fix to use old volume group name for"
[so.git] / adapters / mso-openstack-adapters / src / main / java / org / onap / so / heatbridge / HeatBridgeApi.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 /*
22  * Copyright (C) 2018 Bell Canada. All rights reserved.
23  *
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
26  *
27  * http://www.apache.org/licenses/LICENSE-2.0
28  *
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.
32  */
33 package org.onap.so.heatbridge;
34
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
42 /**
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.
45  */
46 public interface HeatBridgeApi {
47
48     /**
49      * Authenticate with Openstack Keystone. The auth information is read from SO cloud configuration file.
50      *
51      * @return Openstack client object with keystone token
52      * @throws HeatBridgeException upon failure to authenticate with keystone
53      */
54     OpenstackClient authenticate() throws HeatBridgeException;
55
56     /**
57      * Query all the stack based resources from Openstack Heat service
58      *
59      * @param heatStackId Heat stack UUID
60      * @return A list of stack based resources
61      */
62     List<Resource> queryNestedHeatStackResources(String heatStackId);
63
64     /**
65      * Get a filtered list of resource IDs by resource type
66      *
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
70      */
71     List<String> extractStackResourceIdsByResourceType(List<Resource> stackResources, String resourceType);
72
73     /**
74      * Get network IDs for a given list of network names. It is assumed that there is a one to one mapping between the
75      * name and ID.
76      * 
77      * @param networkNameList List of network names
78      * @return List of matching network IDs
79      */
80     List<String> extractNetworkIds(List<String> networkNameList);
81
82     /**
83      * Query the Openstack server objects from the list of stack resources
84      *
85      * @param stackResources A list of stack based resources
86      * @return A list of Openstack Server objects
87      */
88     List<Server> getAllOpenstackServers(List<Resource> stackResources);
89
90     /**
91      * Extract Openstack Image objects from a a list of Server objects
92      *
93      * @param servers A list of Openstack Server objects
94      * @return A list of Openstack Image objects
95      */
96     List<Image> extractOpenstackImagesFromServers(List<Server> servers);
97
98     /**
99      * Extract Openstack Flavor objects from a a list of Server objects
100      *
101      * @param servers A list of Openstack Server objects
102      * @return A list of Openstack Flavor objects
103      */
104     List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers);
105
106     /**
107      * Query and build AAI actions for Openstack Image resources to AAI's image objects
108      *
109      * @param images List of Openstack Image objects
110      * @throws HeatBridgeException when failing to add images to AAI
111      */
112     void buildAddImagesToAaiAction(List<Image> images) throws HeatBridgeException;
113
114     /**
115      * Query and build AAI actions for Openstack Flavor resources to AAI's flavor objects
116      *
117      * @param flavors List of Openstack Flavor objects
118      * @throws HeatBridgeException when failing to add flavors to AAI
119      */
120     void buildAddFlavorsToAaiAction(List<Flavor> flavors) throws HeatBridgeException;
121
122     /**
123      * Query and build AAI actions for Openstack Compute resources to AAI's vserver objects
124      *
125      * @param genericVnfId AAI generic-vnf-id
126      * @param vfModuleId AAI vf-module-id
127      * @param servers Openstack Server list
128      */
129     void buildAddVserversToAaiAction(String genericVnfId, String vfModuleId, List<Server> servers);
130
131     /**
132      * Query and build AAI actions for Openstack Neutron resources associated with a Compute resource to AAI's
133      * l-interface objects
134      *
135      * @param stackResources Openstack Heat stack resource list
136      * @param oobMgtNetIds List of OOB network IDs list
137      * @param cloudOwner
138      */
139     void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds,
140             String cloudOwner);
141
142     /**
143      * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects
144      *
145      * @param stackResources Openstack StackResources list
146      */
147     void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources) throws HeatBridgeException;
148
149     /**
150      * Execute AAI restful API to update the Openstack resources
151      * 
152      * @param dryrun - this will simply log the aai transaction to log if enabled and not write any data
153      * @throws HeatBridgeException when failing to add openstack resource PoJos to AAI
154      */
155     void submitToAai(boolean dryrun) throws HeatBridgeException;
156
157     /**
158      * Delete heatbridge data for a given vf-module
159      *
160      * @throws HeatBridgeException when failing to remove heatbridge data from AAI for a given vf-module
161      */
162     void deleteVfModuleData(String vnfId, String vfModuleId) throws HeatBridgeException;
163 }