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