From 517a288df87fcd0955718b5d489d2966ccd5f912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 28 Jun 2013 19:02:28 +0200 Subject: [PATCH] Feature #2124: Template append action in Java OCA --- .../opennebula/client/cluster/Cluster.java | 22 +++++++++++++++---- .../client/datastore/Datastore.java | 20 ++++++++++++++--- .../opennebula/client/document/Document.java | 14 +++++++++++- .../src/org/opennebula/client/host/Host.java | 20 ++++++++++++++--- .../org/opennebula/client/image/Image.java | 20 ++++++++++++++--- .../opennebula/client/template/Template.java | 20 ++++++++++++++--- .../src/org/opennebula/client/user/User.java | 20 ++++++++++++++--- .../opennebula/client/vm/VirtualMachine.java | 20 ++++++++++++++--- .../client/vnet/VirtualNetwork.java | 20 ++++++++++++++--- 9 files changed, 150 insertions(+), 26 deletions(-) diff --git a/src/oca/java/src/org/opennebula/client/cluster/Cluster.java b/src/oca/java/src/org/opennebula/client/cluster/Cluster.java index f88a73d6e5..15ea8b3e31 100644 --- a/src/oca/java/src/org/opennebula/client/cluster/Cluster.java +++ b/src/oca/java/src/org/opennebula/client/cluster/Cluster.java @@ -106,11 +106,13 @@ public class Cluster extends PoolElement{ * @param client XML-RPC Client. * @param id The id of the target cluster we want to modify. * @param new_template New template contents. + * @param append True to append new attributes instead of replace the whole template * @return If successful the message contains the cluster id. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -223,7 +225,7 @@ public class Cluster extends PoolElement{ { return delete(client, id); } - + /** * Replaces the cluster template. * @@ -232,7 +234,19 @@ public class Cluster extends PoolElement{ */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces the cluster template. + * + * @param new_template New cluster template. + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the cluster id. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/datastore/Datastore.java b/src/oca/java/src/org/opennebula/client/datastore/Datastore.java index fde6ee827a..26a03b8b60 100644 --- a/src/oca/java/src/org/opennebula/client/datastore/Datastore.java +++ b/src/oca/java/src/org/opennebula/client/datastore/Datastore.java @@ -121,11 +121,13 @@ public class Datastore extends PoolElement * @param client XML-RPC Client. * @param id The id of the target datastore we want to modify. * @param new_template New datastore contents. + * @param append True to append new attributes instead of replace the whole template * @return If successful the message contains the datastore id. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -245,7 +247,19 @@ public class Datastore extends PoolElement */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces the datastore template. + * + * @param new_template New datastore template. + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the datastore id. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/document/Document.java b/src/oca/java/src/org/opennebula/client/document/Document.java index 94f5c5e975..a564447295 100644 --- a/src/oca/java/src/org/opennebula/client/document/Document.java +++ b/src/oca/java/src/org/opennebula/client/document/Document.java @@ -131,7 +131,19 @@ public abstract class Document extends PoolElement */ public OneResponse update(String new_document) { - return client.call(UPDATE, id, new_document); + return update(new_document, false); + } + + /** + * Replaces the document template contents. + * + * @param new_document New template contents. + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the document id. + */ + public OneResponse update(String new_document, boolean append) + { + return client.call(UPDATE, id, new_document, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/host/Host.java b/src/oca/java/src/org/opennebula/client/host/Host.java index b81dd1ea79..df36d87eae 100644 --- a/src/oca/java/src/org/opennebula/client/host/Host.java +++ b/src/oca/java/src/org/opennebula/client/host/Host.java @@ -167,11 +167,13 @@ public class Host extends PoolElement{ * @param client XML-RPC Client. * @param id The image id of the target host we want to modify. * @param new_template New template contents + * @param append True to append new attributes instead of replace the whole template * @return If successful the message contains the host id. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -252,7 +254,19 @@ public class Host extends PoolElement{ */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces the template contents. + * + * @param new_template New template contents + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the host id. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/image/Image.java b/src/oca/java/src/org/opennebula/client/image/Image.java index 045cca8e4f..ebbe9b7a37 100644 --- a/src/oca/java/src/org/opennebula/client/image/Image.java +++ b/src/oca/java/src/org/opennebula/client/image/Image.java @@ -125,11 +125,13 @@ public class Image extends PoolElement * @param client XML-RPC Client. * @param id The image id of the target image we want to modify. * @param new_template New template contents + * @param append True to append new attributes instead of replace the whole template * @return If successful the message contains the image id. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -314,7 +316,19 @@ public class Image extends PoolElement */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces the template contents. + * + * @param new_template New template contents + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the image id. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/template/Template.java b/src/oca/java/src/org/opennebula/client/template/Template.java index 42def6a923..84ad1342f1 100644 --- a/src/oca/java/src/org/opennebula/client/template/Template.java +++ b/src/oca/java/src/org/opennebula/client/template/Template.java @@ -105,11 +105,13 @@ public class Template extends PoolElement * @param client XML-RPC Client. * @param id The template id of the target template we want to modify. * @param new_template New template contents. + * @param append True to append new attributes instead of replace the whole template * @return If successful the message contains the template id. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -272,7 +274,19 @@ public class Template extends PoolElement */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces the template contents. + * + * @param new_template New template contents. + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the template id. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/user/User.java b/src/oca/java/src/org/opennebula/client/user/User.java index 869eaa36f7..29c9fa0ca3 100644 --- a/src/oca/java/src/org/opennebula/client/user/User.java +++ b/src/oca/java/src/org/opennebula/client/user/User.java @@ -170,11 +170,13 @@ public class User extends PoolElement{ * @param client XML-RPC Client. * @param id The user id of the target user we want to modify. * @param new_template New template contents. + * @param append True to append new attributes instead of replace the whole template * @return If successful the message contains the user id. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -272,7 +274,19 @@ public class User extends PoolElement{ */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces the user template contents. + * + * @param new_template New template contents. + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the user id. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index 3bdad77099..9d479a8f68 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -204,11 +204,13 @@ public class VirtualMachine extends PoolElement{ * @param client XML-RPC Client. * @param id The id of the target vm. * @param new_template New template contents + * @param append True to append new attributes instead of replace the whole template * @return If an error occurs the error message contains the reason. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -779,7 +781,19 @@ public class VirtualMachine extends PoolElement{ */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces this VM's user template contents. + * + * @param new_template New template contents + * @param append True to append new attributes instead of replace the whole template + * @return If an error occurs the error message contains the reason. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /** diff --git a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java index f1a03436a7..775ab20ddb 100644 --- a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java +++ b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java @@ -266,11 +266,13 @@ public class VirtualNetwork extends PoolElement{ * @param client XML-RPC Client. * @param id The vnet id of the target vnet we want to modify. * @param new_template New template contents. + * @param append True to append new attributes instead of replace the whole template * @return If successful the message contains the vnet id. */ - public static OneResponse update(Client client, int id, String new_template) + public static OneResponse update(Client client, int id, String new_template, + boolean append) { - return client.call(UPDATE, id, new_template); + return client.call(UPDATE, id, new_template, append ? 1 : 0); } /** @@ -502,7 +504,19 @@ public class VirtualNetwork extends PoolElement{ */ public OneResponse update(String new_template) { - return update(client, id, new_template); + return update(new_template, false); + } + + /** + * Replaces the VirtualNetwork template contents. + * + * @param new_template New template contents. + * @param append True to append new attributes instead of replace the whole template + * @return If successful the message contains the vnet id. + */ + public OneResponse update(String new_template, boolean append) + { + return update(client, id, new_template, append); } /**