diff --git a/share/doc/xsd/vm.xsd b/share/doc/xsd/vm.xsd
index ae3b333c6f..a6f1b96bbe 100644
--- a/share/doc/xsd/vm.xsd
+++ b/share/doc/xsd/vm.xsd
@@ -87,6 +87,7 @@
+
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 583a06ff10..6b1509c165 100644
--- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java
+++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java
@@ -175,7 +175,7 @@ public class VirtualMachine extends PoolElement{
* @param client XML-RPC Client.
* @param id The id of the target vm.
* @param new_template New template contents
- * @return If successful the message contains the vm id.
+ * @return If an error occurs the error message contains the reason.
*/
public static OneResponse update(Client client, int id, String new_template)
{
@@ -558,6 +558,17 @@ public class VirtualMachine extends PoolElement{
return rename(client, id, name);
}
+ /**
+ * Replaces this VM's user template contents.
+ *
+ * @param new_template New template contents
+ * @return If an error occurs the error message contains the reason.
+ */
+ public OneResponse update(String new_template)
+ {
+ return client.call(UPDATE, id, new_template);
+ }
+
// =================================
// Helpers
// =================================
diff --git a/src/onedb/3.8.1_to_3.9.80.rb b/src/onedb/3.8.1_to_3.9.80.rb
index d03487348a..021b4039c3 100644
--- a/src/onedb/3.8.1_to_3.9.80.rb
+++ b/src/onedb/3.8.1_to_3.9.80.rb
@@ -345,6 +345,35 @@ module Migrator
@db.run "DROP TABLE old_cluster_pool;"
+ ########################################################################
+ # Feature #1556: New elem USER_TEMPLATE
+ ########################################################################
+
+ @db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
+ @db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
+
+ @db.fetch("SELECT * FROM old_vm_pool") do |row|
+
+ doc = Document.new(row[:body])
+ doc.root.add_element("USER_TEMPLATE")
+
+ @db[:vm_pool].insert(
+ :oid => row[:oid],
+ :name => row[:name],
+ :body => doc.root.to_s,
+ :uid => row[:uid],
+ :gid => row[:gid],
+ :last_poll => row[:last_poll],
+ :state => row[:state],
+ :lcm_state => row[:lcm_state],
+ :owner_u => row[:owner_u],
+ :group_u => row[:group_u],
+ :other_u => row[:other_u])
+ end
+
+ @db.run "DROP TABLE old_vm_pool;"
+
+
########################################################################
#
# Banner for the new /var/lib/one/vms directory