Skip to content

Commit 64a9488

Browse files
committed
Merge pull request #9 from huangpf/dev
AzureRT PR S45 #1 - Add-AzureVMImage
2 parents 76e6148 + e29d0ae commit 64a9488

35 files changed

+416
-98
lines changed

src/Common/Commands.Common.Test/Commands.Common.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
106106
</Reference>
107107
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
108-
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.8.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
108+
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
109109
</Reference>
110110
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
111111
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>

src/Common/Commands.Common.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1717
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
1818
<package id="Microsoft.WindowsAzure.Management" version="4.0.0" targetFramework="net45" />
19-
<package id="Microsoft.WindowsAzure.Management.Compute" version="8.0.0" targetFramework="net45" />
19+
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.0.0" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
2121
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
2222
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />

src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
102102
</Reference>
103103
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
104-
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.8.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
104+
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
105105
</Reference>
106106
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
107107
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>

src/Common/Commands.ScenarioTest/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1818
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
1919
<package id="Microsoft.WindowsAzure.Management" version="4.0.0" targetFramework="net45" />
20-
<package id="Microsoft.WindowsAzure.Management.Compute" version="8.0.0" targetFramework="net45" />
20+
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.0.0" targetFramework="net45" />
2121
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
2222
<package id="Microsoft.WindowsAzure.Management.WebSites" version="4.4.0-prerelease" targetFramework="net45" />
2323
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />

src/ServiceManagement/Compute/Commands.ServiceManagement.PlatformImageRepository/Commands.ServiceManagement.PlatformImageRepository.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@
111111
<SpecificVersion>False</SpecificVersion>
112112
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
113113
</Reference>
114-
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115-
<SpecificVersion>False</SpecificVersion>
116-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.8.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
114+
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
115+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
117116
</Reference>
118117
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
119118
<SpecificVersion>False</SpecificVersion>

src/ServiceManagement/Compute/Commands.ServiceManagement.PlatformImageRepository/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1717
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
1818
<package id="Microsoft.WindowsAzure.Management" version="4.0.0" targetFramework="net45" />
19-
<package id="Microsoft.WindowsAzure.Management.Compute" version="8.0.0" targetFramework="net45" />
19+
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.0.0" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
2121
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
2222
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Commands.ServiceManagement.Preview.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@
111111
<SpecificVersion>False</SpecificVersion>
112112
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
113113
</Reference>
114-
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115-
<SpecificVersion>False</SpecificVersion>
116-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.8.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
114+
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
115+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
117116
</Reference>
118117
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
119118
<SpecificVersion>False</SpecificVersion>

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1717
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
1818
<package id="Microsoft.WindowsAzure.Management" version="4.0.0" targetFramework="net45" />
19-
<package id="Microsoft.WindowsAzure.Management.Compute" version="8.0.0" targetFramework="net45" />
19+
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.0.0" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.Management.Network" version="6.0.0" targetFramework="net45" />
2121
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
2222
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/Commands.ServiceManagement.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
106106
</Reference>
107107
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
108-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.8.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
108+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
109109
</Reference>
110110
<Reference Include="Microsoft.WindowsAzure.Management.Network">
111111
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/CredentialHelper.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public static string DefaultStorageName
239239
}
240240
}
241241

