Merge of new rebased code
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / main / java / org / openecomp / appc / adapter / iaas / ProviderAdapter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.adapter.iaas;
23
24 import java.util.Map;
25
26 import org.openecomp.appc.exceptions.APPCException;
27 import org.openecomp.appc.exceptions.UnknownProviderException;
28 import com.att.cdp.zones.model.Image;
29 import com.att.cdp.zones.model.Server;
30 import com.att.cdp.zones.model.Stack;
31 import org.openecomp.sdnc.sli.SvcLogicContext;
32 import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
33
34 /**
35  * This interface defines the operations that the provider adapter exposes.
36  * <p>
37  * This interface defines static constant property values that can be used to configure the adapter. These constants are
38  * prefixed with the name PROPERTY_ to indicate that they are configuration properties. These properties are read from
39  * the configuration file for the adapter and are used to define the providers, identity service URLs, and other
40  * information needed by the adapter to interface with an IaaS provider.
41  * </p>
42  */
43 public interface ProviderAdapter extends SvcLogicJavaPlugin {
44
45     /**
46      * The type of provider to be accessed to locate and operate on a virtual machine instance. This is used to load the
47      * correct provider support through the CDP IaaS abstraction layer and can be OpenStackProvider, BareMetalProvider,
48      * or any other supported provider type.
49      */
50     static final String PROPERTY_PROVIDER_TYPE = "org.openecomp.appc.provider.type";
51
52     /**
53      * The adapter maintains a cache of providers organized by the name of the provider, not its type. This is
54      * equivalent to the system or installation name. All regions within the same installation are assumed to be the
55      * same type.
56      */
57     static final String PROPERTY_PROVIDER_NAME = "org.openecomp.appc.provider.name";
58
59     /**
60      * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
61      */
62     static final String PROPERTY_INSTANCE_URL = "org.openecomp.appc.instance.url";
63
64     /**
65      * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
66      */
67     static final String PROPERTY_IDENTITY_URL = "org.openecomp.appc.identity.url";
68     
69     /**
70      * The Rebuild VM flag is an optional payload parameter for the Evacuate API.
71      */
72     static final String PROPERTY_REBUILD_VM = "org.openecomp.appc.rebuildvm";
73     
74     /**
75      * The target host id is an optional payload parameter for the Evacuate API.
76      */
77     static final String PROPERTY_TARGETHOST_ID = "org.openecomp.appc.targethost.id";
78     
79     /**
80      * heat stack id to perform operation on stack
81      */
82     static final String PROPERTY_STACK_ID = "org.openecomp.appc.stack.id";
83
84     static final String PROPERTY_SNAPSHOT_ID = "snapshot.id";
85
86     static final String PROPERTY_INPUT_SNAPSHOT_ID = "org.openecomp.appc.snapshot.id";
87
88     static final String DG_OUTPUT_PARAM_NAMESPACE = "output.";
89     
90     static final String SKIP_HYPERVISOR_CHECK = "org.openecomp.appc.skiphypervisorcheck";
91
92     /**
93      * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
94      * <p>
95      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
96      * passed to the method are passed as properties in a map. This method expects the following properties to be
97      * defined:
98      * <dl>
99      * <dt>org.openecomp.appc.provider.type</dt>
100      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
101      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
102      * provider types are legal.</dd>
103      * <dt>org.openecomp.appc.instance.url</dt>
104      * <dd>The fully qualified URL of the instance to be restarted, as it is known to the provider (i.e., the self-link
105      * URL of the server)</dd>
106      * </dl>
107      * </p>
108      *
109      * @param properties
110      *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
111      *            defined above.
112      * @param context
113      *            The service logic context of the graph being executed.
114      * @return The <code>Server</code> object that represents the VM being restarted. The returned server object can be
115      *         inspected for the final state of the server once the restart has been completed. The method does not
116      *         return until the restart has either completed or has failed.
117      * @throws APPCException
118      *             If the server cannot be restarted for some reason
119      */
120     Server restartServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
121
122     /**
123      * This method is used to stop the indicated server
124      * <p>
125      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
126      * passed to the method are passed as properties in a map. This method expects the following properties to be
127      * defined:
128      * <dl>
129      * <dt>org.openecomp.appc.provider.type</dt>
130      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
131      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
132      * provider types are legal.</dd>
133      * <dt>org.openecomp.appc.instance.url</dt>
134      * <dd>The fully qualified URL of the instance to be stopped, as it is known to the provider (i.e., the self-link
135      * URL of the server)</dd>
136      * </dl>
137      * </p>
138      *
139      * @param properties
140      *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
141      *            defined above.
142      * @param context
143      *            The service logic context of the graph being executed.
144      * @return The <code>Server</code> object that represents the VM being stopped. The returned server object can be
145      *         inspected for the final state of the server once the stop has been completed. The method does not return
146      *         until the stop has either completed or has failed.
147      * @throws APPCException
148      *             If the server cannot be stopped for some reason
149      */
150     Server stopServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
151
152     /**
153      * This method is used to start the indicated server
154      * <p>
155      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
156      * passed to the method are passed as properties in a map. This method expects the following properties to be
157      * defined:
158      * <dl>
159      * <dt>org.openecomp.appc.provider.type</dt>
160      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
161      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
162      * provider types are legal.</dd>
163      * <dt>org.openecomp.appc.instance.url</dt>
164      * <dd>The fully qualified URL of the instance to be started, as it is known to the provider (i.e., the self-link
165      * URL of the server)</dd>
166      * </dl>
167      * </p>
168      *
169      * @param properties
170      *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
171      *            defined above.
172      * @param context
173      *            The service logic context of the graph being executed.
174      * @return The <code>Server</code> object that represents the VM being started. The returned server object can be
175      *         inspected for the final state of the server once the start has been completed. The method does not return
176      *         until the start has either completed or has failed.
177      * @throws APPCException
178      *             If the server cannot be started for some reason
179      */
180     Server startServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
181
182     /**
183      * This method is used to rebuild the indicated server
184      * <p>
185      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
186      * passed to the method are passed as properties in a map. This method expects the following properties to be
187      * defined:
188      * <dl>
189      * <dt>org.openecomp.appc.provider.type</dt>
190      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
191      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
192      * provider types are legal.</dd>
193      * <dt>org.openecomp.appc.instance.url</dt>
194      * <dd>The fully qualified URL of the instance to be rebuilt, as it is known to the provider (i.e., the self-link
195      * URL of the server)</dd>
196      * </dl>
197      * </p>
198      *
199      * @param properties
200      *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
201      *            defined above.
202      * @param context
203      *            The service logic context of the graph being executed.
204      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
205      *         inspected for the final state of the server once the rebuild has been completed. The method does not
206      *         return until the rebuild has either completed or has failed.
207      * @throws APPCException
208      *             If the server cannot be rebuilt for some reason
209      */
210     Server rebuildServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
211
212     /**
213      * This method is used to terminate the indicated server
214      * <p>
215      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
216      * passed to the method are passed as properties in a map. This method expects the following properties to be
217      * defined:
218      * <dl>
219      * <dt>org.openecomp.appc.provider.type</dt>
220      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
221      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
222      * provider types are legal.</dd>
223      * <dt>org.openecomp.appc.instance.url</dt>
224      * <dd>The fully qualified URL of the instance to be terminate, as it is known to the provider (i.e., the self-link
225      * URL of the server)</dd>
226      * </dl>
227      * </p>
228      *
229      * @param properties
230      *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
231      *            defined above.
232      * @param context
233      *            The service logic context of the graph being executed.
234      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
235      *         inspected for the final state of the server once the rebuild has been completed. The method does not
236      *         return until the rebuild has either completed or has failed.
237      * @throws APPCException
238      *             If the server cannot be terminate for some reason
239      */
240     Server terminateServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
241
242     /**
243      * Returns the symbolic name of the adapter
244      *
245      * @return The adapter name
246      */
247     String getAdapterName();
248
249     Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
250
251     Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
252
253     Server vmStatuschecker(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
254
255     Stack terminateStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
256
257     Stack snapshotStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
258
259     Stack restoreStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
260
261     /**
262      * This method is used to do the lookup of the indicated server
263      * <p>
264      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
265      * passed to the method are passed as properties in a map. This method expects the following properties to be
266      * defined:
267      * <dl>
268      * <dt>org.openecomp.appc.provider.type</dt>
269      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
270      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
271      * provider types are legal.</dd>
272      * <dt>org.openecomp.appc.instance.url</dt>
273      * <dd>The fully qualified URL of the instance to be lookup, as it is known to the provider (i.e., the self-link URL
274      * of the server)</dd>
275      * </dl>
276      * </p>
277      *
278      * @param properties
279      *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
280      *            defined above.
281      * @param context
282      *            The service logic context of the graph being executed.
283      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
284      *         inspected for the final state of the server once the rebuild has been completed. The method does not
285      *         return until the rebuild has either completed or has failed.
286      * @throws APPCException
287      *             If the server cannot be found for some reason
288      */
289     Server lookupServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
290
291     /**
292      * The
293      *
294      * @param params
295      *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
296      *            defined above.
297      * @param ctx
298      *            The service logic context of the graph being executed.
299      * @return The <code>Image</code> object that represents the VM being restarted. The returned server object can be
300      *         inspected for the final state of the server once the restart has been completed. The method does not
301      *         return until the restart has either completed or has failed.
302      * @throws APPCException
303      *             If the server cannot be restarted for some reason
304      */
305     Image createSnapshot(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
306
307 }