mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
parent
57dfd3176c
commit
726a6a8547
@ -144,6 +144,9 @@ public:
|
||||
BACKUP_POWEROFF = 70
|
||||
};
|
||||
|
||||
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
|
||||
*/
|
||||
|
@ -431,20 +431,21 @@ int VirtualMachine::parse_graphics(string& error_str, Template * tmpl)
|
||||
{
|
||||
password = one_util::random_password();
|
||||
|
||||
if ( graphics->vector_value("TYPE") == "SPICE" )
|
||||
{
|
||||
// Spice password must be 60 characters maximum
|
||||
graphics->replace("PASSWD", password.substr(0, 59));
|
||||
}
|
||||
else if ( graphics->vector_value("TYPE") == "vnc" )
|
||||
{
|
||||
// Vnc password must be 8 characters maximum
|
||||
graphics->replace("PASSWD", password.substr(0, 7));
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics->replace("PASSWD", password);
|
||||
}
|
||||
graphics->replace("PASSWD", password);
|
||||
}
|
||||
|
||||
string type = graphics->vector_value("TYPE");
|
||||
one_util::tolower(type);
|
||||
|
||||
if ( type == "spice" && password.size() > MAX_SPICE_PASSWD_LENGTH )
|
||||
{
|
||||
// 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;
|
||||
|
@ -1787,21 +1787,26 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
|
||||
port = graphics->vector_value("PORT");
|
||||
|
||||
one_util::tolower(type);
|
||||
|
||||
if ( random_passwrd && passwd.empty())
|
||||
{
|
||||
passwd = one_util::random_password();
|
||||
|
||||
if ( graphics->vector_value("TYPE") == "SPICE" )
|
||||
if ( type == "spice" )
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
one_util::tolower(type);
|
||||
|
||||
if ( type == "vnc" || type == "spice" )
|
||||
{
|
||||
file << "\t\t<graphics type=" << one_util::escape_xml_attr(type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user