Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F #3272: Add presave postsave prerestore postrestore tm actions [not completed] [need help] #3273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions include/TransferManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ class TransferManager : public MadManager, public ActionListener
VirtualMachine * vm,
ostream& xfr);

/**
* Inserts a transfer command in the xfs stream, for save
*
* @param vm The VM
* @param xfr Stream where the transfer command will be written
*/
void save_transfer_command(
VirtualMachine * vm,
ostream& xfr);

/**
* Inserts a transfer command in the xfs stream, for restore
*
* @param vm The VM
* @param xfr Stream where the transfer command will be written
*/
void restore_transfer_command(
VirtualMachine * vm,
ostream& xfr);

/**
* This function generates the epilog_delete sequence for current,
* front-end and previous hosts.
Expand Down
41 changes: 41 additions & 0 deletions src/tm/TransferManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,47 @@ void TransferManager::migrate_transfer_command(
<< endl;
}


/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

void TransferManager::save_transfer_command(
VirtualMachine * vm,
ostream& xfr)
{
// <PRESAVE/POSTSAVE> tm_mad SOURCE DST remote_system_dir vmid dsid

xfr << "SAVE " //TM action PRE or POST to be completed by VMM driver
<< vm->get_tm_mad() << " "
<< vm->get_previous_hostname() << " "
<< vm->get_hostname() << " "
<< vm->get_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;
}


/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

void TransferManager::restore_transfer_command(
VirtualMachine * vm,
ostream& xfr)
{
// <PRERESTORE/POSTRESTORE> tm_mad SOURCE DST remote_system_dir vmid dsid

xfr << "RESTORE " //TM action PRE or POST to be completed by VMM driver
<< vm->get_tm_mad() << " "
<< vm->get_previous_hostname() << " "
<< vm->get_hostname() << " "
<< vm->get_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;
}


/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

Expand Down
4 changes: 4 additions & 0 deletions src/vmm/VirtualMachineManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ void VirtualMachineManager::save_action(
ds_id = vm->get_ds_id();
}

Nebula::instance().get_tm()->save_transfer_command(vm, os);

// Invoke driver method
drv_msg = format_message(
hostname,
Expand Down Expand Up @@ -1287,6 +1289,8 @@ void VirtualMachineManager::restore_action(
goto error_no_tm_command;
}

Nebula::instance().get_tm()->restore_transfer_command(vm, os);

// Invoke driver method
drv_msg = format_message(
vm->get_hostname(),
Expand Down
36 changes: 36 additions & 0 deletions src/vmm_mad/exec/one_vmm_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,19 @@ def cancel(id, drv_message)
#
def save(id, drv_message)
action = VmmAction.new(self, id, :save, drv_message)
pre = "PRE"
post = "POST"

pre << action.data[:tm_command] << " " << action.data[:vm]
post << action.data[:tm_command] << " " << action.data[:vm]

steps=[
# Execute a pre-save TM setup
{
:driver => :tm,
:action => :tm_presave,
:parameters => pre.split
},
# Save the Virtual Machine state
{
:driver => :vmm,
Expand All @@ -481,6 +492,13 @@ def save(id, drv_message)
{
:driver => :vnm,
:action => :clean
},
# Execute a post-save TM setup
{
:driver => :tm,
:action => :tm_postsave,
:parameters => post.split,
:no_fail => true
}
]

Expand All @@ -507,8 +525,19 @@ def restore(id, drv_message)
end

action=VmmAction.new(self, id, :restore, drv_message)
pre = "PRE"
post = "POST"

pre << action.data[:tm_command] << " " << action.data[:vm]
post << action.data[:tm_command] << " " << action.data[:vm]

steps.concat([
# Execute a pre-restore TM setup
{
:driver => :tm,
:action => :tm_prerestore,
:parameters => pre.split
},
# Execute pre-boot networking setup
{
:driver => :vnm,
Expand All @@ -532,6 +561,13 @@ def restore(id, drv_message)
:parameters => [:deploy_id, :host]
}
],
},
# Execute a post-restore TM setup
{
:driver => :tm,
:action => :tm_postrestore,
:parameters => post.split,
:no_fail => true
}
])

Expand Down