mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
Now prolog generates the context file and includes a new CONTEXT action
in the transfer script git-svn-id: http://svn.opennebula.org/one/trunk@393 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
b0bc0222da
commit
ee35b3db66
@ -656,10 +656,12 @@ public:
|
||||
// Context related functions
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the context file for this VM.
|
||||
* Writes the context file for this VM, and gets the paths to be included
|
||||
* in the context block device (CBD)
|
||||
* @param files space separated list of paths to be included in the CBD
|
||||
* @return 0 if success
|
||||
*/
|
||||
int write_context();
|
||||
int generate_context(string &files);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -181,6 +181,7 @@ void TransferManager::prolog_action(int vid)
|
||||
string source;
|
||||
string type;
|
||||
string clon;
|
||||
string files;
|
||||
|
||||
VirtualMachine * vm;
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -245,6 +246,9 @@ void TransferManager::prolog_action(int vid)
|
||||
|
||||
if ( type == "SWAP" )
|
||||
{
|
||||
// -----------------------------------------------------------------
|
||||
// Generate a swap disk image
|
||||
// -----------------------------------------------------------------
|
||||
string size = disk->vector_value("SIZE");
|
||||
|
||||
if (size.empty()==true)
|
||||
@ -257,13 +261,9 @@ void TransferManager::prolog_action(int vid)
|
||||
}
|
||||
else
|
||||
{
|
||||
source = disk->vector_value("SOURCE");
|
||||
|
||||
if ( source.empty() )
|
||||
{
|
||||
goto error_empty_disk;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// CLONE or LINK disk images
|
||||
// -----------------------------------------------------------------
|
||||
clon = disk->vector_value("CLONE");
|
||||
|
||||
if ( clon.empty() == true )
|
||||
@ -284,6 +284,16 @@ void TransferManager::prolog_action(int vid)
|
||||
xfr << "LN ";
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Get the disk image, and set source URL
|
||||
// -----------------------------------------------------------------
|
||||
source = disk->vector_value("SOURCE");
|
||||
|
||||
if ( source.empty() )
|
||||
{
|
||||
goto error_empty_disk;
|
||||
}
|
||||
|
||||
if ( source.find(":") == string::npos ) //Regular file
|
||||
{
|
||||
xfr << nd.get_nebula_hostname() << ":" << source << " ";
|
||||
@ -299,9 +309,24 @@ void TransferManager::prolog_action(int vid)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// TODO: Context commands
|
||||
// Generate context file (There are 0...num-1 disks, constext is disk.num)
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( vm->generate_context(files) != 0 )
|
||||
{
|
||||
goto error_context;
|
||||
}
|
||||
|
||||
xfr << "CONTEXT " << vm->get_context_file() << " ";
|
||||
|
||||
if (!files.empty())
|
||||
{
|
||||
xfr << files << " ";
|
||||
}
|
||||
|
||||
xfr << vm->get_hostname() << ":" << vm->get_remote_dir()
|
||||
<< "/disk." << num << endl;
|
||||
|
||||
xfr.close();
|
||||
|
||||
tm_md->transfer(vid,vm->get_transfer_file());
|
||||
@ -310,6 +335,11 @@ void TransferManager::prolog_action(int vid)
|
||||
|
||||
return;
|
||||
|
||||
error_context:
|
||||
os.str("");
|
||||
os << "prolog, could not write context file for VM " << vid;
|
||||
goto error_common;
|
||||
|
||||
error_history:
|
||||
os.str("");
|
||||
os << "prolog, VM " << vid << " has no history";
|
||||
|
@ -632,7 +632,7 @@ void VirtualMachine::release_network_leases()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::write_context()
|
||||
int VirtualMachine::generate_context(string &files)
|
||||
{
|
||||
ofstream file;
|
||||
|
||||
@ -641,6 +641,8 @@ int VirtualMachine::write_context()
|
||||
|
||||
map<string, string>::const_iterator it;
|
||||
|
||||
files = "";
|
||||
|
||||
if ( history == 0 )
|
||||
return -1;
|
||||
|
||||
@ -669,6 +671,8 @@ int VirtualMachine::write_context()
|
||||
return -1;
|
||||
}
|
||||
|
||||
files = context->vector_value("FILES");
|
||||
|
||||
const map<string, string> values = context->value();
|
||||
|
||||
file << "# Context variables generated by OpenNebula\n";
|
||||
|
Loading…
Reference in New Issue
Block a user