From bf42ee22d68a96ad1c46d48410080461b178d178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 10 Dec 2012 12:24:09 +0100 Subject: [PATCH] Feature #1686: Add rename methods to java OCA --- .../opennebula/client/document/Document.java | 12 +++++++++ .../org/opennebula/client/image/Image.java | 25 +++++++++++++++++ .../opennebula/client/template/Template.java | 25 +++++++++++++++++ .../opennebula/client/vm/VirtualMachine.java | 25 +++++++++++++++++ .../client/vnet/VirtualNetwork.java | 27 ++++++++++++++++++- 5 files changed, 113 insertions(+), 1 deletion(-) 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 281e9617b6..7f287a73f1 100644 --- a/src/oca/java/src/org/opennebula/client/document/Document.java +++ b/src/oca/java/src/org/opennebula/client/document/Document.java @@ -65,6 +65,7 @@ public abstract class Document extends PoolElement private static final String CHOWN = METHOD_PREFIX + "chown"; private static final String CHMOD = METHOD_PREFIX + "chmod"; private static final String CLONE = METHOD_PREFIX + "clone"; + private static final String RENAME = METHOD_PREFIX + "rename"; /** * Creates a new Document representation. @@ -215,6 +216,17 @@ public abstract class Document extends PoolElement return client.call(CLONE, id, name); } + /** + * Renames this document + * + * @param name New name for the document. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Helpers // ================================= 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 62d8185790..700371bd2a 100644 --- a/src/oca/java/src/org/opennebula/client/image/Image.java +++ b/src/oca/java/src/org/opennebula/client/image/Image.java @@ -38,6 +38,7 @@ public class Image extends PoolElement private static final String CHMOD = METHOD_PREFIX + "chmod"; private static final String CHTYPE = METHOD_PREFIX + "chtype"; private static final String CLONE = METHOD_PREFIX + "clone"; + private static final String RENAME = METHOD_PREFIX + "rename"; private static final String[] IMAGE_STATES = {"INIT", "READY", "USED", "DISABLED", "LOCKED", @@ -265,6 +266,19 @@ public class Image extends PoolElement return client.call(CLONE, id, name); } + /** + * Renames this Image + * + * @param client XML-RPC Client. + * @param id The Image id of the target Image. + * @param name New name for the Image. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -498,6 +512,17 @@ public class Image extends PoolElement return clone(client, id, name); } + /** + * Renames this Image + * + * @param name New name for the Image. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + // ================================= // Helpers // ================================= 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 dd48c96254..a3a39c8755 100644 --- a/src/oca/java/src/org/opennebula/client/template/Template.java +++ b/src/oca/java/src/org/opennebula/client/template/Template.java @@ -36,6 +36,7 @@ public class Template extends PoolElement private static final String CHMOD = METHOD_PREFIX + "chmod"; private static final String INSTANTIATE = METHOD_PREFIX + "instantiate"; private static final String CLONE = METHOD_PREFIX + "clone"; + private static final String RENAME = METHOD_PREFIX + "rename"; /** * Creates a new Template representation. @@ -219,6 +220,19 @@ public class Template extends PoolElement return client.call(CLONE, id, name); } + /** + * Renames this Template + * + * @param client XML-RPC Client. + * @param id The Template id of the target Template. + * @param name New name for the Template. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -400,6 +414,17 @@ public class Template extends PoolElement return clone(client, id, name); } + /** + * Renames this Template + * + * @param name New name for the Template. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + // ================================= // Helpers // ================================= 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 d402c835d2..0b7d837f87 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -39,6 +39,7 @@ public class VirtualMachine extends PoolElement{ private static final String MONITORING = METHOD_PREFIX + "monitoring"; private static final String ATTACH = METHOD_PREFIX + "attach"; private static final String DETACH = METHOD_PREFIX + "detach"; + private static final String RENAME = METHOD_PREFIX + "rename"; private static final String[] VM_STATES = { @@ -273,6 +274,19 @@ public class VirtualMachine extends PoolElement{ return client.call(DETACH, id, diskId); } + /** + * Renames this VM + * + * @param client XML-RPC Client. + * @param id The VM id of the target VM. + * @param name New name for the VM. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -486,6 +500,17 @@ public class VirtualMachine extends PoolElement{ return detachdisk(client, id, diskId); } + /** + * Renames this VM + * + * @param name New name for the VM. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + // ================================= // Helpers // ================================= 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 112d4adec5..fd65e5584c 100644 --- a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java +++ b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java @@ -38,6 +38,7 @@ public class VirtualNetwork extends PoolElement{ private static final String UPDATE = METHOD_PREFIX + "update"; private static final String HOLD = METHOD_PREFIX + "hold"; private static final String RELEASE = METHOD_PREFIX + "release"; + private static final String RENAME = METHOD_PREFIX + "rename"; /** * Creates a new virtual network representation. @@ -263,7 +264,7 @@ public class VirtualNetwork extends PoolElement{ * Replaces the VirtualNetwork template contents. * * @param client XML-RPC Client. - * @param id The user id of the target vnet we want to modify. + * @param id The vnet id of the target vnet we want to modify. * @param new_template New template contents. * @return If successful the message contains the vnet id. */ @@ -272,6 +273,19 @@ public class VirtualNetwork extends PoolElement{ return client.call(UPDATE, id, new_template); } + /** + * Renames this VirtualNetwork + * + * @param client XML-RPC Client. + * @param id The VirtualNetwork id of the target VirtualNetwork. + * @param name New name for the VirtualNetwork. + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse rename(Client client, int id, String name) + { + return client.call(RENAME, id, name); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -491,6 +505,17 @@ public class VirtualNetwork extends PoolElement{ return update(client, id, new_template); } + /** + * Renames this VirtualNetwork + * + * @param name New name for the VirtualNetwork. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse rename(String name) + { + return rename(client, id, name); + } + // ================================= // Helpers // =================================