From c74a8f5469645cb80779de6827a171c8f1acd99e Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 15 Feb 2012 14:47:14 +0000 Subject: [PATCH] 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 --- perl-xCAT/xCAT/Schema.pm | 3 ++- perl-xCAT/xCAT/VMCommon.pm | 2 +- xCAT-server/lib/xcat/plugins/kvm.pm | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index a5b6d746f..b390a473e 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -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 => { diff --git a/perl-xCAT/xCAT/VMCommon.pm b/perl-xCAT/xCAT/VMCommon.pm index ed6d9a5dc..96dc6367f 100644 --- a/perl-xCAT/xCAT/VMCommon.pm +++ b/perl-xCAT/xCAT/VMCommon.pm @@ -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); diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 574ea7e5e..9a380444f 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -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(""); $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;