@@ -50,8 +50,8 @@ public class InfrastructureManager {
5050 private static final String PATH_SEPARATOR = "/" ;
5151 // IM REST parameters
5252 private static final String REST_PARAMETER_NAME_CONTEXT = "context" ;
53+ private static final String REST_PARAMETER_NAME_ASYNC = "async" ;
5354 private static final String REST_PARAMETER_NAME_VMLIST = "vm_list" ;
54- private static final String REST_PARAMETER_INFRASTRUCTURE_OUTPUTS = "outputs" ;
5555
5656 private final ImClient imClient ;
5757
@@ -248,6 +248,7 @@ public void destroyInfrastructure(String infId) throws ImClientException {
248248 * just after the VM addition
249249 * @return : list of URIs of the new virtual machines
250250 */
251+ @ Deprecated
251252 public InfrastructureUris addResource (String infId , String radlFile ,
252253 BodyContentType bodyContentType , boolean ... context )
253254 throws ImClientException {
@@ -258,6 +259,133 @@ public InfrastructureUris addResource(String infId, String radlFile,
258259 restParameter );
259260 }
260261
262+ /**
263+ * Add the resources specified in the body contents to the infrastructure with
264+ * ID 'infId'. The RADL restrictions are the same as in
265+ * <a href="http://www.grycap.upv.es/im/doc/xmlrpc.html#addresource-xmlrpc">
266+ * RPC-XML AddResource</a><br>
267+ * If success, it is returned a list of URIs of the new virtual machines. <br>
268+ * The context parameter is optional and is a flag to specify if the
269+ * contextualization step will be launched just after the VM addition.<br>
270+ * If not specified the contextualization flag is set to True.
271+ *
272+ * @param infId
273+ * : infrastructure id
274+ * @param radlFile
275+ * : file with the virtual machine properties and configuration
276+ * @param bodyContentType
277+ * : set the body content type. Can be RADL, RADL_JSON or TOSCA.
278+ * @return : list of URIs of the new virtual machines
279+ */
280+ public InfrastructureUris addResource (String infId , String radlFile ,
281+ BodyContentType bodyContentType ) throws ImClientException {
282+ return addResourcesWithParameters (infId , radlFile , bodyContentType );
283+ }
284+
285+ /**
286+ * Add the resources specified in the body contents to the infrastructure with
287+ * ID 'infId'. The RADL restrictions are the same as in
288+ * <a href="http://www.grycap.upv.es/im/doc/xmlrpc.html#addresource-xmlrpc">
289+ * RPC-XML AddResource</a><br>
290+ * If success, it is returned a list of URIs of the new virtual machines. <br>
291+ * The context parameter is optional and is a flag to specify if the
292+ * contextualization step will be launched just after the VM addition.<br>
293+ * If not specified the contextualization flag is set to True.
294+ *
295+ * @param infId
296+ * : infrastructure id
297+ * @param radlFile
298+ * : file with the virtual machine properties and configuration
299+ * @param bodyContentType
300+ * : set the body content type. Can be RADL, RADL_JSON or TOSCA.
301+ * @param context
302+ * : flag to specify if the contextualization step will be launched
303+ * just after the VM addition
304+ * @param async
305+ * : flag to specify if the call has to wait for the VMs to be
306+ * created.
307+ * @return : list of URIs of the new virtual machines
308+ */
309+ public InfrastructureUris addResource (String infId , String radlFile ,
310+ BodyContentType bodyContentType , boolean context , boolean async )
311+ throws ImClientException {
312+
313+ RestParameter ctxParameter =
314+ createCallParameters (REST_PARAMETER_NAME_CONTEXT , context );
315+ RestParameter asyncParameter =
316+ createCallParameters (REST_PARAMETER_NAME_ASYNC , async );
317+
318+ return getImClient ().post (PATH_INFRASTRUCTURES + PATH_SEPARATOR + infId ,
319+ radlFile , bodyContentType .getValue (), InfrastructureUris .class ,
320+ ctxParameter , asyncParameter );
321+ }
322+
323+ /**
324+ * Add the resources specified in the body contents to the infrastructure with
325+ * ID 'infId'. The RADL restrictions are the same as in
326+ * <a href="http://www.grycap.upv.es/im/doc/xmlrpc.html#addresource-xmlrpc">
327+ * RPC-XML AddResource</a><br>
328+ * If success, it is returned a list of URIs of the new virtual machines. <br>
329+ * This call will not wait the VMs to be created.
330+ *
331+ * @param infId
332+ * : infrastructure id
333+ * @param radlFile
334+ * : file with the virtual machine properties and configuration
335+ * @param bodyContentType
336+ * : set the body content type. Can be RADL, RADL_JSON or TOSCA.
337+ * @return : list of URIs of the new virtual machines
338+ */
339+ public InfrastructureUris addAsyncResource (String infId , String radlFile ,
340+ BodyContentType bodyContentType ) throws ImClientException {
341+ RestParameter asyncParameter =
342+ createCallParameters (REST_PARAMETER_NAME_ASYNC , true );
343+ return addResourcesWithParameters (infId , radlFile , bodyContentType ,
344+ asyncParameter );
345+ }
346+
347+ /**
348+ * Add the resources specified in the body contents to the infrastructure with
349+ * ID 'infId'. The RADL restrictions are the same as in
350+ * <a href="http://www.grycap.upv.es/im/doc/xmlrpc.html#addresource-xmlrpc">
351+ * RPC-XML AddResource</a><br>
352+ * If success, it is returned a list of URIs of the new virtual machines. <br>
353+ * This call activates the contextualization step just after the VM addition.
354+ * <br>
355+ *
356+ * @param infId
357+ * : infrastructure id
358+ * @param radlFile
359+ * : file with the virtual machine properties and configuration
360+ * @param bodyContentType
361+ * : set the body content type. Can be RADL, RADL_JSON or TOSCA.
362+ * @return : list of URIs of the new virtual machines
363+ */
364+ public InfrastructureUris addResourceAndContextualize (String infId ,
365+ String radlFile , BodyContentType bodyContentType )
366+ throws ImClientException {
367+
368+ RestParameter ctxParameter =
369+ createCallParameters (REST_PARAMETER_NAME_CONTEXT , true );
370+ return addResourcesWithParameters (infId , radlFile , bodyContentType ,
371+ ctxParameter );
372+ }
373+
374+ private InfrastructureUris addResourcesWithParameters (String infId ,
375+ String radlFile , BodyContentType bodyContentType ,
376+ RestParameter ... parameters ) throws ImClientException {
377+
378+ return getImClient ().post (PATH_INFRASTRUCTURES + PATH_SEPARATOR + infId ,
379+ radlFile , bodyContentType .getValue (), InfrastructureUris .class ,
380+ parameters );
381+ }
382+
383+ private static RestParameter createCallParameters (String paramName ,
384+ Object value ) {
385+ return new Parameter (paramName , value );
386+ }
387+
388+ @ Deprecated
261389 private static RestParameter createCallParameters (boolean ... context ) {
262390 return (context != null && context .length > 0 )
263391 ? new Parameter (REST_PARAMETER_NAME_CONTEXT , context [0 ])
@@ -498,7 +626,7 @@ public void reconfigure(String infId, String radlFile,
498626 public InfOutputValues getInfrastructureOutputs (String infId )
499627 throws ImClientException {
500628 String path = PATH_INFRASTRUCTURES + PATH_SEPARATOR + infId + PATH_SEPARATOR
501- + REST_PARAMETER_INFRASTRUCTURE_OUTPUTS ;
629+ + ImValues . OUTPUTS ;
502630 return getImClient ().get (path , InfOutputValues .class );
503631 }
504632
0 commit comments