1eebe5023abd4a00ce8799e2277c7235e3ceecde
[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 PAYLOAD = "payload";
82     static final String VOLUME_ID = "org.onap.appc.volumeid";
83     static final String DEVICE = "org.onap.appc.device";
84     static final String REBOOT_TYPE = "org.onap.appc.reboot.type";
85     static final String PROPERTY_REQUEST_SNAPSHOT_ID = "snapshot-id";
86     /**
87      * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
88      * <p>
89      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
90      * passed to the method are passed as properties in a map. This method expects the following properties to be
91      * defined:
92      * <dl>
93      * <dt>org.onap.appc.provider.type</dt>
94      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
95      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
96      * provider types are legal.</dd>
97      * <dt>org.onap.appc.instance.url</dt>
98      * <dd>The fully qualified URL of the instance to be restarted, as it is known to the provider (i.e., the self-link
99      * URL of the server)</dd>
100      * </dl>
101      * </p>
102      *
103      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
104      *        needed are defined above.
105      * @param context The service logic context of the graph being executed.
106      * @return The <code>Server</code> object that represents the VM being restarted. The returned server object can be
107      *         inspected for the final state of the server once the restart has been completed. The method does not
108      *         return until the restart has either completed or has failed.
109      * @throws APPCException If the server cannot be restarted for some reason
110      */
111     Server restartServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
112     /**
113      * This method is used to stop the indicated server
114      * <p>
115      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
116      * passed to the method are passed as properties in a map. This method expects the following properties to be
117      * defined:
118      * <dl>
119      * <dt>org.onap.appc.provider.type</dt>
120      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
121      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
122      * provider types are legal.</dd>
123      * <dt>org.onap.appc.instance.url</dt>
124      * <dd>The fully qualified URL of the instance to be stopped, as it is known to the provider (i.e., the self-link
125      * URL of the server)</dd>
126      * </dl>
127      * </p>
128      *
129      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
130      *        needed are defined above.
131      * @param context The service logic context of the graph being executed.
132      * @return The <code>Server</code> object that represents the VM being stopped. The returned server object can be
133      *         inspected for the final state of the server once the stop has been completed. The method does not return
134      *         until the stop has either completed or has failed.
135      * @throws APPCException If the server cannot be stopped for some reason
136      */
137     Server stopServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
138     /**
139      * This method is used to start the indicated server
140      * <p>
141      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
142      * passed to the method are passed as properties in a map. This method expects the following properties to be
143      * defined:
144      * <dl>
145      * <dt>org.onap.appc.provider.type</dt>
146      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
147      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
148      * provider types are legal.</dd>
149      * <dt>org.onap.appc.instance.url</dt>
150      * <dd>The fully qualified URL of the instance to be started, as it is known to the provider (i.e., the self-link
151      * URL of the server)</dd>
152      * </dl>
153      * </p>
154      *
155      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
156      *        needed are defined above.
157      * @param context The service logic context of the graph being executed.
158      * @return The <code>Server</code> object that represents the VM being started. The returned server object can be
159      *         inspected for the final state of the server once the start has been completed. The method does not return
160      *         until the start has either completed or has failed.
161      * @throws APPCException If the server cannot be started for some reason
162      */
163     Server startServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
164     /**
165      * This method is used to rebuild the indicated server
166      * <p>
167      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
168      * passed to the method are passed as properties in a map. This method expects the following properties to be
169      * defined:
170      * <dl>
171      * <dt>org.onap.appc.provider.type</dt>
172      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
173      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
174      * provider types are legal.</dd>
175      * <dt>org.onap.appc.instance.url</dt>
176      * <dd>The fully qualified URL of the instance to be rebuilt, as it is known to the provider (i.e., the self-link
177      * URL of the server)</dd>
178      * </dl>
179      * </p>
180      *
181      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
182      *        needed are defined above.
183      * @param context The service logic context of the graph being executed.
184      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
185      *         inspected for the final state of the server once the rebuild has been completed. The method does not
186      *         return until the rebuild has either completed or has failed.
187      * @throws APPCException If the server cannot be rebuilt for some reason
188      */
189     Server rebuildServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
190     /**
191      * This method is used to terminate the indicated server
192      * <p>
193      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
194      * passed to the method are passed as properties in a map. This method expects the following properties to be
195      * defined:
196      * <dl>
197      * <dt>org.onap.appc.provider.type</dt>
198      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
199      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
200      * provider types are legal.</dd>
201      * <dt>org.onap.appc.instance.url</dt>
202      * <dd>The fully qualified URL of the instance to be terminate, as it is known to the provider (i.e., the self-link
203      * URL of the server)</dd>
204      * </dl>
205      * </p>
206      *
207      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
208      *        needed are defined above.
209      * @param context The service logic context of the graph being executed.
210      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
211      *         inspected for the final state of the server once the rebuild has been completed. The method does not
212      *         return until the rebuild has either completed or has failed.
213      * @throws APPCException If the server cannot be terminate for some reason
214      */
215     Server terminateServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
216     /**
217      * Returns the symbolic name of the adapter
218      *
219      * @return The adapter name
220      */
221     String getAdapterName();
222     Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
223     Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
224     Server vmStatuschecker(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
225     Stack terminateStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
226     Stack snapshotStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
227     Stack restoreStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
228     Server attachVolume(Map<String, String> params, SvcLogicContext ctx)  throws APPCException;
229     Server dettachVolume(Map<String, String> params, SvcLogicContext ctx)  throws APPCException;
230     /**
231      * This method is used to do the lookup of the indicated server
232      * <p>
233      * This method is invoked from a directed graph as an <code>Executor</code> node. This means that the parameters
234      * passed to the method are passed as properties in a map. This method expects the following properties to be
235      * defined:
236      * <dl>
237      * <dt>org.onap.appc.provider.type</dt>
238      * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. This is used by the CDP IaaS
239      * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
240      * provider types are legal.</dd>
241      * <dt>org.onap.appc.instance.url</dt>
242      * <dd>The fully qualified URL of the instance to be lookup, as it is known to the provider (i.e., the self-link URL
243      * of the server)</dd>
244      * </dl>
245      * </p>
246      *
247      * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
248      *        needed are defined above.
249      * @param context The service logic context of the graph being executed.
250      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
251      *         inspected for the final state of the server once the rebuild has been completed. The method does not
252      *         return until the rebuild has either completed or has failed.
253      * @throws APPCException If the server cannot be found for some reason
254      */
255     Server lookupServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
256     /**
257      * The
258      *
259      * @param params A map of name-value pairs that supply the parameters needed by this method. The properties needed
260      *        are defined above.
261      * @param ctx The service logic context of the graph being executed.
262      * @return The <code>Image</code> object that represents the VM being restarted. The returned server object can be
263      *         inspected for the final state of the server once the restart has been completed. The method does not
264      *         return until the restart has either completed or has failed.
265      * @throws APPCException If the server cannot be restarted for some reason
266      */
267     Image createSnapshot(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
268     
269 }