mirror of
https://github.com/OpenNebula/one.git
synced 2025-08-24 17:49:28 +03:00
feature #3782: Removed _hot from saveas functions
This commit is contained in:
@ -75,8 +75,8 @@ public:
|
||||
DETACH_NIC_FAILURE,/**< Sent by the VMM when a detach nic action fails */
|
||||
CLEANUP_SUCCESS, /**< Sent by the VMM when a cleanup action succeeds */
|
||||
CLEANUP_FAILURE, /**< Sent by the VMM when a cleanup action fails */
|
||||
SAVEAS_HOT_SUCCESS,/**< Sent by the VMM when hot saveas succeeds */
|
||||
SAVEAS_HOT_FAILURE,/**< Sent by the VMM when hot saveas fails */
|
||||
SAVEAS_SUCCESS, /**< Sent by the VMM when saveas succeeds */
|
||||
SAVEAS_FAILURE, /**< Sent by the VMM when saveas fails */
|
||||
SNAPSHOT_CREATE_SUCCESS, /**< Sent by the VMM on snap. create success */
|
||||
SNAPSHOT_CREATE_FAILURE, /**< Sent by the VMM on snap. create failure */
|
||||
SNAPSHOT_REVERT_SUCCESS, /**< Sent by the VMM on snap. revert success */
|
||||
@ -252,9 +252,9 @@ private:
|
||||
|
||||
void detach_failure_action(int vid);
|
||||
|
||||
void saveas_hot_success_action(int vid);
|
||||
void saveas_success_action(int vid);
|
||||
|
||||
void saveas_hot_failure_action(int vid);
|
||||
void saveas_failure_action(int vid);
|
||||
|
||||
void attach_nic_success_action(int vid);
|
||||
|
||||
|
@ -1280,6 +1280,14 @@ public:
|
||||
*/
|
||||
int set_saveas_disk(int disk_id, string& err_str);
|
||||
|
||||
/**
|
||||
* Set export attributes for the disk
|
||||
* @param disk_id Index of the disk to export
|
||||
* @param source to save the disk
|
||||
* @param img_id ID of the image this disk will be saved to
|
||||
*/
|
||||
int set_saveas_disk(int disk_id, const string& source, int img_id);
|
||||
|
||||
/**
|
||||
* Sets the corresponding state to export the disk.
|
||||
* @return 0 if the VM can be exported
|
||||
@ -1299,26 +1307,19 @@ public:
|
||||
*/
|
||||
int clear_saveas_disk();
|
||||
|
||||
/**
|
||||
* Set the SAVE_AS attribute for the "disk_id"th disk.
|
||||
* @param disk_id Index of the disk to save
|
||||
* @param source to save the disk (SAVE_AS_SOURCE)
|
||||
* @param img_id ID of the image this disk will be saved to (SAVE_AS).
|
||||
*/
|
||||
int save_disk_hot(int disk_id,
|
||||
const string& source,
|
||||
int img_id);
|
||||
/**
|
||||
* Get the original image id of the disk. It also checks that the disk can
|
||||
* be saved_as.
|
||||
* @param disk_id Index of the disk to save
|
||||
* @param error_str describes the error
|
||||
* @param source of the image to save the disk to
|
||||
* @param image_id of the image to save the disk to
|
||||
* @param tm_mad in use by the disk
|
||||
* @param ds_id of the datastore in use by the disk
|
||||
* @return -1 if failure
|
||||
*/
|
||||
int get_saveas_disk_hot(int& disk_id, string& source, int& image_id,
|
||||
int get_saveas_disk(int& disk_id, string& source, int& image_id,
|
||||
string& tm_mad, string& ds_id);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Authorization related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -455,7 +455,7 @@ static int mkfs_action(istringstream& is,
|
||||
goto error_save_get;
|
||||
}
|
||||
|
||||
if ( vm->save_disk_hot(disk_id, source, id) == -1 )
|
||||
if ( vm->set_saveas_disk(disk_id, source, id) == -1 )
|
||||
{
|
||||
goto error_save_state;
|
||||
}
|
||||
|
@ -1129,11 +1129,11 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
|
||||
if (success)
|
||||
{
|
||||
lcm_action = LifeCycleManager::SAVEAS_HOT_SUCCESS;
|
||||
lcm_action = LifeCycleManager::SAVEAS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
lcm_action = LifeCycleManager::SAVEAS_HOT_FAILURE;
|
||||
lcm_action = LifeCycleManager::SAVEAS_FAILURE;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -166,12 +166,12 @@ void LifeCycleManager::trigger(Actions action, int _vid)
|
||||
aname = "DETACH_FAILURE";
|
||||
break;
|
||||
|
||||
case SAVEAS_HOT_SUCCESS:
|
||||
aname = "SAVEAS_HOT_SUCCESS";
|
||||
case SAVEAS_SUCCESS:
|
||||
aname = "SAVEAS_SUCCESS";
|
||||
break;
|
||||
|
||||
case SAVEAS_HOT_FAILURE:
|
||||
aname = "SAVEAS_HOT_FAILURE";
|
||||
case SAVEAS_FAILURE:
|
||||
aname = "SAVEAS_FAILURE";
|
||||
break;
|
||||
|
||||
case ATTACH_NIC_SUCCESS:
|
||||
@ -399,13 +399,13 @@ void LifeCycleManager::do_action(const string &action, void * arg)
|
||||
{
|
||||
detach_failure_action(vid);
|
||||
}
|
||||
else if (action == "SAVEAS_HOT_SUCCESS")
|
||||
else if (action == "SAVEAS_SUCCESS")
|
||||
{
|
||||
saveas_hot_success_action(vid);
|
||||
saveas_success_action(vid);
|
||||
}
|
||||
else if (action == "SAVEAS_HOT_FAILURE")
|
||||
else if (action == "SAVEAS_FAILURE")
|
||||
{
|
||||
saveas_hot_failure_action(vid);
|
||||
saveas_failure_action(vid);
|
||||
}
|
||||
else if (action == "ATTACH_NIC_SUCCESS")
|
||||
{
|
||||
|
@ -1604,7 +1604,7 @@ void LifeCycleManager::detach_nic_failure_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::saveas_hot_success_action(int vid)
|
||||
void LifeCycleManager::saveas_success_action(int vid)
|
||||
{
|
||||
int image_id;
|
||||
int disk_id;
|
||||
@ -1619,7 +1619,7 @@ void LifeCycleManager::saveas_hot_success_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
int rc = vm->get_saveas_disk_hot(disk_id, source, image_id, tm_mad, ds_id);
|
||||
int rc = vm->get_saveas_disk(disk_id, source, image_id, tm_mad, ds_id);
|
||||
|
||||
vm->clear_saveas_disk();
|
||||
|
||||
@ -1638,14 +1638,14 @@ void LifeCycleManager::saveas_hot_success_action(int vid)
|
||||
|
||||
vm->unlock();
|
||||
|
||||
if ( rc != 0 )
|
||||
if (rc != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Image * image = ipool->get(image_id, true);
|
||||
|
||||
if ( image == 0 )
|
||||
if (image == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1660,7 +1660,7 @@ void LifeCycleManager::saveas_hot_success_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::saveas_hot_failure_action(int vid)
|
||||
void LifeCycleManager::saveas_failure_action(int vid)
|
||||
{
|
||||
int image_id;
|
||||
int disk_id;
|
||||
@ -1675,7 +1675,7 @@ void LifeCycleManager::saveas_hot_failure_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
int rc = vm->get_saveas_disk_hot(disk_id, source, image_id, tm_mad, ds_id);
|
||||
int rc = vm->get_saveas_disk(disk_id, source, image_id, tm_mad, ds_id);
|
||||
|
||||
vm->clear_saveas_disk();
|
||||
|
||||
@ -1694,14 +1694,14 @@ void LifeCycleManager::saveas_hot_failure_action(int vid)
|
||||
|
||||
vm->unlock();
|
||||
|
||||
if ( rc != 0 )
|
||||
if (rc != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Image * image = ipool->get(image_id, true);
|
||||
|
||||
if ( image == 0 )
|
||||
if (image == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2084,9 +2084,9 @@ void TransferManager::saveas_hot_action(int vid)
|
||||
goto error_common;
|
||||
}
|
||||
|
||||
if (vm->get_saveas_disk_hot(disk_id, source, image_id, tm_mad, ds_id) != 0)
|
||||
if (vm->get_saveas_disk(disk_id, source, image_id, tm_mad, ds_id) != 0)
|
||||
{
|
||||
vm->log("TM", Log::ERROR,"Could not get disk information to saveas it");
|
||||
vm->log("TM", Log::ERROR,"Could not get disk information to export it");
|
||||
goto error_common;
|
||||
}
|
||||
|
||||
@ -2135,7 +2135,7 @@ error_file:
|
||||
error_common:
|
||||
vm->log("TM", Log::ERROR, os);
|
||||
|
||||
(nd.get_lcm())->trigger(LifeCycleManager::SAVEAS_HOT_FAILURE, vid);
|
||||
(nd.get_lcm())->trigger(LifeCycleManager::SAVEAS_FAILURE, vid);
|
||||
|
||||
vm->unlock();
|
||||
return;
|
||||
|
@ -136,7 +136,7 @@ void TransferManagerDriver::protocol(const string& message) const
|
||||
case VirtualMachine::HOTPLUG_SAVEAS:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
|
||||
lcm_action = LifeCycleManager::SAVEAS_HOT_SUCCESS;
|
||||
lcm_action = LifeCycleManager::SAVEAS_SUCCESS;
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOTPLUG_PROLOG_POWEROFF:
|
||||
@ -197,7 +197,7 @@ void TransferManagerDriver::protocol(const string& message) const
|
||||
case VirtualMachine::HOTPLUG_SAVEAS:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
|
||||
lcm_action = LifeCycleManager::SAVEAS_HOT_FAILURE;
|
||||
lcm_action = LifeCycleManager::SAVEAS_FAILURE;
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOTPLUG_PROLOG_POWEROFF:
|
||||
|
@ -3242,6 +3242,30 @@ int VirtualMachine::set_saveas_disk(int disk_id, string& err_str)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::set_saveas_disk(int disk_id, const string& source, int iid)
|
||||
{
|
||||
if (lcm_state != HOTPLUG_SAVEAS && lcm_state != HOTPLUG_SAVEAS_SUSPENDED
|
||||
&& lcm_state != HOTPLUG_SAVEAS_POWEROFF )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
VectorAttribute * disk = get_disk(disk_id);
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
disk->replace("HOTPLUG_SAVE_AS", iid);
|
||||
disk->replace("HOTPLUG_SAVE_AS_SOURCE", source);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::set_saveas_state()
|
||||
{
|
||||
switch (state)
|
||||
@ -3339,36 +3363,11 @@ int VirtualMachine::clear_saveas_disk()
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::save_disk_hot(int disk_id,
|
||||
const string& source,
|
||||
int img_id)
|
||||
{
|
||||
if (lcm_state != HOTPLUG_SAVEAS && lcm_state != HOTPLUG_SAVEAS_SUSPENDED
|
||||
&& lcm_state != HOTPLUG_SAVEAS_POWEROFF )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
VectorAttribute * disk = get_disk(disk_id);
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
disk->replace("HOTPLUG_SAVE_AS", img_id);
|
||||
disk->replace("HOTPLUG_SAVE_AS_SOURCE", source);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::get_saveas_disk_hot(int& disk_id, string& source,
|
||||
int VirtualMachine::get_saveas_disk(int& disk_id, string& source,
|
||||
int& image_id, string& tm_mad, string& ds_id)
|
||||
{
|
||||
vector<Attribute *> disks;
|
||||
|
Reference in New Issue
Block a user