mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
feature #1223: Fix error messages and error handling bugs for attach_disk methods
This commit is contained in:
parent
58b6c1f936
commit
2772ba8a84
@ -686,7 +686,7 @@ int DispatchManager::finalize(
|
||||
VirtualMachine * vm;
|
||||
ostringstream oss;
|
||||
Template * tmpl;
|
||||
|
||||
|
||||
int uid;
|
||||
int gid;
|
||||
|
||||
@ -732,7 +732,7 @@ int DispatchManager::finalize(
|
||||
uid = vm->get_uid();
|
||||
gid = vm->get_gid();
|
||||
tmpl = vm->clone_template();
|
||||
|
||||
|
||||
vm->unlock();
|
||||
|
||||
Quotas::vm_del(uid, gid, tmpl);
|
||||
@ -835,7 +835,12 @@ int DispatchManager::attach(int vid,
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
oss << "VirtualMachine " << vid << " no longer exists";
|
||||
oss << "Could not attach a new disk to VM " << vid
|
||||
<< ", VM does not exist" ;
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -850,7 +855,7 @@ int DispatchManager::attach(int vid,
|
||||
vm->unlock();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
vm->get_disk_info(num_disks, used_targets);
|
||||
|
||||
vm->set_state(VirtualMachine::HOTPLUG);
|
||||
@ -863,15 +868,15 @@ int DispatchManager::attach(int vid,
|
||||
|
||||
vm->unlock();
|
||||
|
||||
disk = VirtualMachine::set_up_attach_disk(tmpl,
|
||||
used_targets,
|
||||
disk = VirtualMachine::set_up_attach_disk(tmpl,
|
||||
used_targets,
|
||||
num_disks,
|
||||
uid,
|
||||
image_id,
|
||||
error_str);
|
||||
vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
if ( vm == 0 )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImageManager* imagem = nd.get_imagem();
|
||||
@ -881,6 +886,12 @@ int DispatchManager::attach(int vid,
|
||||
imagem->release_image(image_id, false);
|
||||
}
|
||||
|
||||
oss << "Could not attach a new disk to VM " << vid
|
||||
<< ", VM does not exist after setting its state to HOTPLUG." ;
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -890,8 +901,9 @@ int DispatchManager::attach(int vid,
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->unlock();
|
||||
vm->unlock();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
@ -903,7 +915,7 @@ int DispatchManager::attach(int vid,
|
||||
|
||||
vm->unlock();
|
||||
|
||||
vmm->trigger(VirtualMachineManager::ATTACH,vid);
|
||||
vmm->trigger(VirtualMachineManager::ATTACH,vid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -927,6 +939,9 @@ int DispatchManager::detach(
|
||||
if ( vm == 0 )
|
||||
{
|
||||
oss << "VirtualMachine " << vid << " no longer exists";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -941,16 +956,18 @@ int DispatchManager::detach(
|
||||
vm->unlock();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if ( vm->set_attach_disk(disk_id) == -1 )
|
||||
{
|
||||
oss << "Could not detach disk with DISK_ID " << disk_id
|
||||
<< ", it does not exists.";
|
||||
oss << "Could not detach disk with DISK_ID " << disk_id
|
||||
<< ", it does not exist.";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
|
||||
vm->unlock();
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
vm->set_state(VirtualMachine::HOTPLUG);
|
||||
|
||||
|
@ -175,7 +175,7 @@ int VirtualMachine::select(SqlDB * db)
|
||||
|
||||
mkdir(oss.str().c_str(), 0700);
|
||||
chmod(oss.str().c_str(), 0700);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//Create Log support for this VM
|
||||
//--------------------------------------------------------------------------
|
||||
@ -258,7 +258,7 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
{
|
||||
goto error_no_cpu;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Get network leases
|
||||
// ------------------------------------------------------------------------
|
||||
@ -348,7 +348,7 @@ error_no_memory:
|
||||
goto error_common;
|
||||
|
||||
error_name_length:
|
||||
error_str = "NAME is too long; max length is 128 chars.";
|
||||
error_str = "NAME is too long; max length is 128 chars.";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
@ -1023,12 +1023,12 @@ int VirtualMachine::get_disk_images(string& error_str)
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = ipool->disk_attribute(disk,
|
||||
rc = ipool->disk_attribute(disk,
|
||||
i,
|
||||
img_type,
|
||||
dev_prefix,
|
||||
uid,
|
||||
image_id,
|
||||
uid,
|
||||
image_id,
|
||||
error_str);
|
||||
if (rc == 0 )
|
||||
{
|
||||
@ -1049,7 +1049,7 @@ int VirtualMachine::get_disk_images(string& error_str)
|
||||
{
|
||||
case Image::OS:
|
||||
// The first OS disk gets the first device (a),
|
||||
// other OS's will be managed as DATABLOCK's
|
||||
// other OS's will be managed as DATABLOCK's
|
||||
if ( os_disk.empty() )
|
||||
{
|
||||
os_disk.push( make_pair(dev_prefix, disk) );
|
||||
@ -1176,7 +1176,7 @@ VectorAttribute * VirtualMachine::set_up_attach_disk(
|
||||
Image::ImageType img_type;
|
||||
|
||||
image_id = -1;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Get the DISK attribute from the template
|
||||
// -------------------------------------------------------------------------
|
||||
@ -1192,7 +1192,7 @@ VectorAttribute * VirtualMachine::set_up_attach_disk(
|
||||
// -------------------------------------------------------------------------
|
||||
// Acquire the new disk image
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
int rc = ipool->disk_attribute(new_disk,
|
||||
num_disks + 1, //Preserv CONTEXT disk.i file
|
||||
img_type,
|
||||
@ -1215,11 +1215,11 @@ VectorAttribute * VirtualMachine::set_up_attach_disk(
|
||||
|
||||
oss << "Target " << target << "is already in use.";
|
||||
error_str = oss.str();
|
||||
|
||||
imagem->release_image(image_id, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
imagem->release_image(image_id, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1643,7 +1643,7 @@ error_common:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::save_disk(const string& disk_id,
|
||||
int VirtualMachine::save_disk(const string& disk_id,
|
||||
const string& source,
|
||||
int img_id)
|
||||
{
|
||||
@ -1692,7 +1692,7 @@ int VirtualMachine::save_disk(const string& disk_id,
|
||||
|
||||
void VirtualMachine::set_auth_request(int uid,
|
||||
AuthRequest& ar,
|
||||
VirtualMachineTemplate *tmpl)
|
||||
VirtualMachineTemplate *tmpl)
|
||||
{
|
||||
int num;
|
||||
vector<Attribute * > vectors;
|
||||
@ -1818,8 +1818,8 @@ string& VirtualMachine::to_xml_extended(string& xml, int n_history) const
|
||||
<< "<ID>" << oid << "</ID>"
|
||||
<< "<UID>" << uid << "</UID>"
|
||||
<< "<GID>" << gid << "</GID>"
|
||||
<< "<UNAME>" << uname << "</UNAME>"
|
||||
<< "<GNAME>" << gname << "</GNAME>"
|
||||
<< "<UNAME>" << uname << "</UNAME>"
|
||||
<< "<GNAME>" << gname << "</GNAME>"
|
||||
<< "<NAME>" << name << "</NAME>"
|
||||
<< perms_to_xml(perm_xml)
|
||||
<< "<LAST_POLL>" << last_poll << "</LAST_POLL>"
|
||||
|
Loading…
x
Reference in New Issue
Block a user