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