Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: client/tests/kvm/deps/whql_delete_machine_15.cs

Issue 3554003: Merge remote branch 'cros/upstream' into tempbranch3 (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tests/iperf/iperf.py ('k') | client/tests/kvm/deps/whql_delete_machine_15.exe » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/kvm/deps/whql_delete_machine_15.cs
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 0000000000000000000000000000000000000000..c7015cc2509d7d59f8c0ba599908bf9d0520f2a0
--- /dev/null
+++ b/client/tests/kvm/deps/whql_delete_machine_15.cs
@@ -0,0 +1,82 @@
+// DTM machine deletion tool
+// Author: Michael Goldish <mgoldish@redhat.com>
+// 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;
+ }
+ }
+ }
+}
« no previous file with comments | « client/tests/iperf/iperf.py ('k') | client/tests/kvm/deps/whql_delete_machine_15.exe » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698