Merge "updates for keystone V3 auth"
[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 import org.openstack4j.model.network.Network;
42
43 /**
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.
46  */
47 public interface HeatBridgeApi {
48
49     /**
50      * Authenticate with Openstack Keystone. The auth information is read from SO cloud configuration file.
51      *
52      * @return Openstack client object with keystone token
53      * @throws HeatBridgeException upon failure to authenticate with keystone
54      */
55     OpenstackClient authenticate() throws HeatBridgeException;
56
57     /**
58      * Query all the stack based resources from Openstack Heat service
59      *
60      * @param heatStackId Heat stack UUID
61      * @return A list of stack based resources
62      */
63     List<Resource> queryNestedHeatStackResources(String heatStackId);
64
65     /**
66      * Get a filtered list of resource IDs by resource type
67      *
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
71      */
72     List<String> extractStackResourceIdsByResourceType(List<Resource> stackResources, String resourceType);
73
74     /**
75      * Get network IDs for a given list of network names. It is assumed that there is a one to one mapping between the
76      * name and ID.
77      * 
78      * @param networkNameList List of network names
79      * @return List of matching network IDs
80      */
81     List<String> extractNetworkIds(List<String> networkNameList);
82
83     /**
84      * Query the Openstack server objects from the list of stack resources
85      *
86      * @param stackResources A list of stack based resources
87      * @return A list of Openstack Server objects
88      */
89     List<Server> getAllOpenstackServers(List<Resource> stackResources);
90
91     /**
92      * Query the Openstack provider network objects from the list of stack resources
93      *
94      * @param stackResources A list of stack based resources
95      * @return A list of Openstack Network objects
96      */
97     List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources);
98
99     /**
100      * Extract Openstack Image objects from a a list of Server objects
101      *
102      * @param servers A list of Openstack Server objects
103      * @return A list of Openstack Image objects
104      */
105     List<Image> extractOpenstackImagesFromServers(List<Server> servers);
106
107     /**
108      * Extract Openstack Flavor objects from a a list of Server objects
109      *
110      * @param servers A list of Openstack Server objects
111      * @return A list of Openstack Flavor objects
112      */
113     List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers);
114
115     /**
116      * Query and build AAI actions for Openstack Compute resources to AAI's l3-network objects with its subnets
117      *
118      * @param genericVnfId AAI generic-vnf-id
119      * @param vfModuleId AAI vf-module-id
120      * @param networks Openstack Network list
121      */
122     void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, List<Network> networks);
123
124     /**
125      * Query and build AAI actions for Openstack Image resources to AAI's image objects
126      *
127      * @param images List of Openstack Image objects
128      * @throws HeatBridgeException when failing to add images to AAI
129      */
130     void buildAddImagesToAaiAction(List<Image> images) throws HeatBridgeException;
131
132     /**
133      * Query and build AAI actions for Openstack Flavor resources to AAI's flavor objects
134      *
135      * @param flavors List of Openstack Flavor objects
136      * @throws HeatBridgeException when failing to add flavors to AAI
137      */
138     void buildAddFlavorsToAaiAction(List<Flavor> flavors) throws HeatBridgeException;
139
140     /**
141      * Query and build AAI actions for Openstack Compute resources to AAI's vserver objects
142      *
143      * @param genericVnfId AAI generic-vnf-id
144      * @param vfModuleId AAI vf-module-id
145      * @param servers Openstack Server list
146      */
147     void buildAddVserversToAaiAction(String genericVnfId, String vfModuleId, List<Server> servers);
148
149     /**
150      * Query and build AAI actions for Openstack Neutron resources associated with a Compute resource to AAI's
151      * l-interface objects
152      *
153      * @param stackResources Openstack Heat stack resource list
154      * @param oobMgtNetIds List of OOB network IDs list
155      * @param cloudOwner
156      */
157     void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds,
158             String cloudOwner);
159
160     /**
161      * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects
162      *
163      * @param stackResources Openstack StackResources list
164      */
165     void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources) throws HeatBridgeException;
166
167     /**
168      * Execute AAI restful API to update the Openstack resources
169      * 
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
172      */
173     void submitToAai(boolean dryrun) throws HeatBridgeException;
174
175     /**
176      * Delete heatbridge data for a given vf-module
177      *
178      * @throws HeatBridgeException when failing to remove heatbridge data from AAI for a given vf-module
179      */
180     void deleteVfModuleData(String vnfId, String vfModuleId) throws HeatBridgeException;
181 }