- add kvptest.ps1.txt to docs, a PowerShell script to verify KVP

OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=20
This commit is contained in:
Olaf Hering 2012-03-27 06:51:38 +00:00 committed by Git OBS Bridge
parent 54af41b96e
commit ca8e1383b7
3 changed files with 57 additions and 0 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Mar 27 08:50:43 CEST 2012 - ohering@suse.de
- add kvptest.ps1.txt to docs, a PowerShell script to verify KVP
-------------------------------------------------------------------
Mon Mar 26 19:05:48 CEST 2012 - ohering@suse.de

49
hyper-v.kvptest.ps1.txt Normal file
View File

@ -0,0 +1,49 @@
# Windows PowerShell script to test Key Value Pair functionality
#
# http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/11/18/hyper-v-script-looking-at-kvp-guestintrinsicexchangeitems.aspx
#
# Per default execution of scripts is disabled.
# http://technet.microsoft.com/en-us/library/ee176949.aspx
# The command 'Set-ExecutionPolicy RemoteSigned' will enable it.
#
# Filter for parsing XML data
filter Import-CimXml
{
# Create new XML object from input
$CimXml = [Xml]$_
$CimObj = New-Object -TypeName System.Object
# Iterate over the data and pull out just the value name and data for each entry
foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY[@NAME='Name']"))
{
$CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE
}
foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY[@NAME='Data']"))
{
$CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE
}
# Display output
$CimObj
}
# Prompt for the Hyper-V Server to use
$HyperVServer = Read-Host "Specify the Hyper-V Server to use (enter '.' for the local computer)"
# Prompt for the virtual machine to use
$VMName = Read-Host "Specify the name of the virtual machine"
# Get the virtual machine object
$query = "Select * From Msvm_ComputerSystem Where ElementName='" + $VMName + "'"
$Vm = gwmi -namespace root\virtualization -query $query -computername $HyperVServer
# Get the KVP Object
$query = "Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent"
$Kvp = gwmi -namespace root\virtualization -query $query -computername $HyperVServer
Write-Host
Write-Host "Guest KVP information for" $VMName
# Filter the results
$Kvp.GuestIntrinsicExchangeItems | Import-CimXml

View File

@ -45,6 +45,7 @@ Source1: hyperv_pvdrivers.conf
Source2: kmp_filelist
Source3: hyper-v.supplements.txt
Source4: hyper-v.dummy_ko.c
Source5: hyper-v.kvptest.ps1.txt
Source9: hyper-v.include.linux.hyperv.h
Source10: hyper-v.tools.hv.hv_kvp_daemon.c
Source11: hyper-v.init.sh
@ -81,6 +82,7 @@ This package contains the Microsoft Hyper-V drivers.
%prep
%setup -Tc
cp -avL %{S:5} kvptest.ps1.txt
cp -vL %{S:9} %{hv_kvp_daemon}.h
cp -vL %{S:10} %{hv_kvp_daemon}.c
sed -i~ '/#include <linux.hyperv.h>/d' %{hv_kvp_daemon}.c
@ -129,6 +131,7 @@ install -m644 %SOURCE1 $RPM_BUILD_ROOT/etc/modprobe.d/hyperv_pvdrivers.conf
%files
%defattr (-,root,root)
%doc kvptest.ps1.txt
%if !%{with_kmp}
%dir /etc/modprobe.d
%config /etc/modprobe.d/hyperv_pvdrivers.conf