Allow admins to use more traditional passwords for vnc/spice if they so desire

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11579 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2012-02-15 14:47:14 +00:00
parent b57b58e837
commit c74a8f5469
3 changed files with 21 additions and 8 deletions

View File

@ -185,7 +185,7 @@ vmmaster => {
}
},
vm => {
cols => [qw(node host migrationdest storage storagemodel cfgstore memory cpus nics nicmodel bootorder clockoffset virtflags master vncport textconsole powerstate beacon datacenter guestostype othersettings vidmodel vidproto comments disable)],
cols => [qw(node host migrationdest storage storagemodel cfgstore memory cpus nics nicmodel bootorder clockoffset virtflags master vncport textconsole powerstate beacon datacenter guestostype othersettings vidmodel vidproto vidpassword comments disable)],
keys => [qw(node)],
table_desc => 'Virtualization parameters',
descriptions => {
@ -219,6 +219,7 @@ vm => {
'datacenter' => "Optionally specify a datacenter for the VM to exist in (only applicable to VMWare)",
'vidproto' => "Request a specific protocol for remote video access be set up. For example, spice in KVM.",
'vidmodel' => "Model of video adapter to provide to guest. For example, qxl in KVM",
'vidpassword' => "Password to use instead of temporary random tokens for VNC and SPICE access",
}
},
hypervisor => {

View File

@ -26,7 +26,7 @@ sub grab_table_data{ #grab table data relevent to VM guest nodes
if ($vpdtab) {
$cfghash->{vpd} = $vpdtab->getNodesAttribs($noderange,['uuid']);
}
$cfghash->{vm} = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','cfgstore','storage','vidmodel','vidproto','storagemodel','memory','cpus','nics','nicmodel','bootorder','virtflags','datacenter','guestostype','othersettings','master']);
$cfghash->{vm} = $vmtab->getNodesAttribs($noderange,['node','host','migrationdest','cfgstore','storage','vidmodel','vidproto','vidpassword','storagemodel','memory','cpus','nics','nicmodel','bootorder','virtflags','datacenter','guestostype','othersettings','master']);
my $mactab = xCAT::Table->new("mac",-create=>1);
my $nrtab= xCAT::Table->new("noderes",-create=>1);
$cfghash->{mac} = $mactab->getAllNodeAttribs(['mac'],1);

View File

@ -656,7 +656,11 @@ sub build_xmldesc {
}
$xtree{devices}->{graphics}->{autoport}='yes';
$xtree{devices}->{graphics}->{listen}='0.0.0.0';
$xtree{devices}->{graphics}->{password}=genpassword(16);
if ($confdata->{vm}->{$node}->[0]->{vidpassword}) {
$xtree{devices}->{graphics}->{password}=$confdata->{vm}->{$node}->[0]->{vidpassword};
} else {
$xtree{devices}->{graphics}->{password}=genpassword(20);
}
$xtree{devices}->{sound}->{model}='ac97';
$xtree{devices}->{console}->{type}='pty';
@ -702,18 +706,22 @@ sub getcons {
$sconsparms->{node}->[0]->{baudrate}=[$serialspeed];
return (0,$sconsparms);
} elsif ($type eq "vid") {
$consdata->{server}=$hyper;
my $domxml = $dom->get_xml_description();
my $parseddom = $parser->parse_string($domxml);
my ($graphicsnode) = $parseddom->findnodes("//graphics");
my $tpasswd=genpassword(16);
my $tpasswd;
if ($confdata->{vm}->{$node}->[0]->{vidpassword}) {
$tpasswd=$confdata->{vm}->{$node}->[0]->{vidpassword};
} else {
$tpasswd=genpassword(16);
my $validto=POSIX::strftime("%Y-%m-%dT%H:%M:%S",gmtime(time()+60));
$graphicsnode->setAttribute("passwd",$tpasswd);
$graphicsnode->setAttribute("passwdValidTo",$validto);
}
$graphicsnode->setAttribute("passwd",$tpasswd);
$dom->update_device($graphicsnode->toString());
#$dom->update_device("<graphics type='".$consdata->{vidproto}."' passwd='$tpasswd' passwdValidTo='$validto' autoport='yes'/>");
$consdata->{password}=$tpasswd;
$consdata->{server}=$hyper;
return $consdata;
#return (0,{$consdata->{vidproto}.'@'.$hyper.":".$consdata->{vidport}); #$consdata->{vncport});
}
@ -1063,7 +1071,11 @@ sub makedom {
}
my $parseddom = $parser->parse_string($xml);
my ($graphics) = $parseddom->findnodes("//graphics");
$graphics->setAttribute("passwd",genpassword(20));
if ($confdata->{vm}->{$node}->[0]->{vidpassword}) {
$graphics->setAttribute("passwd",$confdata->{vm}->{$node}->[0]->{vidpassword});
} else {
$graphics->setAttribute("passwd",genpassword(20));
}
$graphics->setAttribute("listen",'0.0.0.0');
$xml = $parseddom->toString();
my $errstr;