diff --git a/src/cli/onevnet b/src/cli/onevnet index b3b20be20d..16457d6ef6 100755 --- a/src/cli/onevnet +++ b/src/cli/onevnet @@ -205,7 +205,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit -1 end - if rname == -1 + if rname == -1 && args[1].nil? STDERR.puts "Specify a name (-n name) for the reservation" exit -1 end diff --git a/src/oca/ruby/opennebula/virtual_network.rb b/src/oca/ruby/opennebula/virtual_network.rb index 99dac99456..d45d4ff2a3 100644 --- a/src/oca/ruby/opennebula/virtual_network.rb +++ b/src/oca/ruby/opennebula/virtual_network.rb @@ -199,7 +199,7 @@ module OpenNebula return Error.new('ID not defined') if !@pe_id rtmpl = "SIZE = #{rsize}\n" - rtmpl << "NAME = #{rname}\n" if !name.nil? + rtmpl << "NAME = #{rname}\n" if !rname.nil? rtmpl << "AR_ID = #{ar_id}\n" if !ar_id.nil? rtmpl << "NETWORK_ID = #{vnet}\n" if !vnet.nil? diff --git a/src/rm/RequestManagerVirtualNetwork.cc b/src/rm/RequestManagerVirtualNetwork.cc index 6ca84aae8f..18488ac107 100644 --- a/src/rm/RequestManagerVirtualNetwork.cc +++ b/src/rm/RequestManagerVirtualNetwork.cc @@ -137,6 +137,7 @@ void VirtualNetworkReserve::request_execute( int id = xmlrpc_c::value_int (paramList.getInt(1)); string str_tmpl = xmlrpc_c::value_string (paramList.getString(2)); + VirtualNetworkPool * vnpool = static_cast(pool); VirtualNetworkTemplate tmpl; VirtualNetwork * vn; VirtualNetwork * rvn; @@ -239,7 +240,7 @@ void VirtualNetworkReserve::request_execute( // --------------- Get the VNET to make the reservation ------------- - vn = static_cast(pool->get(id,true)); + vn = vnpool->get(id,true); if ( vn == 0 ) { @@ -259,9 +260,8 @@ void VirtualNetworkReserve::request_execute( cluster_id = vn->get_cluster_id(); - rc = (static_cast(pool))->allocate(att.uid, att.gid, - att.uname, att.gname, att.umask, id, vtmpl, &rid, cluster_id, - vn->get_cluster_name(), error_str); + rc = vnpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, + id, vtmpl, &rid, cluster_id, vn->get_cluster_name(), error_str); if (rc < 0) { @@ -276,7 +276,7 @@ void VirtualNetworkReserve::request_execute( } } - rvn = static_cast(pool->get(rid,true)); + rvn = vnpool->get(rid,true); if (rvn == 0) { @@ -291,11 +291,14 @@ void VirtualNetworkReserve::request_execute( if (on_exisiting && rvn->get_parent() != id) { + ostringstream oss; + + oss << "New reservations for virtual network " << rid << " have to be " + << "from network " << rvn->get_parent(); + quota_rollback(&qtmpl, Quotas::NETWORK, att); - failure_response(INTERNAL, - request_error("Cannot put reservations from different networks on " - "the same VNET",""), att); + failure_response(INTERNAL, request_error(oss.str(),""), att); rvn->unlock();