mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-24 21:34:01 +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
|
// 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
|
* @return 0 if success
|
||||||
*/
|
*/
|
||||||
int write_context();
|
int generate_context(string &files);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ void TransferManager::prolog_action(int vid)
|
|||||||
string source;
|
string source;
|
||||||
string type;
|
string type;
|
||||||
string clon;
|
string clon;
|
||||||
|
string files;
|
||||||
|
|
||||||
VirtualMachine * vm;
|
VirtualMachine * vm;
|
||||||
Nebula& nd = Nebula::instance();
|
Nebula& nd = Nebula::instance();
|
||||||
@ -245,6 +246,9 @@ void TransferManager::prolog_action(int vid)
|
|||||||
|
|
||||||
if ( type == "SWAP" )
|
if ( type == "SWAP" )
|
||||||
{
|
{
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
// Generate a swap disk image
|
||||||
|
// -----------------------------------------------------------------
|
||||||
string size = disk->vector_value("SIZE");
|
string size = disk->vector_value("SIZE");
|
||||||
|
|
||||||
if (size.empty()==true)
|
if (size.empty()==true)
|
||||||
@ -257,13 +261,9 @@ void TransferManager::prolog_action(int vid)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source = disk->vector_value("SOURCE");
|
// -----------------------------------------------------------------
|
||||||
|
// CLONE or LINK disk images
|
||||||
if ( source.empty() )
|
// -----------------------------------------------------------------
|
||||||
{
|
|
||||||
goto error_empty_disk;
|
|
||||||
}
|
|
||||||
|
|
||||||
clon = disk->vector_value("CLONE");
|
clon = disk->vector_value("CLONE");
|
||||||
|
|
||||||
if ( clon.empty() == true )
|
if ( clon.empty() == true )
|
||||||
@ -284,6 +284,16 @@ void TransferManager::prolog_action(int vid)
|
|||||||
xfr << "LN ";
|
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
|
if ( source.find(":") == string::npos ) //Regular file
|
||||||
{
|
{
|
||||||
xfr << nd.get_nebula_hostname() << ":" << source << " ";
|
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();
|
xfr.close();
|
||||||
|
|
||||||
tm_md->transfer(vid,vm->get_transfer_file());
|
tm_md->transfer(vid,vm->get_transfer_file());
|
||||||
@ -310,6 +335,11 @@ void TransferManager::prolog_action(int vid)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
error_context:
|
||||||
|
os.str("");
|
||||||
|
os << "prolog, could not write context file for VM " << vid;
|
||||||
|
goto error_common;
|
||||||
|
|
||||||
error_history:
|
error_history:
|
||||||
os.str("");
|
os.str("");
|
||||||
os << "prolog, VM " << vid << " has no history";
|
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;
|
ofstream file;
|
||||||
|
|
||||||
@ -641,6 +641,8 @@ int VirtualMachine::write_context()
|
|||||||
|
|
||||||
map<string, string>::const_iterator it;
|
map<string, string>::const_iterator it;
|
||||||
|
|
||||||
|
files = "";
|
||||||
|
|
||||||
if ( history == 0 )
|
if ( history == 0 )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -669,6 +671,8 @@ int VirtualMachine::write_context()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files = context->vector_value("FILES");
|
||||||
|
|
||||||
const map<string, string> values = context->value();
|
const map<string, string> values = context->value();
|
||||||
|
|
||||||
file << "# Context variables generated by OpenNebula\n";
|
file << "# Context variables generated by OpenNebula\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user