242-
public static void CopyTestData(string srcContainer, string srcBlob, string destContainer, string destBlob)
242+
public static void CopyTestData(string srcContainer, string srcBlob, string destContainer, string destBlob = null)
243243
{
244244
ServiceManagementCmdletTestHelper vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();
245245
Process currentProcess = Process.GetCurrentProcess();
@@ -262,7 +262,15 @@ public static void CopyTestData(string srcContainer, string srcBlob, string dest
262262
// Make SAS Uri for the source blob.
263263
string srcSasUri = Utilities.GenerateSasUri(CredentialHelper.CredentialBlobUriFormat, storageAccount, storageAccountKey, srcContainer, srcBlob);
264264

265-
vmPowershellCmdlets.RunPSScript(string.Format("Start-AzureStorageBlobCopy -SrcUri \"{0}\" -DestContainer {1} -DestBlob {2} -Force", srcSasUri, destContainer, destBlob));
265+
if (string.IsNullOrEmpty(destBlob))
266+
{
267+
vmPowershellCmdlets.RunPSScript(string.Format("Start-AzureStorageBlobCopy -SrcContainer {0} -SrcBlob {1} -DestContainer {2} -Force", srcContainer, srcBlob, destContainer));
268+
destBlob = srcBlob;
269+
}
270+
else
271+
{
272+
vmPowershellCmdlets.RunPSScript(string.Format("Start-AzureStorageBlobCopy -SrcUri \"{0}\" -DestContainer {1} -DestBlob {2} -Force", srcSasUri, destContainer, destBlob));
273+
}
266274

267275
for (int i = 0; i < 60; i++)
268276
{

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/FunctionalTestCommonVhd.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public void AzureVMImageTest()
155155

156156
try
157157
{
158+
// BVT Tests for OS Images
158159
OSImageContext result = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, oldLabel, vmSize, iconUri, smallIconUri, showInGui);
159160

160161
OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
@@ -174,6 +175,97 @@ public void AzureVMImageTest()
174175
vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
175176
Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName));
176177

178+
// BVT Tests for VM Images
179+
// Unique Container Prefix
180+
var containerPrefix = Utilities.GetUniqueShortName("vmimg");
181+
182+
// Disk Blobs
183+
var srcVhdName = "os1.vhd";
184+
var srcVhdContainer = vhdContainerName;
185+
var dstOSVhdContainer = containerPrefix.ToLower() + "os" + vhdContainerName;
186+
CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstOSVhdContainer);
187+
string osVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstOSVhdContainer, srcVhdName);
188+
189+
var dstDataVhdContainer = containerPrefix.ToLower() + "data" + vhdContainerName;
190+
CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstDataVhdContainer);
191+
string dataVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstDataVhdContainer, srcVhdName);
192+
193+
// VM Image OS/Data Disk Configuration
194+
var addVMImageName = containerPrefix + "Image";
195+
var diskConfig = new VirtualMachineImageDiskConfigSet
196+
{
197+
OSDiskConfiguration = new OSDiskConfiguration
198+
{
199+
HostCaching = HostCaching.ReadWrite.ToString(),
200+
OS = OSType.Windows.ToString(),
201+
OSState = "Generalized",
202+
MediaLink = new Uri(osVhdLink)
203+
},
204+
DataDiskConfigurations = new DataDiskConfigurationList
205+
{
206+
new DataDiskConfiguration
207+
{
208+
HostCaching = HostCaching.ReadOnly.ToString(),
209+
Lun = 0,
210+
MediaLink = new Uri(dataVhdLink)
211+
}
212+
}
213+
};
214+
215+
// Add-AzureVMImage
216+
string label = addVMImageName;
217+
string description = "test";
218+
string eula = "http://www.bing.com/";
219+
string imageFamily = "Windows";
220+
DateTime? publishedDate = new DateTime(2015, 1, 1);
221+
string privacyUri = "http://www.bing.com/";
222+
string recommendedVMSize = vmSize;
223+
string iconName = "iconName";
224+
string smallIconName = "smallIconName";
225+
226+
vmPowershellCmdlets.AddAzureVMImage(
227+
addVMImageName,
228+
label,
229+
diskConfig,
230+
description,
231+
eula,
232+
imageFamily,
233+
publishedDate,
234+
privacyUri,
235+
recommendedVMSize,
236+
iconName,
237+
smallIconName,
238+
showInGui);
239+
240+
// Get-AzureVMImage
241+
var vmImage = vmPowershellCmdlets.GetAzureVMImageReturningVMImages(addVMImageName).First();
242+
243+
Assert.IsTrue(vmImage.ImageName == addVMImageName);
244+
Assert.IsTrue(vmImage.Label == label);
245+
Assert.IsTrue(vmImage.Description == description);
246+
Assert.IsTrue(vmImage.Eula == eula);
247+
Assert.IsTrue(vmImage.ImageFamily == imageFamily);
248+
Assert.IsTrue(vmImage.PublishedDate.Value.Year == publishedDate.Value.Year);
249+
Assert.IsTrue(vmImage.PublishedDate.Value.Month == publishedDate.Value.Month);
250+
Assert.IsTrue(vmImage.PublishedDate.Value.Day == publishedDate.Value.Day);
251+
Assert.IsTrue(vmImage.PrivacyUri.AbsoluteUri.ToString() == privacyUri);
252+
Assert.IsTrue(vmImage.RecommendedVMSize == recommendedVMSize);
253+
Assert.IsTrue(vmImage.IconName == iconName);
254+
Assert.IsTrue(vmImage.IconUri == iconName);
255+
Assert.IsTrue(vmImage.SmallIconName == smallIconName);
256+
Assert.IsTrue(vmImage.SmallIconUri == smallIconName);
257+
Assert.IsTrue(vmImage.ShowInGui == showInGui);
258+
Assert.IsTrue(vmImage.OSDiskConfiguration.HostCaching == diskConfig.OSDiskConfiguration.HostCaching);
259+
Assert.IsTrue(vmImage.OSDiskConfiguration.OS == diskConfig.OSDiskConfiguration.OS);
260+
Assert.IsTrue(vmImage.OSDiskConfiguration.OSState == diskConfig.OSDiskConfiguration.OSState);
261+
Assert.IsTrue(vmImage.OSDiskConfiguration.MediaLink == diskConfig.OSDiskConfiguration.MediaLink);
262+
Assert.IsTrue(vmImage.DataDiskConfigurations.First().HostCaching == diskConfig.DataDiskConfigurations.First().HostCaching);
263+
Assert.IsTrue(vmImage.DataDiskConfigurations.First().Lun == diskConfig.DataDiskConfigurations.First().Lun);
264+
Assert.IsTrue(vmImage.DataDiskConfigurations.First().MediaLink == diskConfig.DataDiskConfigurations.First().MediaLink);
265+
266+
// Remove-AzureVMImage
267+
vmPowershellCmdlets.RemoveAzureVMImage(addVMImageName);
268+
177269
pass = true;
178270
}
179271
catch (Exception e)

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/IaasCmdletInfo/AddAzureVMImageCmdletInfo.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System;
1616
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo;
1717
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
18+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
1819

