5055305bfc7aba271b82a15a82f0973e5678edd1
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / main / java / org / onap / appc / adapter / iaas / ProviderAdapter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 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  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.adapter.iaas;
25
26 import java.util.Map;
27 import org.onap.appc.exceptions.APPCException;
28 import org.onap.appc.exceptions.UnknownProviderException;
29 import com.att.cdp.zones.model.Image;
30 import com.att.cdp.zones.model.Server;
31 import com.att.cdp.zones.model.Stack;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
34
35 /**
36  * This interface defines the operations that the provider adapter exposes.
37  * <p>
38  * This interface defines static constant property values that can be used to configure the adapter. These constants are
39  * prefixed with the name PROPERTY_ to indicate that they are configuration properties. These properties are read from
40  * the configuration file for the adapter and are used to define the providers, identity service URLs, and other
41  * information needed by the adapter to interface with an IaaS provider.
42  * </p>
43  */
44 public interface ProviderAdapter extends SvcLogicJavaPlugin {
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.onap.appc.provider.type";
51     /**
52      * The adapter maintains a cache of providers organized by the name of the provider, not its type. This is
53      * equivalent to the system or installation name. All regions within the same installation are assumed to be the
54      * same type.
55      */
56     static final String PROPERTY_PROVIDER_NAME = "org.onap.appc.provider.name";
57     /**
58      * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
59      */
60     static final String PROPERTY_INSTANCE_URL = "org.onap.appc.instance.url";
61     /**
62      * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
63      */
64     static final String PROPERTY_IDENTITY_URL = "org.onap.appc.identity.url";
65     /**
66      * The Rebuild VM flag is an optional payload parameter for the Evacuate API.
67      */
68     static final String PROPERTY_REBUILD_VM = "org.onap.appc.rebuildvm";
69     /**
70      * The target host id is an optional payload parameter for the Evacuate API.
71      */
72     static final String PROPERTY_TARGETHOST_ID = "org.onap.appc.targethost.id";
73     /**
74      * heat stack id to perform operation on stack
75      */
76     static final String PROPERTY_STACK_ID = "org.onap.appc.stack.id";
77     static final String PROPERTY_SNAPSHOT_ID = "snapshot.id";
78     static final String PROPERTY_INPUT_SNAPSHOT_ID = "org.onap.appc.snapshot.id";
79     static final String DG_OUTPUT_PARAM_NAMESPACE = "output.";
80     static final String SKIP_HYPERVISOR_CHECK = "org.onap.appc.skiphypervisorcheck";
81     static final String VOLUME_ID = "org.onap.appc.volumeid";
82     static final String DEVICE = "org.onap.appc.device";
83     /**
84      * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
85      * <p>
86      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
87      * passed to the method are passed as properties in a map. This method expects the following properties to be
88      * defined:
89      * <dl>
90      * <dt>org.onap.appc.provider.type</dt>
91      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
92      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
93      * provider types are legal.</dd>
94      * <dt>org.onap.appc.instance.url</dt>
95      * <dd>The fully qualified URL of the instance to be restarted, as it is known to the provider (i.e., the self-link
96      * URL of the server)</dd>
97      * </dl>
98      * </p>
99      *
100      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
101      *        needed are defined above.
102      * @param context The service logic context of the graph being executed.
103      * @return The <code>Server</code> object that represents the VM being restarted. The returned server object can be
104      *         inspected for the final state of the server once the restart has been completed. The method does not
105      *         return until the restart has either completed or has failed.
106      * @throws APPCException If the server cannot be restarted for some reason
107      */
108     Server restartServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
109     /**
110      * This method is used to stop the indicated server
111      * <p>
112      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
113      * passed to the method are passed as properties in a map. This method expects the following properties to be
114      * defined:
115      * <dl>
116      * <dt>org.onap.appc.provider.type</dt>
117      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
118      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
119      * provider types are legal.</dd>
120      * <dt>org.onap.appc.instance.url</dt>
121      * <dd>The fully qualified URL of the instance to be stopped, as it is known to the provider (i.e., the self-link
122      * URL of the server)</dd>
123      * </dl>
124      * </p>
125      *
126      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
127      *        needed are defined above.
128      * @param context The service logic context of the graph being executed.
129      * @return The <code>Server</code> object that represents the VM being stopped. The returned server object can be
130      *         inspected for the final state of the server once the stop has been completed. The method does not return
131      *         until the stop has either completed or has failed.
132      * @throws APPCException If the server cannot be stopped for some reason
133      */
134     Server stopServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
135     /**
136      * This method is used to start the indicated server
137      * <p>
138      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
139      * passed to the method are passed as properties in a map. This method expects the following properties to be
140      * defined:
141      * <dl>
142      * <dt>org.onap.appc.provider.type</dt>
143      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
144      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
145      * provider types are legal.</dd>
146      * <dt>org.onap.appc.instance.url</dt>
147      * <dd>The fully qualified URL of the instance to be started, as it is known to the provider (i.e., the self-link
148      * URL of the server)</dd>
149      * </dl>
150      * </p>
151      *
152      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
153      *        needed are defined above.
154      * @param context The service logic context of the graph being executed.
155      * @return The <code>Server</code> object that represents the VM being started. The returned server object can be
156      *         inspected for the final state of the server once the start has been completed. The method does not return
157      *         until the start has either completed or has failed.
158      * @throws APPCException If the server cannot be started for some reason
159      */
160     Server startServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
161     /**
162      * This method is used to rebuild the indicated server
163      * <p>
164      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
165      * passed to the method are passed as properties in a map. This method expects the following properties to be
166      * defined:
167      * <dl>
168      * <dt>org.onap.appc.provider.type</dt>
169      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
170      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
171      * provider types are legal.</dd>
172      * <dt>org.onap.appc.instance.url</dt>
173      * <dd>The fully qualified URL of the instance to be rebuilt, as it is known to the provider (i.e., the self-link
174      * URL of the server)</dd>
175      * </dl>
176      * </p>
177      *
178      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
179      *        needed are defined above.
180      * @param context The service logic context of the graph being executed.
181      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
182      *         inspected for the final state of the server once the rebuild has been completed. The method does not
183      *         return until the rebuild has either completed or has failed.
184      * @throws APPCException If the server cannot be rebuilt for some reason
185      */
186     Server rebuildServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
187     /**
188      * This method is used to terminate the indicated server
189      * <p>
190      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
191      * passed to the method are passed as properties in a map. This method expects the following properties to be
192      * defined:
193      * <dl>
194      * <dt>org.onap.appc.provider.type</dt>
195      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
196      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
197      * provider types are legal.</dd>
198      * <dt>org.onap.appc.instance.url</dt>
199      * <dd>The fully qualified URL of the instance to be terminate, as it is known to the provider (i.e., the self-link
200      * URL of the server)</dd>
201      * </dl>
202      * </p>
203      *
204      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
205      *        needed are defined above.
206      * @param context 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 If the server cannot be terminate for some reason
211      */
212     Server terminateServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
213     /**
214      * Returns the symbolic name of the adapter
215      *
216      * @return The adapter name
217      */
218     String getAdapterName();
219     Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
220     Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
221     Server vmStatuschecker(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
222     Stack terminateStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
223     Stack snapshotStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
224     Stack restoreStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
225     Server attachVolume(Map<String, String> params, SvcLogicContext ctx)  throws APPCException;
226     Server dettachVolume(Map<String, String> params, SvcLogicContext ctx)  throws APPCException;
227     /**
228      * This method is used to do the lookup of the indicated server
229      * <p>
230      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
231      * passed to the method are passed as properties in a map. This method expects the following properties to be
232      * defined:
233      * <dl>
234      * <dt>org.onap.appc.provider.type</dt>
235      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
236      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
237      * provider types are legal.</dd>
238      * <dt>org.onap.appc.instance.url</dt>
239      * <dd>The fully qualified URL of the instance to be lookup, as it is known to the provider (i.e., the self-link URL
240      * of the server)</dd>
241      * </dl>
242      * </p>
243      *
244      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
245      *        needed are defined above.
246      * @param context The service logic context of the graph being executed.
247      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
248      *         inspected for the final state of the server once the rebuild has been completed. The method does not
249      *         return until the rebuild has either completed or has failed.
250      * @throws APPCException If the server cannot be found for some reason
251      */
252     Server lookupServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
253     /**
254      * The
255      *
256      * @param params A map of name-value pairs that supply the parameters needed by this method. The properties needed
257      *        are defined above.
258      * @param ctx The service logic context of the graph being executed.
259      * @return The <code>Image</code> object that represents the VM being restarted. The returned server object can be
260      *         inspected for the final state of the server once the restart has been completed. The method does not
261      *         return until the restart has either completed or has failed.
262      * @throws APPCException If the server cannot be restarted for some reason
263      */
264     Image createSnapshot(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
265 }