mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-24 02:03:52 +03:00
(cherry picked from commit 726a6a854751f37d130b8516197978707a8dd202)
This commit is contained in:
parent
af093bffcc
commit
59ec26c931
@ -141,6 +141,9 @@ public:
|
|||||||
HOTPLUG_SAVEAS_STOPPED = 68
|
HOTPLUG_SAVEAS_STOPPED = 68
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int MAX_VNC_PASSWD_LENGTH = 8;
|
||||||
|
static const int MAX_SPICE_PASSWD_LENGTH = 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions to convert to/from string the VM states
|
* Functions to convert to/from string the VM states
|
||||||
*/
|
*/
|
||||||
|
@ -426,15 +426,21 @@ int VirtualMachine::parse_graphics(string& error_str, Template * tmpl)
|
|||||||
{
|
{
|
||||||
password = one_util::random_password();
|
password = one_util::random_password();
|
||||||
|
|
||||||
if ( graphics->vector_value("TYPE") == "SPICE" )
|
graphics->replace("PASSWD", password);
|
||||||
{
|
}
|
||||||
// Spice password must be 60 characters maximum
|
|
||||||
graphics->replace("PASSWD", password.substr(0, 59));
|
string type = graphics->vector_value("TYPE");
|
||||||
}
|
one_util::tolower(type);
|
||||||
else
|
|
||||||
{
|
if ( type == "spice" && password.size() > MAX_SPICE_PASSWD_LENGTH )
|
||||||
graphics->replace("PASSWD", password);
|
{
|
||||||
}
|
// Spice password must be 60 characters maximum
|
||||||
|
graphics->replace("PASSWD", password.substr(0, MAX_SPICE_PASSWD_LENGTH));
|
||||||
|
}
|
||||||
|
else if ( type == "vnc" && password.size() > MAX_VNC_PASSWD_LENGTH )
|
||||||
|
{
|
||||||
|
// Vnc password must be 8 characters maximum
|
||||||
|
graphics->replace("PASSWD", password.substr(0, MAX_VNC_PASSWD_LENGTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1706,21 +1706,26 @@ int LibVirtDriver::deployment_description_kvm(
|
|||||||
|
|
||||||
port = graphics->vector_value("PORT");
|
port = graphics->vector_value("PORT");
|
||||||
|
|
||||||
|
one_util::tolower(type);
|
||||||
|
|
||||||
if ( random_passwrd && passwd.empty())
|
if ( random_passwrd && passwd.empty())
|
||||||
{
|
{
|
||||||
passwd = one_util::random_password();
|
passwd = one_util::random_password();
|
||||||
|
|
||||||
if ( graphics->vector_value("TYPE") == "SPICE" )
|
if ( type == "spice" )
|
||||||
{
|
{
|
||||||
// Spice password must be 60 characters maximum
|
// Spice password must be 60 characters maximum
|
||||||
passwd = passwd.substr(0, 59);
|
passwd = passwd.substr(0, VirtualMachine::MAX_SPICE_PASSWD_LENGTH);
|
||||||
|
}
|
||||||
|
else if ( type == "vnc" )
|
||||||
|
{
|
||||||
|
// Vnc password must be 8 characters maximum
|
||||||
|
passwd = passwd.substr(0, VirtualMachine::MAX_VNC_PASSWD_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_cast<VectorAttribute*>(graphics)->replace("PASSWD", passwd);
|
const_cast<VectorAttribute*>(graphics)->replace("PASSWD", passwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
one_util::tolower(type);
|
|
||||||
|
|
||||||
if ( type == "vnc" || type == "spice" )
|
if ( type == "vnc" || type == "spice" )
|
||||||
{
|
{
|
||||||
file << "\t\t<graphics type=" << one_util::escape_xml_attr(type);
|
file << "\t\t<graphics type=" << one_util::escape_xml_attr(type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user