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