Skip to content

Commit

Permalink
Merge pull request Azure#35 from AzureRT/dev
Browse files Browse the repository at this point in the history
AzureRT S42 PR #2
  • Loading branch information
ogail committed Dec 5, 2014
2 parents 723176f + d5051ca commit 7352114
Show file tree
Hide file tree
Showing 28 changed files with 103 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Common.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="3.1.0" targetFramework="net45" />
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.ScenarioTest/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="3.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.WebSites" version="4.0.1-prerelease" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="3.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="4.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="3.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void TestCleanUp()
}


[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set,Remove)-AzureVMSqlServerExtension)")]
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set,Remove)-AzureVMSqlServerExtension)")]
public void GetAzureVMSqlServerExtensionTest()
{
try
Expand Down Expand Up @@ -97,7 +97,7 @@ public void GetAzureVMSqlServerExtensionTest()
}
}

[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
public void UpdateVMWithSqlServerExtensionTest()
{
try
Expand Down Expand Up @@ -130,7 +130,7 @@ public void UpdateVMWithSqlServerExtensionTest()
}
}

[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
public void AddRoleWithSqlServerExtensionTest()
{
try
Expand Down Expand Up @@ -161,7 +161,7 @@ public void AddRoleWithSqlServerExtensionTest()
}


[TestMethod(), TestCategory(Category.Sequential), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
[TestMethod(), TestCategory("Scenario"), TestProperty("Feature", "IAAS"), Priority(0), Owner("seths"), Description("Test the cmdlet ((Get,Set)-AzureVMSqlServerExtension)")]
public void UpdateRoleWithSqlServerExtensionTest()
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ public void AzureVMImageTest()

string oldLabel = "old label";
string newLabel = "new label";
string vmSize = "Small";
var iconUri = "http://www.bing.com";
var smallIconUri = "http://www.bing.com";
bool showInGui = true;

try
{
OSImageContext result = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, oldLabel);
OSImageContext result = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, oldLabel, vmSize, iconUri, smallIconUri, showInGui);

OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ public AddAzureVMImageCmdletInfo(string imageName, string mediaLocation, OS os,
}
}

public AddAzureVMImageCmdletInfo(string imageName, string mediaLocation, OS os, string label, string recommendedSize, string iconUri, string smallIconUri, bool showInGui)
: this(imageName, mediaLocation, os, label, recommendedSize)
{
if (!string.IsNullOrEmpty(iconUri))
{
cmdletParams.Add(new CmdletParam("IconUri", iconUri));
}

if (!string.IsNullOrEmpty(iconUri))
{
cmdletParams.Add(new CmdletParam("SmallIconUri", smallIconUri));
}

if (showInGui)
{
cmdletParams.Add(new CmdletParam("ShowInGui"));
}
}