1920
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo
2021
{
@@ -96,5 +97,76 @@ public AddAzureVMImageCmdletInfo(
9697
cmdletParams.Add(new CmdletParam("PublishedDate", publishedDate.ToString()));
9798
}
9899
}
100+
101+
public AddAzureVMImageCmdletInfo(
102+
string imageName,
103+
string label,
104+
VirtualMachineImageDiskConfigSet diskConfig,
105+
string description,
106+
string eula,
107+
string imageFamily,
108+
DateTime? publishedDate,
109+
string privacyUri,
110+
string recommendedVMSize,
111+
string iconName,
112+
string smallIconName,
113+
bool? showInGui)
114+
{
115+
cmdletName = Utilities.AddAzureVMImageCmdletName;
116+
117+
cmdletParams.Add(new CmdletParam("ImageName", imageName));
118+
119+
cmdletParams.Add(new CmdletParam("Label", label));
120+
121+
if (diskConfig != null)
122+
{
123+
cmdletParams.Add(new CmdletParam("DiskConfig", diskConfig));
124+
}
125+
126+
if (!string.IsNullOrEmpty(description))
127+
{
128+
cmdletParams.Add(new CmdletParam("Description", description));
129+
}
130+
131+
if (!string.IsNullOrEmpty(eula))
132+
{
133+
cmdletParams.Add(new CmdletParam("Eula", eula));
134+
}
135+
136+
if (!string.IsNullOrEmpty(imageFamily))
137+
{
138+
cmdletParams.Add(new CmdletParam("ImageFamily", imageFamily));
139+
}
140+
141+
if (publishedDate != null)
142+
{
143+
cmdletParams.Add(new CmdletParam("PublishedDate", publishedDate));
144+
}
145+
146+
if (!string.IsNullOrEmpty(privacyUri))
147+
{
148+
cmdletParams.Add(new CmdletParam("PrivacyUri", privacyUri));
149+
}
150+
151+
if (!string.IsNullOrEmpty(recommendedVMSize))
152+
{
153+
cmdletParams.Add(new CmdletParam("RecommendedVMSize", recommendedVMSize));
154+
}
155+
156+
if (!string.IsNullOrEmpty(iconName))
157+
{
158+
cmdletParams.Add(new CmdletParam("IconName", iconName));
159+
}
160+
161+
if (!string.IsNullOrEmpty(smallIconName))
162+
{
163+
cmdletParams.Add(new CmdletParam("SmallIconName", smallIconName));
164+
}
165+
166+
if (showInGui != null)
167+
{
168+
cmdletParams.Add(new CmdletParam("ShowInGui", showInGui));
169+
}
170+
}
99171
}
100172
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/IaasCmdletInfo/UpdateAzureVMImageCmdletInfo.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public UpdateAzureVMImageCmdletInfo(
5252
Uri privacyUri,
5353
DateTime publishedDate,
5454
string language,
55-
Uri iconUri,
56-
Uri smallIconUri,
55+
string iconName,
56+
string smallIconName,
5757
bool showInGui)
5858
: this(imageName, label, recommendedSize, null, !showInGui)
5959
{
@@ -81,13 +81,13 @@ public UpdateAzureVMImageCmdletInfo(
8181
{
8282
cmdletParams.Add(new CmdletParam("Language", language));
8383
}
84-
if (iconUri != null)
84+
if (!string.IsNullOrEmpty(iconName))
8585
{
86-
cmdletParams.Add(new CmdletParam("IconUri", iconUri));
86+
cmdletParams.Add(new CmdletParam("IconName", iconName));
8787
}
88-
if (smallIconUri != null)
88+
if (!string.IsNullOrEmpty(smallIconName))
8989
{
90-
cmdletParams.Add(new CmdletParam("SmallIconUri", smallIconUri));
90+
cmdletParams.Add(new CmdletParam("SmallIconName", smallIconName));
9191
}
9292
}
9393
}

0 commit comments

Comments
 (0)