mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-09 09:57:23 +03:00
Added context device to domain deployment description
git-svn-id: http://svn.opennebula.org/one/trunk@411 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
f243bb5886
commit
22b23a8a9e
@ -26,7 +26,7 @@ int LibVirtDriver::deployment_description(
|
||||
const VirtualMachine * vm,
|
||||
const string& file_name) const
|
||||
{
|
||||
|
||||
|
||||
ofstream file;
|
||||
|
||||
int num;
|
||||
@ -34,7 +34,7 @@ int LibVirtDriver::deployment_description(
|
||||
|
||||
string vcpu;
|
||||
string memory;
|
||||
|
||||
|
||||
int memory_in_kb = 0;
|
||||
|
||||
string kernel = "";
|
||||
@ -45,6 +45,7 @@ int LibVirtDriver::deployment_description(
|
||||
string bootloader = "";
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VectorAttribute * context;
|
||||
|
||||
string type = "";
|
||||
string target = "";
|
||||
@ -59,15 +60,15 @@ int LibVirtDriver::deployment_description(
|
||||
string script = "";
|
||||
|
||||
const VectorAttribute * graphics;
|
||||
|
||||
|
||||
string listen = "";
|
||||
string port = "";
|
||||
string passwd = "";
|
||||
|
||||
|
||||
const VectorAttribute * input;
|
||||
|
||||
|
||||
const VectorAttribute * features;
|
||||
|
||||
|
||||
string pae = "";
|
||||
string acpi = "";
|
||||
|
||||
@ -85,19 +86,19 @@ int LibVirtDriver::deployment_description(
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Starting XML document
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
file << "<domain type='" << emulator << "'>" << endl;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Domain name
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
file << "\t<name>one-" << vm->get_oid() << "</name>" << endl;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// CPU
|
||||
// ------------------------------------------------------------------------
|
||||
// CPU
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
vm->get_template_attribute("VCPU", vcpu);
|
||||
|
||||
@ -105,14 +106,14 @@ int LibVirtDriver::deployment_description(
|
||||
{
|
||||
get_default("VCPU", vcpu);
|
||||
}
|
||||
|
||||
|
||||
if (!vcpu.empty())
|
||||
{
|
||||
file << "\t<vcpu>" << vcpu << "</vcpu>" << endl;
|
||||
file << "\t<vcpu>" << vcpu << "</vcpu>" << endl;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Memory
|
||||
// Memory
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
vm->get_template_attribute("MEMORY",memory);
|
||||
@ -125,7 +126,7 @@ int LibVirtDriver::deployment_description(
|
||||
if (!memory.empty())
|
||||
{
|
||||
memory_in_kb = atoi(memory.c_str()) * 1024;
|
||||
|
||||
|
||||
file << "\t<memory>" << memory_in_kb << "</memory>" << endl;
|
||||
}
|
||||
else
|
||||
@ -136,24 +137,24 @@ int LibVirtDriver::deployment_description(
|
||||
// ------------------------------------------------------------------------
|
||||
// OS and boot options
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
file << "\t<os>" << endl;
|
||||
|
||||
|
||||
if (emulator == "kvm")
|
||||
{
|
||||
file << "\t\t<type>hvm</type>" << endl;
|
||||
file << "\t\t<type>hvm</type>" << endl;
|
||||
}
|
||||
|
||||
num = vm->get_template_attribute("OS",attrs);
|
||||
|
||||
|
||||
// Get values & defaults
|
||||
|
||||
if ( num > 0 )
|
||||
if ( num > 0 )
|
||||
{
|
||||
const VectorAttribute * os;
|
||||
|
||||
os = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
|
||||
|
||||
if( os != 0 )
|
||||
{
|
||||
kernel = os->vector_value("KERNEL");
|
||||
@ -179,43 +180,43 @@ int LibVirtDriver::deployment_description(
|
||||
{
|
||||
get_default("OS","BOOTLOADER",bootloader);
|
||||
}
|
||||
|
||||
|
||||
if ( boot.empty() )
|
||||
{
|
||||
get_default("OS","BOOT",boot);
|
||||
|
||||
|
||||
if ( boot.empty() )
|
||||
{
|
||||
goto error_boot;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( root.empty() )
|
||||
{
|
||||
get_default("OS","ROOT",root);
|
||||
}
|
||||
|
||||
|
||||
if ( kernel_cmd.empty() )
|
||||
{
|
||||
get_default("OS","KERNEL_CMD",kernel_cmd);
|
||||
}
|
||||
|
||||
|
||||
// Start writing to the file with the info we got
|
||||
|
||||
if ( !kernel.empty() )
|
||||
{
|
||||
file << "\t\t<kernel>" << kernel << "</kernel>" << endl;
|
||||
|
||||
|
||||
if ( !initrd.empty() )
|
||||
{
|
||||
file << "\t\t<initrd>" << initrd << "</initrd>" << endl;
|
||||
}
|
||||
|
||||
|
||||
if ( !root.empty() )
|
||||
{
|
||||
kernel_cmd = "root=/dev/" + root + " " + kernel_cmd;
|
||||
}
|
||||
|
||||
|
||||
if (!kernel_cmd.empty())
|
||||
{
|
||||
file << "\t\t<cmdline>" << kernel_cmd << "</cmdline>" << endl;
|
||||
@ -225,23 +226,23 @@ int LibVirtDriver::deployment_description(
|
||||
{
|
||||
file << "\t\t<bootloader>" << bootloader << "</bootloader>" << endl;
|
||||
}
|
||||
|
||||
|
||||
file << "\t\t<boot dev='" << boot << "'/>" << endl;
|
||||
|
||||
|
||||
|
||||
file << "\t\t<boot dev='" << boot << "'/>" << endl;
|
||||
|
||||
file << "\t</os>" << endl;
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Disks
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
file << "\t<devices>" << endl;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
file << "\t<devices>" << endl;
|
||||
|
||||
if (emulator == "kvm")
|
||||
{
|
||||
file << "\t\t<emulator>/usr/bin/kvm</emulator>" << endl;
|
||||
file << "\t\t<emulator>/usr/bin/kvm</emulator>" << endl;
|
||||
}
|
||||
|
||||
num = vm->get_template_attribute("DISK",attrs);
|
||||
@ -249,12 +250,12 @@ int LibVirtDriver::deployment_description(
|
||||
for (int i=0; i < num ;i++,target="",ro="")
|
||||
{
|
||||
disk = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
type = disk->vector_value("TYPE");
|
||||
target = disk->vector_value("TARGET");
|
||||
ro = disk->vector_value("READONLY");
|
||||
@ -280,8 +281,8 @@ int LibVirtDriver::deployment_description(
|
||||
if ( type.empty() )
|
||||
{
|
||||
type = "disk";
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
string type_=type;
|
||||
transform(type_.begin(),type_.end(),type_.begin(),(int(*)(int))toupper);
|
||||
@ -290,46 +291,73 @@ int LibVirtDriver::deployment_description(
|
||||
type="disk";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
file << "\t\t<disk type='file' device='" << type << "'>" << endl;
|
||||
file << "\t\t\t<source file='" << vm->get_remote_dir() << "/disk." << i
|
||||
file << "\t\t\t<source file='" << vm->get_remote_dir() << "/disk." << i
|
||||
<< "'/>" << endl;
|
||||
file << "\t\t\t<target dev='" << target << "'";
|
||||
|
||||
file << "\t\t\t<target dev='" << target << "'";
|
||||
|
||||
if (!bus.empty())
|
||||
{
|
||||
file << " bus='" << bus << "'/>" << endl;
|
||||
{
|
||||
file << " bus='" << bus << "'/>" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
file << "/>" << endl;
|
||||
}
|
||||
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
file << "\t\t\t<readonly/>" << endl;
|
||||
file << "\t\t\t<readonly/>" << endl;
|
||||
}
|
||||
|
||||
|
||||
file << "\t\t</disk>" << endl;
|
||||
}
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Network interfaces
|
||||
// ------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
// Context Device
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( vm->get_template_attribute("CONTEXT",attrs) == 1 )
|
||||
{
|
||||
context = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
target = disk->vector_value("TARGET");
|
||||
|
||||
if ( !target.empty() )
|
||||
{
|
||||
file << "\t\t<disk type='file' device='disk'>" << endl;
|
||||
file << "\t\t\t<source file='" << vm->get_remote_dir() << "/disk."
|
||||
<< num << "'/>" << endl;
|
||||
file << "\t\t\t<target dev='" << target << "'";
|
||||
file << "\t\t\t<readonly/>" << endl;
|
||||
file << "\t\t</disk>" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("VMM", Log::WARNING, "Could not find target device to"
|
||||
" attach context, will continue without it.");
|
||||
}
|
||||
}
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Network interfaces
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
num = vm->get_template_attribute("NIC",attrs);
|
||||
|
||||
for(int i=0; i<num;i++,mac="",bridge="",target="",script="")
|
||||
{
|
||||
nic = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
|
||||
if ( nic == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
bridge = nic->vector_value("BRIDGE");
|
||||
|
||||
if ( bridge.empty() )
|
||||
@ -340,7 +368,7 @@ int LibVirtDriver::deployment_description(
|
||||
{
|
||||
file << "\t\t<interface type='bridge'>" << endl;
|
||||
file << "\t\t\t<source bridge='" << bridge << "'/>" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
mac = nic->vector_value("MAC");
|
||||
|
||||
@ -348,21 +376,21 @@ int LibVirtDriver::deployment_description(
|
||||
{
|
||||
file << "\t\t\t<mac address='" << mac << "'/>" << endl;
|
||||
}
|
||||
|
||||
|
||||
target = nic->vector_value("TARGET");
|
||||
|
||||
|
||||
if( !target.empty() )
|
||||
{
|
||||
file << "\t\t\t<target dev='" << target << "'/>" << endl;
|
||||
}
|
||||
|
||||
|
||||
script = nic->vector_value("SCRIPT");
|
||||
|
||||
|
||||
if( !script.empty() )
|
||||
{
|
||||
file << "\t\t\t<script path='" << script << "'/>" << endl;
|
||||
}
|
||||
|
||||
|
||||
file << "\t\t</interface>" << endl;
|
||||
|
||||
}
|
||||
@ -376,14 +404,14 @@ int LibVirtDriver::deployment_description(
|
||||
if ( vm->get_template_attribute("GRAPHICS",attrs) > 0 )
|
||||
{
|
||||
graphics = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
|
||||
|
||||
if ( graphics != 0 )
|
||||
{
|
||||
type = graphics->vector_value("TYPE");
|
||||
listen = graphics->vector_value("LISTEN");
|
||||
port = graphics->vector_value("PORT");
|
||||
passwd = graphics->vector_value("PASSWD");
|
||||
|
||||
|
||||
if ( type == "vnc" || type == "VNC" )
|
||||
{
|
||||
file << "\t\t<graphics type='vnc'";
|
||||
@ -403,17 +431,17 @@ int LibVirtDriver::deployment_description(
|
||||
file << " password='" << passwd << "'";
|
||||
}
|
||||
|
||||
file << "/>" << endl;
|
||||
file << "/>" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("VMM", Log::WARNING, "Not supported graphics type, ignored.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
attrs.clear();
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Input
|
||||
// ------------------------------------------------------------------------
|
||||
@ -421,7 +449,7 @@ int LibVirtDriver::deployment_description(
|
||||
if ( vm->get_template_attribute("INPUT",attrs) > 0 )
|
||||
{
|
||||
input = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
|
||||
|
||||
if ( input != 0 )
|
||||
{
|
||||
type = input->vector_value("TYPE");
|
||||
@ -430,52 +458,52 @@ int LibVirtDriver::deployment_description(
|
||||
if ( !type.empty() )
|
||||
{
|
||||
file << "\t\t<input type='" << type << "'";
|
||||
|
||||
|
||||
if ( !bus.empty() )
|
||||
{
|
||||
file << " bus='" << bus << "'";
|
||||
}
|
||||
|
||||
|
||||
file << "/>" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
attrs.clear();
|
||||
|
||||
|
||||
file << "\t</devices>" << endl;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Features
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
num = vm->get_template_attribute("FEATURES",attrs);
|
||||
|
||||
if ( num > 0 )
|
||||
{
|
||||
if ( num > 0 )
|
||||
{
|
||||
features = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
|
||||
|
||||
if ( features != 0 )
|
||||
{
|
||||
pae = features->vector_value("PAE");
|
||||
acpi = features->vector_value("ACPI");
|
||||
|
||||
file << "\t<features>" << endl;
|
||||
|
||||
|
||||
if ( pae == "yes" )
|
||||
{
|
||||
file << "\t\t<pae/>" << endl;
|
||||
}
|
||||
|
||||
|
||||
if ( acpi == "no" )
|
||||
{
|
||||
file << "\t\t<acpi/>" << endl;
|
||||
}
|
||||
|
||||
|
||||
file << "\t</features>" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -487,23 +515,23 @@ int LibVirtDriver::deployment_description(
|
||||
for(int i=0; i<num;i++)
|
||||
{
|
||||
raw = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
|
||||
if ( raw == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
type = raw->vector_value("TYPE");
|
||||
|
||||
transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
|
||||
|
||||
if ( type == "KVM" )
|
||||
{
|
||||
{
|
||||
data = raw->vector_value("DATA");
|
||||
file << "\t" << data << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
file << "</domain>" << endl;
|
||||
|
||||
file.close();
|
||||
@ -513,19 +541,19 @@ int LibVirtDriver::deployment_description(
|
||||
error_file:
|
||||
vm->log("VMM", Log::ERROR, "Could not open KVM deployment file.");
|
||||
return -1;
|
||||
|
||||
|
||||
error_memory:
|
||||
vm->log("VMM", Log::ERROR, "No MEMORY defined and no default provided.");
|
||||
file.close();
|
||||
file.close();
|
||||
return -1;
|
||||
|
||||
error_boot:
|
||||
vm->log("VMM", Log::ERROR, "No BOOT device defined and no default provided.");
|
||||
file.close();
|
||||
file.close();
|
||||
return -1;
|
||||
|
||||
error_disk:
|
||||
vm->log("VMM", Log::ERROR, "Wrong target value in DISK.");
|
||||
file.close();
|
||||
file.close();
|
||||
return -1;
|
||||
}
|
||||
|
@ -26,15 +26,15 @@ int XenDriver::deployment_description(
|
||||
const string& file_name) const
|
||||
{
|
||||
ofstream file;
|
||||
|
||||
|
||||
int num;
|
||||
vector<const Attribute *> attrs;
|
||||
|
||||
|
||||
string credits;
|
||||
string cpu;
|
||||
string memory;
|
||||
string vcpu;
|
||||
|
||||
|
||||
float base_credit = 1.0;
|
||||
float cpu_units = 1.0;
|
||||
|
||||
@ -45,18 +45,19 @@ int XenDriver::deployment_description(
|
||||
string bootloader = "";
|
||||
|
||||
const VectorAttribute * disk;
|
||||
|
||||
const VectorAttribute * context;
|
||||
|
||||
string target = "";
|
||||
string ro = "";
|
||||
string mode;
|
||||
|
||||
const VectorAttribute * nic;
|
||||
|
||||
|
||||
string mac = "";
|
||||
string bridge = "";
|
||||
|
||||
const VectorAttribute * graphics;
|
||||
|
||||
|
||||
string type = "";
|
||||
string listen = "";
|
||||
string port = "";
|
||||
@ -64,11 +65,11 @@ int XenDriver::deployment_description(
|
||||
|
||||
const VectorAttribute * raw;
|
||||
string data;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
file.open(file_name.c_str(), ios::out);
|
||||
|
||||
|
||||
if (file.fail() == true)
|
||||
{
|
||||
goto error_file;
|
||||
@ -76,34 +77,34 @@ int XenDriver::deployment_description(
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Domain name
|
||||
// ------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
file << "name = 'one-" << vm->get_oid() << "'" << endl;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Capacity CPU, Mem & Credits
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
get_default("CREDIT", credits);
|
||||
|
||||
|
||||
if(!credits.empty())
|
||||
{
|
||||
base_credit = atof(credits.c_str());
|
||||
}
|
||||
|
||||
|
||||
vm->get_template_attribute("CPU", cpu);
|
||||
|
||||
|
||||
if(!cpu.empty())
|
||||
{
|
||||
cpu_units = atof(cpu.c_str());
|
||||
}
|
||||
|
||||
|
||||
file << "#O CPU_CREDITS = " << ceil(cpu_units*base_credit) << endl;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
vm->get_template_attribute("MEMORY",memory);
|
||||
|
||||
|
||||
if (memory.empty())
|
||||
{
|
||||
get_default("MEMORY",memory);
|
||||
@ -117,16 +118,16 @@ int XenDriver::deployment_description(
|
||||
{
|
||||
goto error_memory;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
vm->get_template_attribute("VCPU",vcpu);
|
||||
|
||||
|
||||
if (vcpu.empty())
|
||||
{
|
||||
get_default("VCPU",vcpu);
|
||||
}
|
||||
|
||||
|
||||
if (!vcpu.empty())
|
||||
{
|
||||
file << "vcpu = '" << vcpu << "'" << endl;
|
||||
@ -135,15 +136,15 @@ int XenDriver::deployment_description(
|
||||
// ------------------------------------------------------------------------
|
||||
// OS and boot options
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
num = vm->get_template_attribute("OS",attrs);
|
||||
|
||||
|
||||
if ( num > 0 )
|
||||
{
|
||||
const VectorAttribute * os;
|
||||
|
||||
|
||||
os = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
|
||||
|
||||
if ( os != 0 )
|
||||
{
|
||||
kernel = os->vector_value("KERNEL");
|
||||
@ -163,31 +164,31 @@ int XenDriver::deployment_description(
|
||||
{
|
||||
get_default("OS","INITRD",initrd);
|
||||
}
|
||||
|
||||
|
||||
if ( bootloader.empty() )
|
||||
{
|
||||
get_default("OS","BOOTLOADER",bootloader);
|
||||
}
|
||||
}
|
||||
|
||||
if ( root.empty() )
|
||||
{
|
||||
get_default("OS","ROOT",root);
|
||||
}
|
||||
|
||||
|
||||
if ( kernel_cmd.empty() )
|
||||
{
|
||||
get_default("OS","KERNEL_CMD",kernel_cmd);
|
||||
}
|
||||
|
||||
|
||||
if ( !kernel.empty() ) //Direct Kernel boot method
|
||||
{
|
||||
file << "kernel = '" << kernel << "'" << endl;
|
||||
|
||||
|
||||
if ( !initrd.empty() )
|
||||
{
|
||||
file << "ramdisk = '" << initrd << "'" << endl;
|
||||
}
|
||||
|
||||
|
||||
if ( !root.empty() )
|
||||
{
|
||||
file << "root = '/dev/" << root << "'" << endl;
|
||||
@ -200,52 +201,52 @@ int XenDriver::deployment_description(
|
||||
}
|
||||
else if ( !bootloader.empty() ) //Host loader boot method
|
||||
{
|
||||
file << "bootloader = \"" << bootloader << "\"" << endl;
|
||||
file << "bootloader = \"" << bootloader << "\"" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto error_boot;
|
||||
goto error_boot;
|
||||
}
|
||||
|
||||
|
||||
attrs.clear();
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Disks
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
num = vm->get_template_attribute("DISK",attrs);
|
||||
|
||||
|
||||
file << "disk = [" << endl;
|
||||
|
||||
for (int i=0; i < num ;i++,target="",ro="")
|
||||
{
|
||||
disk = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
target = disk->vector_value("TARGET");
|
||||
ro = disk->vector_value("READONLY");
|
||||
|
||||
|
||||
if ( target.empty() )
|
||||
{
|
||||
goto error_disk;
|
||||
}
|
||||
|
||||
|
||||
mode = "w";
|
||||
|
||||
|
||||
if ( !ro.empty() )
|
||||
{
|
||||
transform(ro.begin(),ro.end(),ro.begin(),(int(*)(int))toupper);
|
||||
|
||||
|
||||
if ( ro == "YES" )
|
||||
{
|
||||
mode = "r";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: "file" method to specify disk images in xen is deprecated.
|
||||
// The new method is using "tap:aio:" instead of "file:"
|
||||
file << " "
|
||||
@ -255,41 +256,66 @@ int XenDriver::deployment_description(
|
||||
<< "'," << endl;
|
||||
}
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Context Device
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( vm->get_template_attribute("CONTEXT",attrs) == 1 )
|
||||
{
|
||||
context = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
target = disk->vector_value("TARGET");
|
||||
|
||||
if ( !target.empty() )
|
||||
{
|
||||
file << " "
|
||||
<< "'tap:aio:" << vm->get_remote_dir() << "/disk." << num <<","
|
||||
<< target << ","
|
||||
<< "ro'," << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("VMM", Log::WARNING, "Could not find target device to"
|
||||
" attach context, will continue without it.");
|
||||
}
|
||||
}
|
||||
|
||||
file << "]" << endl;
|
||||
|
||||
attrs.clear();
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Network
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
num = vm->get_template_attribute("NIC",attrs);
|
||||
|
||||
|
||||
file << "vif = [" << endl;
|
||||
|
||||
|
||||
for(int i=0; i<num;i++,mac="",bridge="")
|
||||
{
|
||||
char pre_char = ' ';
|
||||
|
||||
|
||||
nic = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
|
||||
if ( nic == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
file << " '";
|
||||
|
||||
|
||||
mac = nic->vector_value("MAC");
|
||||
|
||||
|
||||
if( !mac.empty() )
|
||||
{
|
||||
file << "mac=" << mac;
|
||||
pre_char = ',';
|
||||
}
|
||||
|
||||
|
||||
bridge = nic->vector_value("BRIDGE");
|
||||
|
||||
|
||||
if( !bridge.empty() )
|
||||
{
|
||||
file << pre_char << "bridge=" << bridge;
|
||||
@ -298,35 +324,35 @@ int XenDriver::deployment_description(
|
||||
file << "',";
|
||||
file << endl;
|
||||
}
|
||||
|
||||
|
||||
file << "]" << endl;
|
||||
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Graphics
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
if ( vm->get_template_attribute("GRAPHICS",attrs) > 0 )
|
||||
{
|
||||
graphics = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
|
||||
|
||||
if ( graphics != 0 )
|
||||
{
|
||||
type = graphics->vector_value("TYPE");
|
||||
listen = graphics->vector_value("LISTEN");
|
||||
port = graphics->vector_value("PORT");
|
||||
passwd = graphics->vector_value("PASSWD");
|
||||
|
||||
|
||||
if ( type == "vnc" || type == "VNC" )
|
||||
{
|
||||
file << "vfb = ['type=vnc";
|
||||
|
||||
file << "vfb = ['type=vnc";
|
||||
|
||||
if ( !listen.empty() )
|
||||
{
|
||||
file << ",vnclisten=" << listen;
|
||||
}
|
||||
|
||||
|
||||
if ( !port.empty() )
|
||||
{
|
||||
file << ",vncdisplay=" << port;
|
||||
@ -336,39 +362,39 @@ int XenDriver::deployment_description(
|
||||
{
|
||||
file << ",vncpasswd=" << passwd;
|
||||
}
|
||||
|
||||
file <<"']" << endl;
|
||||
|
||||
file <<"']" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("VMM", Log::WARNING, "Not supported graphics type, ignored.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
attrs.clear();
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Raw XEN attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
num = vm->get_template_attribute("RAW",attrs);
|
||||
|
||||
|
||||
for(int i=0; i<num;i++)
|
||||
{
|
||||
raw = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
|
||||
if ( raw == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
type = raw->vector_value("TYPE");
|
||||
|
||||
|
||||
transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
|
||||
|
||||
|
||||
if ( type == "XEN" )
|
||||
{
|
||||
{
|
||||
data = raw->vector_value("DATA");
|
||||
file << data << endl;
|
||||
}
|
||||
@ -381,19 +407,19 @@ int XenDriver::deployment_description(
|
||||
error_file:
|
||||
vm->log("VMM", Log::ERROR, "Could not open Xen deployment file.");
|
||||
return -1;
|
||||
|
||||
|
||||
error_memory:
|
||||
vm->log("VMM", Log::ERROR, "No memory defined and no default provided.");
|
||||
file.close();
|
||||
file.close();
|
||||
return -1;
|
||||
|
||||
error_boot:
|
||||
vm->log("VMM", Log::ERROR, "No kernel or bootloader defined and no default provided.");
|
||||
file.close();
|
||||
file.close();
|
||||
return -1;
|
||||
|
||||
error_disk:
|
||||
vm->log("VMM", Log::ERROR, "Wrong target value in DISK.");
|
||||
file.close();
|
||||
file.close();
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user