mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-12 09:17:41 +03:00
parent
8c1501ed60
commit
a7cdfccf38
@ -327,6 +327,11 @@ namespace one_util
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new uuid
|
||||
*/
|
||||
std::string uuid();
|
||||
|
||||
} // namespace one_util
|
||||
|
||||
#endif /* _NEBULA_UTIL_H_ */
|
||||
|
@ -428,3 +428,25 @@ void one_util::split_unique(const string& st, char delim, set<string>& res)
|
||||
res.insert(str);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string one_util::uuid()
|
||||
{
|
||||
// Generate from random numbers to avoid adding a dependency
|
||||
ostringstream oss;
|
||||
|
||||
oss.fill('0');
|
||||
oss << hex
|
||||
<< setw(4) << random<short uint>()
|
||||
<< setw(4) << random<short uint>()
|
||||
<< "-" << setw(4) << random<short uint>()
|
||||
<< "-" << setw(4) << ((random<short uint>() & 0x0fff) | 0x4000)
|
||||
<< "-" << setw(4) << random<short uint>() % 0x3fff + 0x8000
|
||||
<< "-" << setw(4) << random<short uint>()
|
||||
<< setw(4) << random<short uint>()
|
||||
<< setw(4) << random<short uint>();
|
||||
|
||||
return oss.str();
|
||||
}
|
@ -2767,7 +2767,7 @@ void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static std::map<std::string,std::vector<std::string>> UPDATECONF_ATTRS = {
|
||||
{"OS", {"ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "KERNEL_CMD", "ROOT", "SD_DISK_BUS"} },
|
||||
{"OS", {"ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "KERNEL_CMD", "ROOT", "SD_DISK_BUS", "UUID"} },
|
||||
{"FEATURES", {"PAE", "ACPI", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT",
|
||||
"VIRTIO_SCSI_QUEUES"} },
|
||||
{"INPUT", {"TYPE", "BUS"} },
|
||||
|
@ -187,15 +187,18 @@ int VirtualMachine::parse_os(string& error_str)
|
||||
|
||||
if ( num == 0 )
|
||||
{
|
||||
return 0;
|
||||
os = new VectorAttribute("OS");
|
||||
obj_template->set(os);
|
||||
}
|
||||
else if ( num > 1 )
|
||||
{
|
||||
error_str = "Only one OS attribute can be defined.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
os = dynamic_cast<VectorAttribute *>(os_attr[0]);
|
||||
else
|
||||
{
|
||||
os = dynamic_cast<VectorAttribute *>(os_attr[0]);
|
||||
}
|
||||
|
||||
if ( os == 0 )
|
||||
{
|
||||
@ -212,6 +215,14 @@ int VirtualMachine::parse_os(string& error_str)
|
||||
|
||||
rc = set_os_file(os, "INITRD", Image::RAMDISK, error_str);
|
||||
|
||||
string uuid = os->vector_value("UUID");
|
||||
|
||||
if (uuid.empty())
|
||||
{
|
||||
uuid = one_util::uuid();
|
||||
os->replace("UUID", uuid);
|
||||
}
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
return -1;
|
||||
|
@ -614,6 +614,14 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
|
||||
file << "\t<title>" << vm->get_name() << "</title>" << endl;
|
||||
|
||||
auto os = vm->get_template_attribute("OS");
|
||||
auto uuid = os->vector_value("UUID");
|
||||
|
||||
if (!uuid.empty())
|
||||
{
|
||||
file << "\t<uuid>" << uuid << "</uuid>" << endl;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// CPU & Memory
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user