From ddcc7dc65526bbe21ec69e72e887aeba64e3ead6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 20 Feb 2013 17:25:48 +0100 Subject: [PATCH] Feature #1224: Accept empty names for new snapshots --- src/rm/RequestManagerVirtualMachine.cc | 6 +++--- src/vm/VirtualMachine.cc | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 2497013911..9944e8725a 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -1067,8 +1067,8 @@ void VirtualMachineSnapshotCreate::request_execute( int rc; string error_str; - int id = xmlrpc_c::value_int(paramList.getInt(1)); - string str = xmlrpc_c::value_string(paramList.getString(2)); + int id = xmlrpc_c::value_int(paramList.getInt(1)); + string name = xmlrpc_c::value_string(paramList.getString(2)); // ------------------------------------------------------------------------- // Authorize the operation @@ -1079,7 +1079,7 @@ void VirtualMachineSnapshotCreate::request_execute( return; } - rc = dm->snapshot_create(id, str, error_str); + rc = dm->snapshot_create(id, name, error_str); if ( rc != 0 ) { diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 916ad3702d..26709b8036 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1831,6 +1831,15 @@ int VirtualMachine::new_snapshot(string& name) } } + if (name.empty()) + { + ostringstream oss; + + oss << "snapshot-" << max_id+1; + + name = oss.str(); + } + snap = new VectorAttribute("SNAPSHOT"); snap->replace("SNAPSHOT_ID", max_id+1); snap->replace("NAME", name);