From: Michael Goldish Subject: [KVM-AUTOTEST PATCH v2 2/5] [RFC] KVM test: DTM machine deletion tool for WHQL tests Date: Thu, 22 Jul 2010 13:14:16 +0300 Message-ID: <1279793659-22486-2-git-send-email-mgoldish@redhat.com> References: <1279793659-22486-1-git-send-email-mgoldish@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: autotest@test.kernel.org, kvm@vger.kernel.org Return-path: In-Reply-To: <1279793659-22486-1-git-send-email-mgoldish@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org This C# program should run on a DTM server. It's used by the whql_client_install test to delete the client machine from the server's data store (if listed there) prior to client installation. This seems to be necessary to prevent trouble during testing (like failure to contact the client machine). Note: the binary is copied to the server at run time, so it doesn't need to be packaged in winutils.iso. Signed-off-by: Michael Goldish --- client/tests/kvm/deps/whql_delete_machine_15.cs | 82 ++++++++++++++++++++++ client/tests/kvm/deps/whql_delete_machine_15.exe | Bin 0 -> 5632 bytes 2 files changed, 82 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/deps/whql_delete_machine_15.cs create mode 100644 client/tests/kvm/deps/whql_delete_machine_15.exe diff --git a/client/tests/kvm/deps/whql_delete_machine_15.cs b/client/tests/kvm/deps/whql_delete_machine_15.cs new file mode 100644 index 0000000..1d78a6d --- /dev/null +++ b/client/tests/kvm/deps/whql_delete_machine_15.cs @@ -0,0 +1,82 @@ +// DTM machine deletion tool +// Author: Michael Goldish +// Based on sample code by Microsoft. + +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using Microsoft.DistributedAutomation.DeviceSelection; +using Microsoft.DistributedAutomation.SqlDataStore; + +namespace automate0 +{ + class AutoJob + { + static int Main(string[] args) + { + if (args.Length != 2) + { + Console.WriteLine("Error: incorrect number of command line arguments"); + Console.WriteLine("Usage: {0} serverName clientName", + System.Environment.GetCommandLineArgs()[0]); + return 1; + } + string serverName = args[0]; + string clientName = args[1]; + + try + { + // Initialize DeviceScript and connect to data store + Console.WriteLine("Initializing DeviceScript object"); + DeviceScript script = new DeviceScript(); + Console.WriteLine("Connecting to data store"); + script.ConnectToNamedDataStore(serverName); + + // Find the client machine + IResourcePool rootPool = script.GetResourcePoolByName("$"); + Console.WriteLine("Looking for client machine '{0}'", clientName); + IResource machine = rootPool.GetResourceByName(clientName); + if (machine == null) + { + Console.WriteLine("Client machine not found"); + return 0; + } + Console.WriteLine("Client machine '{0}' found ({1}, {2})", + clientName, machine.OperatingSystem, machine.ProcessorArchitecture); + + // Change the client machine's status to 'unsafe' + Console.WriteLine("Changing the client machine's status to 'Unsafe'"); + try + { + machine.ChangeResourceStatus("Unsafe"); + } + catch (Exception e) + { + Console.WriteLine("Warning: " + e.Message); + } + while (machine.Status != "Unsafe") + { + try + { + machine = rootPool.GetResourceByName(clientName); + } + catch (Exception e) + { + Console.WriteLine("Warning: " + e.Message); + } + System.Threading.Thread.Sleep(1000); + } + + // Delete the client machine from datastore + Console.WriteLine("Deleting client machine from data store"); + script.DeleteResource(machine.Id); + return 0; + } + catch (Exception e) + { + Console.WriteLine("Error: " + e.Message); + return 1; + } + } + } +} diff --git a/client/tests/kvm/deps/whql_delete_machine_15.exe b/client/tests/kvm/deps/whql_delete_machine_15.exe new file mode 100644 index 0000000000000000000000000000000000000000..7f571345dd04b1871c5156556791d97ca2564419 GIT binary patch literal 5632 zcmeHLO>i7X6@If?N$a(>u_XV+mhI8nE=x|dT04dqW7)gX%Fa5HCA5;91X1?vY-=^n z?98TTR!A`>IwVwaq3oi#_yUKxfEy61NI?My2%KD%V=g$Zf+40K%bKHGj-Hz;=oPmlQe9o~gQ4o_aiR&WjZXjm>_pw#U5aR% zwHVPBU@&pJe*}Y$o5dXR(-?Db4_DX=&0i-rA1w-wCcHA6*=J?JdksUYVk)1a;%kS5jJQ$B}k$yV%P`%Oa=unR|fLE4w^v3@1J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