Skip to content

Commit 8d9bf96

Browse files
author
unknown
committed
Add 'ResizedSizeInGB' parameter to Set-AzureOSDisk
1 parent c71801c commit 8d9bf96

File tree

7 files changed

+102
-15
lines changed

7 files changed

+102
-15
lines changed

src/Common/Commands.Common/ServiceManagementTypes.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,19 @@ public string IOType
16151615
this.SetValue("IOType", value);
16161616
}
16171617
}
1618+
1619+
[DataMember(Name = "ResizedSizeInGB", EmitDefaultValue = false, Order = 6)]
1620+
public int? ResizedSizeInGB
1621+
{
1622+
get
1623+
{
1624+
return this.GetValue<int?>("ResizedSizeInGB");
1625+
}
1626+
set
1627+
{
1628+
this.SetValue("ResizedSizeInGB", value);
1629+
}
1630+
}
16181631
}
16191632
#endregion
16201633

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ public void AzureIaaSBVT()
100100
string certData = Convert.ToBase64String(((X509Certificate2)certToUpload.BaseObject).RawData);
101101

102102
string newAzureVMName = Utilities.GetUniqueShortName(vmNamePrefix);
103-
if (string.IsNullOrEmpty(imageName))
104-
{
105-
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
106-
}
103+
104+
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false, 50);
107105

108106
RecordTimeTaken(ref prevTime);
109107

@@ -222,9 +220,13 @@ public void AzureIaaSBVT()
222220
RecordTimeTaken(ref prevTime);
223221

224222
//
225-
// New-AzureDns
223+
// Set-AzureOSDisk
226224
//
225+
vm = vmPowershellCmdlets.SetAzureOSDisk(null, vm, 100);
227226

227+
//
228+
// New-AzureDns
229+
//
228230
string dnsName = "OpenDns1";
229231
string ipAddress = "208.67.222.222";
230232

@@ -348,7 +350,6 @@ public void AzureIaaSBVT()
348350
//
349351
vm = vmPowershellCmdlets.SetAzureOSDisk(HostCaching.ReadOnly, vm);
350352

