diff --git a/include/DispatchManager.h b/include/DispatchManager.h
index 02558f3eae..35df649ab4 100644
--- a/include/DispatchManager.h
+++ b/include/DispatchManager.h
@@ -396,6 +396,23 @@ public:
int did,
int snap_id,
string& error_str);
+
+ /**
+ * Deletes a disk snapshot
+ *
+ * @param vid VirtualMachine identification
+ * @param did DISK identification
+ * @param snap_id Snapshot to be restored
+ * @param error_str Error reason, if any
+ *
+ * @return 0 on success, -1 otherwise
+ */
+ int disk_snapshot_delete(
+ int vid,
+ int did,
+ int snap_id,
+ string& error_str);
+
private:
/**
* Thread id for the Dispatch Manager
diff --git a/include/RequestManagerVirtualMachine.h b/include/RequestManagerVirtualMachine.h
index ac7fc030a6..9a3eb46f06 100644
--- a/include/RequestManagerVirtualMachine.h
+++ b/include/RequestManagerVirtualMachine.h
@@ -436,4 +436,21 @@ public:
RequestAttributes& att);
};
+/* -------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
+
+class VirtualMachineDiskSnapshotDelete: public RequestManagerVirtualMachine
+{
+public:
+ VirtualMachineDiskSnapshotDelete():
+ RequestManagerVirtualMachine("VirtualMachineDiskSnapshotDelete",
+ "Deletes a disk snapshot",
+ "A:siii"){};
+
+ ~VirtualMachineDiskSnapshotDelete(){};
+
+ void request_execute(xmlrpc_c::paramList const& _paramList,
+ RequestAttributes& att);
+};
+
#endif
diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h
index c8669b2c91..de7b6467b1 100644
--- a/include/VirtualMachine.h
+++ b/include/VirtualMachine.h
@@ -157,7 +157,8 @@ public:
PROLOG_RESUME_FAILURE = 49,
PROLOG_UNDEPLOY_FAILURE = 50,
DISK_SNAPSHOT_POWEROFF = 51,
- DISK_SNAPSHOT_REVERT_POWEROFF = 52
+ DISK_SNAPSHOT_REVERT_POWEROFF = 52,
+ DISK_SNAPSHOT_DELETE_POWEROFF = 53
};
static int lcm_state_from_str(string& st, LcmState& state)
@@ -215,6 +216,7 @@ public:
else if ( st == "PROLOG_UNDEPLOY_FAILURE") { state = PROLOG_UNDEPLOY_FAILURE; }
else if ( st == "DISK_SNAPSHOT_POWEROFF") { state = DISK_SNAPSHOT_POWEROFF; }
else if ( st == "DISK_SNAPSHOT_REVERT_POWEROFF") { state = DISK_SNAPSHOT_REVERT_POWEROFF; }
+ else if ( st == "DISK_SNAPSHOT_DELETE_POWEROFF") { state = DISK_SNAPSHOT_DELETE_POWEROFF; }
else {return -1;}
return 0;
@@ -275,6 +277,7 @@ public:
case PROLOG_UNDEPLOY_FAILURE: st = "PROLOG_UNDEPLOY_FAILURE"; break;
case DISK_SNAPSHOT_POWEROFF: st = "DISK_SNAPSHOT_POWEROFF"; break;
case DISK_SNAPSHOT_REVERT_POWEROFF: st = "DISK_SNAPSHOT_REVERT_POWEROFF"; break;
+ case DISK_SNAPSHOT_DELETE_POWEROFF: st = "DISK_SNAPSHOT_DELETE_POWEROFF"; break;
}
return st;
diff --git a/share/doc/xsd/acct.xsd b/share/doc/xsd/acct.xsd
index c09c26bdb5..9b1b9d1870 100644
--- a/share/doc/xsd/acct.xsd
+++ b/share/doc/xsd/acct.xsd
@@ -165,7 +165,8 @@
PROLOG_RESUME_FAILURE = 49,
PROLOG_UNDEPLOY_FAILURE = 50,
DISK_SNAPSHOT_POWEROFF = 51,
- DISK_SNAPSHOT_REVERT_POWEROFF = 52
+ DISK_SNAPSHOT_REVERT_POWEROFF = 52,
+ DISK_SNAPSHOT_DELETE_POWEROFF = 53
-->
diff --git a/share/doc/xsd/vm.xsd b/share/doc/xsd/vm.xsd
index 493683cb5f..fb37186bf9 100644
--- a/share/doc/xsd/vm.xsd
+++ b/share/doc/xsd/vm.xsd
@@ -98,7 +98,8 @@
PROLOG_RESUME_FAILURE = 49,
PROLOG_UNDEPLOY_FAILURE = 50,
DISK_SNAPSHOT_POWEROFF = 51,
- DISK_SNAPSHOT_REVERT_POWEROFF = 52
+ DISK_SNAPSHOT_REVERT_POWEROFF = 52,
+ DISK_SNAPSHOT_DELETE_POWEROFF = 53
-->
diff --git a/src/cli/onevm b/src/cli/onevm
index 927e92bfea..4ae4f74cb6 100755
--- a/src/cli/onevm
+++ b/src/cli/onevm
@@ -800,8 +800,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
disk_snapshot_revert_desc = <<-EOT.unindent
- Reverts disk state to a previously taken snapshot. To revert
- disk state to the base disk image use 0 as snapshot id
+ Reverts disk state to a previously taken snapshot.
States: POWEROFF
EOT
@@ -813,6 +812,18 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
+ disk_snapshot_delete_desc = <<-EOT.unindent
+ Deletes a disk snapshot.
+
+ States: POWEROFF
+ EOT
+ command :"disk-snapshot-delete", disk_snapshot_delete_desc,
+ :vmid, :diskid, :snapshot_id do
+ helper.perform_action(args[0],options,"disk snapshot deleted") do |o|
+ o.disk_snapshot_delete(args[1].to_i, args[2].to_i)
+ end
+ end
+
list_desc = <<-EOT.unindent
Lists VMs in the pool
EOT
diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc
index 063a7b7b50..a80ff9c543 100644
--- a/src/dm/DispatchManagerActions.cc
+++ b/src/dm/DispatchManagerActions.cc
@@ -1717,3 +1717,65 @@ int DispatchManager::disk_snapshot_revert(
return 0;
}
+
+/* -------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
+
+int DispatchManager::disk_snapshot_delete(
+ int vid,
+ int did,
+ int snap_id,
+ string& error_str)
+{
+ ostringstream oss;
+
+ VirtualMachine * vm = vmpool->get(vid, true);
+
+ if ( vm == 0 )
+ {
+ oss << "Could not delete disk snapshot from VM " << vid
+ << ", VM does not exist" ;
+ error_str = oss.str();
+
+ NebulaLog::log("DiM", Log::ERROR, error_str);
+
+ return -1;
+ }
+
+ if ( vm->get_state() != VirtualMachine::POWEROFF ||
+ vm->get_lcm_state() != VirtualMachine::LCM_INIT )
+ {
+ oss << "Could not delete disk snapshot from VM " << vid
+ << ", wrong state " << vm->state_str() << ".";
+ error_str = oss.str();
+
+ NebulaLog::log("DiM", Log::ERROR, error_str);
+
+ vm->unlock();
+ return -1;
+ }
+
+ if (vm->delete_disk_snapshot(did, snap_id, error_str) == -1)
+ {
+ vm->unlock();
+ return -1;
+ }
+
+ if (vm->set_snapshot_disk(did, snap_id) == -1)
+ {
+ vm->unlock();
+ return -1;
+ }
+
+ vm->set_state(VirtualMachine::ACTIVE);
+ vm->set_state(VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF);
+
+ vmpool->update(vm);
+
+ vm->unlock();
+
+ tm->trigger(TransferManager::SNAPSHOT_DELETE, vid);
+
+ return 0;
+}
+
diff --git a/src/dm/DispatchManagerStates.cc b/src/dm/DispatchManagerStates.cc
index 47528b4ad4..a7728b2490 100644
--- a/src/dm/DispatchManagerStates.cc
+++ b/src/dm/DispatchManagerStates.cc
@@ -168,6 +168,7 @@ void DispatchManager::poweroff_success_action(int vid)
vm->get_lcm_state() == VirtualMachine::PROLOG_MIGRATE_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::DISK_SNAPSHOT_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF ||
+ vm->get_lcm_state() == VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE))
{
vm->set_state(VirtualMachine::POWEROFF);
diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc
index 05d8b20f0a..ae844cfa8e 100644
--- a/src/lcm/LifeCycleActions.cc
+++ b/src/lcm/LifeCycleActions.cc
@@ -970,6 +970,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
+ case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
vm->clear_snapshot_disk();
vmpool->update(vm);
@@ -1245,6 +1246,7 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
+ case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
lcm_action = LifeCycleManager::DISK_SNAPSHOT_FAILURE;
break;
}
@@ -1449,6 +1451,7 @@ void LifeCycleManager::retry(VirtualMachine * vm)
case VirtualMachine::HOTPLUG_EPILOG_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
+ case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
case VirtualMachine::RUNNING:
case VirtualMachine::UNKNOWN:
break;
diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc
index fdb131ac39..c45ca8284a 100644
--- a/src/lcm/LifeCycleStates.cc
+++ b/src/lcm/LifeCycleStates.cc
@@ -1710,58 +1710,50 @@ void LifeCycleManager::saveas_hot_failure_action(int vid)
void LifeCycleManager::disk_snapshot_success(int vid)
{
- VirtualMachine * vm;
+ string disk_id, tm_mad, ds_id, snap_id, err;
+ int isnap_id, idisk_id;
- vm = vmpool->get(vid,true);
+ VirtualMachine * vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return;
}
- if ( vm->get_lcm_state() == VirtualMachine::DISK_SNAPSHOT_POWEROFF )
+ switch (vm->get_lcm_state())
{
- vm->log("LCM", Log::INFO, "VM disk snapshot successfully taken.");
+ case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
+ case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
+ vm->log("LCM", Log::INFO, "VM disk snapshot operation completed.");
- vm->clear_snapshot_disk();
-
- vmpool->update(vm);
-
- dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
- }
- else if (vm->get_lcm_state()==VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF)
- {
- string disk_id, tm_mad, ds_id, snap_id, err;
-
- if (vm->get_snapshot_disk(ds_id, tm_mad, disk_id, snap_id) == -1)
- {
- vm->log("LCM", Log::INFO, "Active disk snapshot not found.");
- }
- else
- {
- int isnap_id = strtol(snap_id.c_str(),NULL,0);
- int idisk_id = strtol(disk_id.c_str(),NULL,0);
-
- if (vm->revert_disk_snapshot(idisk_id, isnap_id, err)==-1)
+ if (vm->get_snapshot_disk(ds_id, tm_mad, disk_id, snap_id) != -1)
{
- vm->log("LCM", Log::INFO, "Error activating snapshot: " + err);
+ isnap_id = strtol(snap_id.c_str(),NULL,0);
+ idisk_id = strtol(disk_id.c_str(),NULL,0);
+
+ vm->revert_disk_snapshot(idisk_id, isnap_id, err);
}
- }
+ break;
- vm->log("LCM", Log::INFO, "VM disk snapshot successfully reverted.");
+ case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
+ vm->log("LCM", Log::INFO, "VM disk snapshot deleted.");
+ break;
- vm->clear_snapshot_disk();
-
- vmpool->update(vm);
-
- dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
- }
- else
- {
- vm->log("LCM",Log::ERROR,"disk_snapshot_success, VM in a wrong state");
+ default:
+ vm->log("LCM",Log::ERROR,"disk_snapshot_success, VM in a wrong state");
+ vm->unlock();
+ return;
}
+ vm->clear_snapshot_disk();
+
+ vmpool->update(vm);
+
+ dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
+
vm->unlock();
+
+ return;
}
/* -------------------------------------------------------------------------- */
@@ -1769,59 +1761,49 @@ void LifeCycleManager::disk_snapshot_success(int vid)
void LifeCycleManager::disk_snapshot_failure(int vid)
{
- VirtualMachine * vm;
+ string disk_id, tm_mad, ds_id, snap_id, err;
+ int isnap_id, idisk_id;
- vm = vmpool->get(vid,true);
+ VirtualMachine * vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return;
}
- if ( vm->get_lcm_state() == VirtualMachine::DISK_SNAPSHOT_POWEROFF )
+ switch (vm->get_lcm_state())
{
- string disk_id, tm_mad, ds_id, snap_id, err;
+ case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
+ case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
+ vm->log("LCM", Log::ERROR, "VM disk snapshot operation failed.");
- vm->log("LCM",Log::ERROR,"Error taking disk snapshot");
-
- if (vm->get_snapshot_disk(ds_id, tm_mad, disk_id, snap_id) == -1)
- {
- vm->log("LCM", Log::INFO, "Active disk snapshot not found."
- " Remove failed snapshot manually.");
- }
- else
- {
- int isnap_id = strtol(snap_id.c_str(),NULL,0);
- int idisk_id = strtol(disk_id.c_str(),NULL,0);
-
- if (vm->delete_disk_snapshot(idisk_id, isnap_id, err) == -1)
+ if (vm->get_snapshot_disk(ds_id, tm_mad, disk_id, snap_id) != -1)
{
- vm->log("LCM", Log::INFO, "Error deleting snapshot: " + err
- + " Remove failed snapshot manually.");
+ isnap_id = strtol(snap_id.c_str(),NULL,0);
+ idisk_id = strtol(disk_id.c_str(),NULL,0);
+
+ vm->delete_disk_snapshot(idisk_id, isnap_id, err);
}
- }
+ break;
- vm->clear_snapshot_disk();
+ case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
+ vm->log("LCM", Log::ERROR, "Could not revert to disk snapshot.");
+ break;
- vmpool->update(vm);
-
- dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
+ default:
+ vm->log("LCM",Log::ERROR,"disk_snapshot_failure, VM in a wrong state");
+ vm->unlock();
+ return;
}
- else if (vm->get_lcm_state()==VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF)
- {
- vm->log("LCM",Log::ERROR,"Could not revert to disk snapshot.");
- vm->clear_snapshot_disk();
+ vm->clear_snapshot_disk();
- vmpool->update(vm);
+ vmpool->update(vm);
- dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
- }
- else
- {
- vm->log("LCM",Log::ERROR,"disk_snapshot_success, VM in a wrong state.");
- }
+ dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
vm->unlock();
-};
+
+ return;
+}
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 126fb96c97..d7e70bea57 100644
--- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java
+++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java
@@ -129,7 +129,8 @@ public class VirtualMachine extends PoolElement{
"PROLOG_RESUME_FAILURE",
"PROLOG_UNDEPLOY_FAILURE",
"DISK_SNAPSHOT_POWEROFF",
- "DISK_SNAPSHOT_REVERT_POWEROFF"
+ "DISK_SNAPSHOT_REVERT_POWEROFF",
+ "DISK_SNAPSHOT_DELETE_POWEROFF"
};
private static final String[] SHORT_LCM_STATES =
@@ -186,7 +187,8 @@ public class VirtualMachine extends PoolElement{
"fail", // PROLOG_RESUME_FAILURE
"fail", // PROLOG_UNDEPLOY_FAILURE
"snap", // DISK_SNAPSHOT_POWEROFF
- "snap" // DISK_SNAPSHOT_REVERT_POWEROFF
+ "snap", // DISK_SNAPSHOT_REVERT_POWEROFF
+ "snap" // DISK_SNAPSHOT_DELETE_POWEROFF
};
/**
diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb
index 2568e7f05d..0b1d91a839 100644
--- a/src/oca/ruby/opennebula/virtual_machine.rb
+++ b/src/oca/ruby/opennebula/virtual_machine.rb
@@ -46,7 +46,8 @@ module OpenNebula
:detachnic => "vm.detachnic",
:recover => "vm.recover",
:disksnapshotcreate => "vm.disksnapshotcreate",
- :disksnapshotrevert => "vm.disksnapshotrevert"
+ :disksnapshotrevert => "vm.disksnapshotrevert",
+ :disksnapshotdelete => "vm.disksnapshotdelete"
}
VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED
@@ -106,6 +107,7 @@ module OpenNebula
PROLOG_UNDEPLOY_FAILURE
DISK_SNAPSHOT_POWEROFF
DISK_SNAPSHOT_REVERT_POWEROFF
+ DISK_SNAPSHOT_DELETE_POWEROFF
}
SHORT_VM_STATES={
@@ -173,7 +175,8 @@ module OpenNebula
"PROLOG_RESUME_FAILURE" => "fail",
"PROLOG_UNDEPLOY_FAILURE" => "fail",
"DISK_SNAPSHOT_POWEROFF" => "snap",
- "DISK_SNAPSHOT_REVERT_POWEROFF" => "snap"
+ "DISK_SNAPSHOT_REVERT_POWEROFF" => "snap",
+ "DISK_SNAPSHOT_DELETE_POWEROFF" => "snap"
}
MIGRATE_REASON=%w{NONE ERROR USER}
@@ -617,7 +620,7 @@ module OpenNebula
end
# Takes a new snapshot of a disk
- #
+ #
# @param disk_id [Integer] Id of the disk
# @param tag [String] description for the snapshot
#
@@ -627,7 +630,7 @@ module OpenNebula
end
# Reverts disk state to a previously taken snapshot
- #
+ #
# @param disk_id [Integer] Id of the disk
# @param snap_id [Integer] Id of the snapshot
#
@@ -637,6 +640,17 @@ module OpenNebula
return call(VM_METHODS[:disksnapshotrevert], @pe_id, disk_id, snap_id)
end
+ # Deletes a disk snapshot
+ #
+ # @param disk_id [Integer] Id of the disk
+ # @param snap_id [Integer] Id of the snapshot
+ #
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
+ # otherwise
+ def disk_snapshot_delete(disk_id, snap_id)
+ return call(VM_METHODS[:disksnapshotdelete], @pe_id, disk_id, snap_id)
+ end
+
# Recovers an ACTIVE VM
#
# @param result [Integer] Recover with failure (0), success (1) or
diff --git a/src/rm/RequestManager.cc b/src/rm/RequestManager.cc
index 5465383a20..9d00465815 100644
--- a/src/rm/RequestManager.cc
+++ b/src/rm/RequestManager.cc
@@ -306,6 +306,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr vm_snap_delete(new VirtualMachineSnapshotDelete());
xmlrpc_c::methodPtr vm_dsnap_create(new VirtualMachineDiskSnapshotCreate());
xmlrpc_c::methodPtr vm_dsnap_revert(new VirtualMachineDiskSnapshotRevert());
+ xmlrpc_c::methodPtr vm_dsnap_delete(new VirtualMachineDiskSnapshotDelete());
xmlrpc_c::methodPtr vm_recover(new VirtualMachineRecover());
xmlrpc_c::methodPtr vm_pool_acct(new VirtualMachinePoolAccounting());
@@ -464,6 +465,7 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.vm.snapshotdelete", vm_snap_delete);
RequestManagerRegistry.addMethod("one.vm.disksnapshotcreate", vm_dsnap_create);
RequestManagerRegistry.addMethod("one.vm.disksnapshotrevert", vm_dsnap_revert);
+ RequestManagerRegistry.addMethod("one.vm.disksnapshotdelete", vm_dsnap_delete);
RequestManagerRegistry.addMethod("one.vm.recover", vm_recover);
RequestManagerRegistry.addMethod("one.vmpool.info", vm_pool_info);
diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc
index ec106800c2..5e1051a409 100644
--- a/src/rm/RequestManagerVirtualMachine.cc
+++ b/src/rm/RequestManagerVirtualMachine.cc
@@ -2560,5 +2560,43 @@ void VirtualMachineDiskSnapshotRevert::request_execute(
return;
}
+
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
+
+
+void VirtualMachineDiskSnapshotDelete::request_execute(
+ xmlrpc_c::paramList const& paramList,
+ RequestAttributes& att)
+{
+ Nebula& nd = Nebula::instance();
+ DispatchManager * dm = nd.get_dm();
+
+ int rc;
+ string error_str;
+
+ int id = xmlrpc_c::value_int(paramList.getInt(1));
+ int did = xmlrpc_c::value_int(paramList.getInt(2));
+ int snap_id = xmlrpc_c::value_int(paramList.getInt(3));
+
+ if ( vm_authorization(id, 0, 0, att, 0, 0, auth_op) == false )
+ {
+ return;
+ }
+
+ rc = dm->disk_snapshot_delete(id, did, snap_id, error_str);
+
+ if ( rc != 0 )
+ {
+ failure_response(ACTION,
+ request_error(error_str, ""),
+ att);
+ }
+ else
+ {
+ success_response(id, att);
+ }
+
+ return;
+}
+
diff --git a/src/sunstone/OpenNebulaVNC.rb b/src/sunstone/OpenNebulaVNC.rb
index 377ef88797..457d7a0609 100644
--- a/src/sunstone/OpenNebulaVNC.rb
+++ b/src/sunstone/OpenNebulaVNC.rb
@@ -85,6 +85,7 @@ VNC_STATES = [
#50, #PROLOG_UNDEPLOY_FAILURE
#51, #DISK_SNAPSHOT_POWEROFF
#52, #DISK_SNAPSHOT_REVERT_POWEROFF
+ #53, #DISK_SNAPSHOT_DELETE_POWEROFF
]
class OpenNebulaVNC
diff --git a/src/tm/TransferManagerDriver.cc b/src/tm/TransferManagerDriver.cc
index 2c94cfac9f..d7c6b16b19 100644
--- a/src/tm/TransferManagerDriver.cc
+++ b/src/tm/TransferManagerDriver.cc
@@ -149,6 +149,7 @@ void TransferManagerDriver::protocol(const string& message) const
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
+ case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
lcm_action = LifeCycleManager::DISK_SNAPSHOT_SUCCESS;
break;
@@ -209,6 +210,7 @@ void TransferManagerDriver::protocol(const string& message) const
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
+ case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
lcm_action = LifeCycleManager::DISK_SNAPSHOT_FAILURE;
break;
diff --git a/src/vm/Snapshots.cc b/src/vm/Snapshots.cc
index 4bacf92d94..af055a615e 100644
--- a/src/vm/Snapshots.cc
+++ b/src/vm/Snapshots.cc
@@ -179,7 +179,14 @@ int Snapshots::delete_snapshot(unsigned int id, string& error)
children = one_util::join(child_set.begin(), child_set.end(), ',');
- parent->replace("CHILDREN", children);
+ if (children.empty())
+ {
+ parent->remove("CHILDREN");
+ }
+ else
+ {
+ parent->replace("CHILDREN", children);
+ }
}
}
diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc
index ca33cc3096..9124a8f312 100644
--- a/src/vm/VirtualMachine.cc
+++ b/src/vm/VirtualMachine.cc
@@ -4278,7 +4278,7 @@ int VirtualMachine::new_disk_snapshot(int did, const string& tag, string& error)
if ( disk == 0 )
{
- error = "DISK does not exists";
+ error = "VM disk does not exists";
return -1;
}
@@ -4328,7 +4328,7 @@ int VirtualMachine::revert_disk_snapshot(int did, int snap_id, string& error)
if ( disk == 0 )
{
- error = "DISK does not exists";
+ error = "VM disk does not exists";
return -1;
}
@@ -4362,7 +4362,7 @@ int VirtualMachine::delete_disk_snapshot(int did, int snap_id, string& error)
if ( disk == 0 )
{
- error = "DISK does not exists";
+ error = "VM disk does not exists";
return -1;
}