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