1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-26 06:50:09 +03:00

Merge branch 'master' of dsa-research.org:one

This commit is contained in:
Tino Vázquez 2010-11-03 12:10:37 +01:00
commit 8299982009
10 changed files with 121 additions and 24 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# chkconfig: 2345 10 90
# chkconfig: 2345 9 90
# description: network reconfigure
#
# -------------------------------------------------------------------------- #

View File

@ -49,7 +49,7 @@ class InformationManager < OpenNebulaDriver
@config = read_configuration
@hypervisor = hypervisor
@remote_dir = @config['SCRIPTS_REMOTE_DIR'] || '/tmp/one'
@remote_dir = @config['SCRIPTS_REMOTE_DIR']
# register actions
register_action(:MONITOR, method("action_monitor"))

View File

@ -434,9 +434,9 @@ int Image::drop(SqlDB * db)
ostream& operator<<(ostream& os, Image& image)
{
string image_str;
string image_str;
os << image.to_xml(image_str);
os << image.to_xml(image_str);
return os;
}
@ -571,20 +571,25 @@ int Image::disk_attribute( VectorAttribute * disk,
{
string bus;
string target;
string driver;
ostringstream iid;
*img_type = type;
bus = disk->vector_value("BUS");
target = disk->vector_value("TARGET");
driver = disk->vector_value("DRIVER");
iid << oid;
string template_bus;
string template_target;
string prefix;
string template_driver;
get_template_attribute("BUS", template_bus);
get_template_attribute("TARGET", template_target);
get_template_attribute("DRIVER", template_driver);
get_template_attribute("DEV_PREFIX", prefix);
//--------------------------------------------------------------------------
@ -612,7 +617,16 @@ int Image::disk_attribute( VectorAttribute * disk,
}
else if (!template_bus.empty())
{
new_disk.insert(make_pair("BUS",template_bus));
new_disk.insert(make_pair("BUS",template_bus));
}
if (!driver.empty())
{
new_disk.insert(make_pair("DRIVER",driver));
}
else if (!template_driver.empty())
{
new_disk.insert(make_pair("DRIVER",template_driver));
}
//---------------------------------------------------------------------------
@ -714,4 +728,3 @@ string Image::sha1_digest(const string& pass)
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */

View File

@ -183,7 +183,7 @@ private
if ENV['ONE_LOCATION']
one_config=ENV['ONE_LOCATION']+'/var/config'
else
one_config='/var/log/one/config'
one_config='/var/lib/one/config'
end
config=Hash.new

View File

@ -52,6 +52,7 @@ NebulaTemplate::NebulaTemplate(string& etc_location, string& var_location)
# PORT
# DB
# VNC_BASE_PORT
# SCRIPTS_REMOTE_DIR
#*******************************************************************************
*/
// MONITOR_INTERVAL
@ -94,6 +95,13 @@ NebulaTemplate::NebulaTemplate(string& etc_location, string& var_location)
attribute = new SingleAttribute("PORT",value);
conf_default.insert(make_pair(attribute->name(),attribute));
//SCRIPTS_REMOTE_DIR
value = "/var/tmp/one";
attribute = new SingleAttribute("SCRIPTS_REMOTE_DIR",value);
conf_default.insert(make_pair(attribute->name(),attribute));
/*
#*******************************************************************************
# Physical Networks configuration
@ -188,4 +196,3 @@ int NebulaTemplate::load_configuration()
return 0;
}

View File

@ -49,6 +49,8 @@ int LibVirtDriver::deployment_description_kvm(
string target = "";
string bus = "";
string ro = "";
string driver = "";
string default_driver = "";
bool readonly;
const VectorAttribute * nic;
@ -245,6 +247,13 @@ int LibVirtDriver::deployment_description_kvm(
file << "\t\t<emulator>/usr/bin/kvm</emulator>" << endl;
}
get_default("DISK","DRIVER",default_driver);
if (default_driver.empty())
{
default_driver = "raw";
}
num = vm->get_template_attribute("DISK",attrs);
for (int i=0; i < num ;i++)
@ -260,6 +269,7 @@ int LibVirtDriver::deployment_description_kvm(
target = disk->vector_value("TARGET");
ro = disk->vector_value("READONLY");
bus = disk->vector_value("BUS");
driver = disk->vector_value("DRIVER");
if (target.empty())
{
@ -278,6 +288,8 @@ int LibVirtDriver::deployment_description_kvm(
}
}
// ---- Disk type and source for the image ----
if (type.empty() == false)
{
transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
@ -302,8 +314,12 @@ int LibVirtDriver::deployment_description_kvm(
<< i << "'/>" << endl;
}
// ---- target device to map the disk ----
file << "\t\t\t<target dev='" << target << "'";
// ---- bus ----
if (!bus.empty())
{
file << " bus='" << bus << "'/>" << endl;
@ -313,11 +329,26 @@ int LibVirtDriver::deployment_description_kvm(
file << "/>" << endl;
}
// ---- readonly attribute for the disk ----
if (readonly)
{
file << "\t\t\t<readonly/>" << endl;
}
// ---- Image Format using qemu driver ----
file << "\t\t\t<driver name='qemu' type='";
if ( !driver.empty() )
{
file << driver << "'/>" << endl;
}
else
{
file << default_driver << "'/>" << endl;
}
file << "\t\t</disk>" << endl;
}
@ -331,6 +362,7 @@ int LibVirtDriver::deployment_description_kvm(
{
context = dynamic_cast<const VectorAttribute *>(attrs[0]);
target = context->vector_value("TARGET");
driver = context->vector_value("DRIVER");
if ( !target.empty() )
{
@ -339,6 +371,18 @@ int LibVirtDriver::deployment_description_kvm(
<< num << "'/>" << endl;
file << "\t\t\t<target dev='" << target << "'/>" << endl;
file << "\t\t\t<readonly/>" << endl;
file << "\t\t\t<driver name='qemu' type='";
if ( !driver.empty() )
{
file << driver << "'/>" << endl;
}
else
{
file << default_driver << "'/>" << endl;
}
file << "\t\t</disk>" << endl;
}
else
@ -587,4 +631,3 @@ error_disk:
file.close();
return -1;
}

View File

@ -49,12 +49,15 @@ int XenDriver::deployment_description(
string target = "";
string ro = "";
string type = "";
string driver = "";
string default_driver = "";
string mode;
const VectorAttribute * nic;
string mac = "";
string bridge = "";
string model = "";
const VectorAttribute * graphics;
@ -216,6 +219,13 @@ int XenDriver::deployment_description(
num = vm->get_template_attribute("DISK",attrs);
get_default("DISK","DRIVER",default_driver);
if (default_driver.empty())
{
default_driver = "tap:aio:";
}
file << "disk = [" << endl;
for (int i=0; i < num ;i++)
@ -230,6 +240,7 @@ int XenDriver::deployment_description(
target = disk->vector_value("TARGET");
type = disk->vector_value("TYPE");
ro = disk->vector_value("READONLY");
driver = disk->vector_value("DRIVER");
if ( target.empty() )
{
@ -253,13 +264,20 @@ int XenDriver::deployment_description(
}
}
if ( type == "BLOCK" )
if ( !driver.empty() )
{
file << " 'phy:";
file << " '" << driver;
}
else
{
file << " 'tap:aio:";
if ( type == "BLOCK" )
{
file << " 'phy:";
}
else
{
file << " '" << default_driver;
}
}
file << vm->get_remote_dir() << "/disk." << i << ","
@ -278,12 +296,22 @@ int XenDriver::deployment_description(
{
context = dynamic_cast<const VectorAttribute *>(attrs[0]);
target = context->vector_value("TARGET");
driver = context->vector_value("DRIVER");
if ( !target.empty() )
{
file << " "
<< "'tap:aio:" << vm->get_remote_dir() << "/disk." << num <<","
<< target << ","
file << " '";
if ( !driver.empty() )
{
file << driver;
}
else
{
file << default_driver;
}
file << vm->get_remote_dir() << "/disk." << num <<","<< target <<","
<< "r'," << endl;
}
else
@ -320,10 +348,17 @@ int XenDriver::deployment_description(
mac = nic->vector_value("MAC");
bridge = nic->vector_value("BRIDGE");
model = nic->vector_value("MODEL");
if( !model.empty() )
{
file << "type=" << model;
pre_char = ',';
}
if( !mac.empty() )
{
file << "mac=" << mac;
file << pre_char << "mac=" << mac;
pre_char = ',';
}

View File

@ -47,7 +47,7 @@ class SshDriver < VirtualMachineDriver
@config = read_configuration
@hypervisor = hypervisor
@remote_dir = @config['SCRIPTS_REMOTE_DIR'] || '/tmp/one'
@remote_dir = @config['SCRIPTS_REMOTE_DIR']
end
# ------------------------------------------------------------------------ #

View File

@ -6,13 +6,11 @@
# - cpu
# - vcpu
# - features [acpi, pae]
# - disk [driver ]
#VCPU = 1
#MEMORY = 128
#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", boot=hd,kernel_cmd="ro"]
OS = [ boot = "hd" ]
OS = [ boot = "hd" ]
FEATURES = [ PAE = "no", ACPI = "yes" ]
FEATURES = [
PAE=no,
ACPI=yes
]
DISK = [ driver = "raw" ]

View File

@ -5,9 +5,10 @@
# - os [kernel,initrd,root,kernel_cmd]
# - memory
# - vcpu
# - disk[driver]
#VCPU = 1
#MEMORY = 128
#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", kernel_cmd="ro" ]
CREDIT = 256
DISK = [ driver = "tap:aio:" ]