Skip to content

Commit

Permalink
adding --reimage option
Browse files Browse the repository at this point in the history
  • Loading branch information
smarx committed Sep 14, 2012
1 parent ba4e0b7 commit 2f382f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
27 changes: 15 additions & 12 deletions README.md
Expand Up @@ -5,21 +5,24 @@ WazMonkey chooses a role instance from your service at random and reboots it.

## Usage:

WazMonkey v0.1
Copyright (C) 2012 Steve Marx
Usage: WazMonkey -p foo.publishSettings -n myservice -s production
WazMonkey v0.2
Copyright (C) 2012 Steve Marx
Usage: WazMonkey -p foo.publishSettings -n myservice -s production

-p, --publishSettings .publishSettings file - specify either this or a
.pfx file
-p, --publishSettings .publishSettings file - specify either this or a
.pfx file

--pfx .pfx certificate file - specify either this or a
.publishSettings file
--pfx .pfx certificate file - specify either this or a
.publishSettings file

--subscriptionId subscriptionId to use, defaults to first
subscription found in the .publishSettings file
--subscriptionId subscriptionId to use, defaults to first
subscription found in the .publishSettings file

-n, --serviceName Required. Name of the cloud service
-n, --serviceName Required. Name of the cloud service

-s, --slot Required. The slot ("production" or "staging")
-s, --slot Required. The slot ("production" or "staging")

--help Display this help screen.
--reimage Reimage the instance (instead of reboot, the
default)

--help Display this help screen.
9 changes: 6 additions & 3 deletions WazMonkey/Program.cs
Expand Up @@ -28,12 +28,15 @@ class Options : CommandLineOptionsBase
[Option("s", "slot", Required = true, HelpText = @"The slot (""production"" or ""staging"")")]
public string Slot { get; set; }

[Option(null, "reimage", Required = false, HelpText = "Reimage the instance (instead of reboot, the default)")]
public bool Reimage { get; set; }

[HelpOption(HelpText = "Display this help screen.")]
public string GetUsage()
{
var help = new HelpText
{
Heading = new HeadingInfo("WazMonkey", "v0.1"),
Heading = new HeadingInfo("WazMonkey", "v0.2"),
Copyright = new CopyrightInfo("Steve Marx", 2012),
AdditionalNewLineAfterOption = true,
AddDashesToOption = true
Expand Down Expand Up @@ -130,10 +133,10 @@ static void Main(string[] args)

// choose one at random
var instance = instances[new Random().Next(instances.Length)];
Console.WriteLine("Rebooting {0}.", instance);
Console.WriteLine("{0} {1}.", options.Reimage ? "Reimaging" : "Rebooting", instance);

// reboot it
req = (HttpWebRequest)WebRequest.Create(string.Format("{0}/roleinstances/{1}?comp=reboot", baseAddress, instance));
req = (HttpWebRequest)WebRequest.Create(string.Format("{0}/roleinstances/{1}?comp={2}", baseAddress, instance, options.Reimage ? "reimage" : "reboot"));
req.Method = "POST";
req.ContentLength = 0;
req.Headers["x-ms-version"] = "2012-03-01";
Expand Down

0 comments on commit 2f382f1

Please sign in to comment.