public AddAzureVMImageCmdletInfo(
string imageName,
string mediaLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,31 @@ namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests

public class ServiceManagementCmdletTestHelper
{
private T RunPSCmdletAndReturnFirst<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false, bool retryOnConflict = true)
{
var result = default(T);
if (retryOnConflict)
{
Utilities.RetryActionUntilSuccess(
() => result = RunPSCmdletAndReturnFirstHelper<T>(cmdlet),
"ConflictError", 3, 60);
}
else
{
result = RunPSCmdletAndReturnFirstHelper<T>(cmdlet);
}
return result;

}

/// <summary>
/// Run a powershell cmdlet that returns the first PSObject as a return value.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cmdlet"></param>
/// <param name="debug"></param>
/// <returns></returns>
private T RunPSCmdletAndReturnFirst<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
private T RunPSCmdletAndReturnFirstHelper<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
{
var azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(cmdlet);
Collection<PSObject> result = azurePowershellCmdlet.Run(debug);
Expand Down Expand Up @@ -91,14 +108,31 @@ private T RunPSCmdletAndReturnFirst<T>(PowershellCore.CmdletsInfo cmdlet, bool d
return default(T);
}

private Collection<T> RunPSCmdletAndReturnAll<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false, bool retryOnConflict = true)
{
var result = new Collection<T>();
if (retryOnConflict)
{
Utilities.RetryActionUntilSuccess(
() => result = RunPSCmdletAndReturnAllHelper<T>(cmdlet),
"ConflictError", 3, 60);
}
else
{
result = RunPSCmdletAndReturnAllHelper<T>(cmdlet);
}
return result;
}


/// <summary>
/// Run a powershell cmdlet that returns a collection of PSObjects as a return value.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cmdlet"></param>
/// <param name="debug"></param>
/// <returns></returns>
private Collection<T> RunPSCmdletAndReturnAll<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
private Collection<T> RunPSCmdletAndReturnAllHelper<T>(PowershellCore.CmdletsInfo cmdlet, bool debug = false)
{
var azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(cmdlet);
Collection<PSObject> result = azurePowershellCmdlet.Run(debug);
Expand Down Expand Up @@ -1314,21 +1348,19 @@ public SM.PersistentVMRoleContext ExportAzureVM(string vmName, string serviceNam
public ManagementOperationContext UpdateAzureVM(string vmName, string serviceName, SM.PersistentVM persistentVM)
{
ManagementOperationContext result = new ManagementOperationContext();
Utilities.RetryActionUntilSuccess(
() => result = RunPSCmdletAndReturnFirst<ManagementOperationContext>(new UpdateAzureVMCmdletInfo(vmName, serviceName, persistentVM)),
"409", 3, 60);
result = RunPSCmdletAndReturnFirst<ManagementOperationContext>(new UpdateAzureVMCmdletInfo(vmName, serviceName, persistentVM));
return result;
}

#endregion

#region AzureVMImage

public SM.OSImageContext AddAzureVMImage(string imageName, string mediaLocation, OS os, string label = null, string recommendedSize = null)
public SM.OSImageContext AddAzureVMImage(string imageName, string mediaLocation, OS os, string label = null, string recommendedSize = null, string iconUri = null, string smallIconUri = null, bool showInGui = false)
{
SM.OSImageContext result = new SM.OSImageContext();
Utilities.RetryActionUntilSuccess(
() => result = RunPSCmdletAndReturnFirst<SM.OSImageContext>(new AddAzureVMImageCmdletInfo(imageName, mediaLocation, os, label, recommendedSize)),
() => result = RunPSCmdletAndReturnFirst<SM.OSImageContext>(new AddAzureVMImageCmdletInfo(imageName, mediaLocation, os, label, recommendedSize, iconUri, smallIconUri, showInGui)),
"409", 3, 60);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public static void RetryActionUntilSuccess(Action act, string errorMessage, int
}
catch (Exception e)
{
if (e.ToString().Contains(errorMessage))
if (e.ToString().Contains(errorMessage) || (e.InnerException != null && e.InnerException.ToString().Contains(errorMessage)))
{
Console.WriteLine("{0} error occurs! retrying ...", errorMessage);
if (e.InnerException != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="4.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="3.1.0" targetFramework="net45" />
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public class AddAzureVMImage : ServiceManagementBaseCmdlet
[Parameter(Position = 9, ValueFromPipelineByPropertyName = true, HelpMessage = " Specifies the size to use for the virtual machine that is created from the OS image.")]
public string RecommendedVMSize { get; set; }

[Parameter(Position = 10, ValueFromPipelineByPropertyName = true, HelpMessage = "Icon Uri.")]
public Uri IconUri { get; set; }

[Parameter(Position = 11, ValueFromPipelineByPropertyName = true, HelpMessage = "Small Icon Uri.")]
public Uri SmallIconUri { get; set; }

[Parameter(Position = 12, ValueFromPipelineByPropertyName = true, HelpMessage = "To show in GUI.")]
public SwitchParameter ShowInGui { get; set; }

public void ExecuteCommand()
{
var imageType = new VirtualMachineImageHelper(this.ComputeClient).GetImageType(this.ImageName);
Expand Down Expand Up @@ -94,7 +103,10 @@ public void ExecuteCommand()
ImageFamily = this.ImageFamily,
PublishedDate = this.PublishedDate,
PrivacyUri = this.PrivacyUri,
RecommendedVMSize = this.RecommendedVMSize
RecommendedVMSize = this.RecommendedVMSize,
IconUri = this.IconUri,
SmallIconUri = this.SmallIconUri,
ShowInGui = this.ShowInGui
};

this.ExecuteClientActionNewSM(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="4.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="3.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Loading

0 comments on commit 7352114

Please sign in to comment.