351-
352353
//
353354
// Update-AzureVM
354355
//

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests
2020
{
2121
public class SetAzureOSDiskCmdletInfo : CmdletsInfo
2222
{
23-
public SetAzureOSDiskCmdletInfo(HostCaching hs, PersistentVM vm)
23+
public SetAzureOSDiskCmdletInfo(HostCaching? hs, PersistentVM vm, int? resizedSize)
2424
{
2525
cmdletName = Utilities.SetAzureOSDiskCmdletName;
26-
this.cmdletParams.Add(new CmdletParam("HostCaching", hs.ToString()));
26+
27+
if (hs != null)
28+
{
29+
this.cmdletParams.Add(new CmdletParam("HostCaching", hs.ToString()));
30+
}
2731
this.cmdletParams.Add(new CmdletParam("VM", vm));
32+
if (resizedSize != null)
33+
{
34+
this.cmdletParams.Add(new CmdletParam("ResizedSizeInGB", resizedSize));
35+
}
2836
}
2937
}
3038
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,9 @@ public void RemoveEndPoint(string vmName, string serviceName, string [] epNames)
670670

671671
#region AzureOSDisk
672672

673-
public SM.PersistentVM SetAzureOSDisk(HostCaching hc, SM.PersistentVM vm)
673+
public SM.PersistentVM SetAzureOSDisk(HostCaching? hc, SM.PersistentVM vm, int? resizedSize = null)
674674
{
675-
return RunPSCmdletAndReturnFirst<SM.PersistentVM>(new SetAzureOSDiskCmdletInfo(hc, vm));
675+
return RunPSCmdletAndReturnFirst<SM.PersistentVM>(new SetAzureOSDiskCmdletInfo(hc, vm, resizedSize));
676676
}
677677

678678
public SM.OSVirtualHardDisk GetAzureOSDisk(SM.PersistentVM vm)
@@ -1463,17 +1463,19 @@ public void SaveAzureVMImage(string serviceName, string vmName, string newImageN
14631463
return vmImages;
14641464
}
14651465

1466-
public string GetAzureVMImageName(string[] keywords, bool exactMatch = true)
1466+
public string GetAzureVMImageName(string[] keywords, bool exactMatch = true, int? diskSize = null)
14671467
{
14681468
Collection<SM.OSImageContext> vmImages = GetAzureVMImage();
14691469
foreach (SM.OSImageContext image in vmImages)
14701470
{
1471-
if (Utilities.MatchKeywords(image.ImageName, keywords, exactMatch) >= 0)
1471+
if (Utilities.MatchKeywords(image.ImageName, keywords, exactMatch) >= 0 &&
1472+
((diskSize == null) || (image.LogicalSizeInGB <= diskSize)))
14721473
return image.ImageName;
14731474
}
14741475
foreach (SM.OSImageContext image in vmImages)
14751476
{
1476-
if (Utilities.MatchKeywords(image.OS, keywords, exactMatch) >= 0)
1477+
if (Utilities.MatchKeywords(image.OS, keywords, exactMatch) >= 0 &&
1478+
((diskSize == null) || (image.LogicalSizeInGB <= diskSize)))
14771479
return image.ImageName;
14781480
}
14791481
return null;

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/DiskRepository/UpdateAzureDisk.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ public class UpdateAzureDiskCommand : ServiceManagementBaseCmdlet
3737
[ValidateNotNullOrEmpty]
3838
public string Label { get; set; }
3939

40-
[Parameter(Position = 2, ParameterSetName = ResizeParameterSetName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Label of the disk.")]
40+
[Parameter(Position = 2,
41+
ParameterSetName = ResizeParameterSetName,
42+
Mandatory = true,
43+
ValueFromPipelineByPropertyName = true,
44+
HelpMessage = "Resizes the underlying blob to the indicated size in GB.")]
4145
[ValidateNotNullOrEmpty]
4246
public int ResizedSizeInGB { get; set; }
4347

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Disks/SetAzureOSDisk.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,30 @@ namespace Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS
2323
[Cmdlet(VerbsCommon.Set, "AzureOSDisk"), OutputType(typeof(IPersistentVM))]
2424
public class SetAzureOSDiskCommand : VirtualMachineConfigurationCmdletBase
2525
{
26-
[Parameter(Position = 0, Mandatory = true, HelpMessage = "Controls the platform caching behavior of data disk blob for read / write efficiency.")]
26+
private const string ResizeParameterSet = "Resize";
27+
private const string NoResizeParameteSet = "NoResize";
28+
29+
[Parameter(Position = 0, ParameterSetName = NoResizeParameteSet, Mandatory = true, HelpMessage = "Controls the platform caching behavior of data disk blob for read / write efficiency.")]
30+
[Parameter(Position = 0, ParameterSetName = ResizeParameterSet, Mandatory = false, HelpMessage = "Controls the platform caching behavior of data disk blob for read / write efficiency.")]
2731
[ValidateSet("ReadOnly", "ReadWrite", IgnoreCase = true)]
2832
public string HostCaching
2933
{
3034
get;
3135
set;
3236
}
3337

38+
[Parameter(Position = 1,
39+
ParameterSetName = ResizeParameterSet,
40+
Mandatory = true,
41+
ValueFromPipelineByPropertyName = false,
42+
HelpMessage = "Resize the new OS Disk to a larger size.")]
43+
[ValidateNotNullOrEmpty]
44+
public int ResizedSizeInGB
45+
{
46+
get;
47+
set;
48+
}
49+
3450
internal void ExecuteCommand()
3551
{
3652
var role = VM.GetInstance();
@@ -47,6 +63,11 @@ internal void ExecuteCommand()
4763

4864
OSVirtualHardDisk disk = role.OSVirtualHardDisk;
4965
disk.HostCaching = HostCaching;
66+
if (this.ParameterSetName.Equals(ResizeParameterSet))
67+
{
68+
disk.ResizedSizeInGB = this.ResizedSizeInGB;
69+
}
70+
5071
WriteObject(VM, true);
5172
}
5273

src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24225,6 +24225,13 @@ C:\PS&gt; Get-AzureVM -ServiceName &quot;MyService&quot; -Name &quot;MyVM&quot;
2422524225
</maml:description>
2422624226
<command:parameterValue required="true" variableLength="false">IPersistentVM</command:parameterValue>
2422724227
</command:parameter>
24228+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1">
24229+
<maml:name>ResizedSizeInGB</maml:name>
24230+
<maml:description>
24231+
<maml:para>Resize the new OSVirtualHardDisk to a larger size. ResizedSizeInGB must be larger than the underlying OS Image's LogicalSizeInGB. </maml:para>
24232+
</maml:description>
24233+
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
24234+
</command:parameter>
2422824235
</command:syntaxItem>
2422924236
</command:syntax>
2423024237
<command:parameters>
@@ -24252,6 +24259,18 @@ C:\PS&gt; Get-AzureVM -ServiceName &quot;MyService&quot; -Name &quot;MyVM&quot;
2425224259
</dev:type>
2425324260
<dev:defaultValue></dev:defaultValue>
2425424261
</command:parameter>
24262+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1">
24263+
<maml:name>ResizedSizeInGB</maml:name>
24264+
<maml:description>
24265+
<maml:para>Resize the new OSVirtualHardDisk to a larger size. ResizedSizeInGB must be larger than the underlying OS Image's LogicalSizeInGB. </maml:para>
24266+
</maml:description>
24267+
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
24268+
<dev:type>
24269+
<maml:name>int</maml:name>
24270+
<maml:uri/>
24271+
</dev:type>
24272+
<dev:defaultValue></dev:defaultValue>
24273+
</command:parameter>
2425524274
</command:parameters>
2425624275
<command:inputTypes>
2425724276
<command:inputType>
@@ -31812,6 +31831,13 @@ PS C:\&gt; Get-AzureVM -ServiceName &quot;ContosoService03&quot; -Name &quot;Con
3181231831
</maml:description>
3181331832
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
3181431833
</command:parameter>
31834+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
31835+
<maml:name>ResizedSizeInGB</maml:name>
31836+
<maml:description>
31837+
<maml:para></maml:para>
31838+
</maml:description>
31839+
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
31840+
</command:parameter>
3181531841
</command:syntaxItem>
3181631842
</command:syntax>
3181731843
<command:parameters>
@@ -31839,6 +31865,18 @@ PS C:\&gt; Get-AzureVM -ServiceName &quot;ContosoService03&quot; -Name &quot;Con
3183931865
</dev:type>
3184031866
<dev:defaultValue></dev:defaultValue>
3184131867
</command:parameter>
31868+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
31869+
<maml:name>ResizedSizeInGB</maml:name>
31870+
<maml:description>
31871+
<maml:para>Resizes the underlying blob to the indicated size in GB.</maml:para>
31872+
</maml:description>
31873+
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
31874+
<dev:type>
31875+
<maml:name>int</maml:name>
31876+
<maml:uri/>
31877+
</dev:type>
31878+
<dev:defaultValue></dev:defaultValue>
31879+
</command:parameter>
3184231880
</command:parameters>
3184331881
<command:inputTypes>
3184431882
<command:inputType>

0 commit comments

Comments
 (0)