Skip to content

Commit

Permalink
Merge pull request #11033 from hyonholee/february
Browse files Browse the repository at this point in the history
[Compute] Allow empty value for ProximityPlacementGroupId during update
  • Loading branch information
VeryEarly authored Feb 6, 2020
2 parents 68a75f2 + 3e9e95b commit 821b03f
Show file tree
Hide file tree
Showing 16 changed files with 4,190 additions and 3,243 deletions.
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.1.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.18.0-preview" />
</ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,21 @@ function Test-DedicatedHostVirtualMachine
Assert-AreEqual 1 $dedicatedHostGroup.Hosts.Count;
Assert-AreEqual $dedicatedHostId $dedicatedHostGroup.Hosts[0].Id;

# Remove Host from VM
Stop-AzVM -ResourceGroupName $rgname -Name $vmName1 -Force;
$vm1.Host.Id = $null;
Update-AzVM -ResourceGroupName $rgname -VM $vm1;

$vm1 = Get-AzVM -ResourceGroupName $rgname -Name $vmname1;
Assert-Null $vm1.Host;
$dedicatedHost = Get-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName;
Assert-AreEqual 1 $dedicatedHost.VirtualMachines.Count;
Assert-AreEqual $vm0.Id $dedicatedHost.VirtualMachines[0].Id;

$dedicatedHostGroup = Get-AzHostGroup -ResourceGroupName $rgname -HostGroupName $hostGroupNam;
Assert-AreEqual 1 $dedicatedHostGroup.Hosts.Count;
Assert-AreEqual $dedicatedHostId $dedicatedHostGroup.Hosts[0].Id;

Remove-AzVM -ResourceGroupName $rgname -Name $vmname1 -Force;

$dedicatedHost = Get-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName;
Expand Down
12 changes: 12 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/PPGTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ function Test-ProximityPlacementGroupVM
Assert-AreEqual $vm.Id $ppgStatus2.VirtualMachines[0].Id;
Check-ColocationStatusUnknown $ppgStatus2.ColocationStatus;

Update-AzVM -ResourceGroupName $rgname -VM $vm -ProximityPlacementGroupId "";
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmName;
Assert-Null $vm.ProximityPlacementGroup.Id;

$ppg2 = Get-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname2;
Assert-AreEqual 0 $ppg2.VirtualMachines.Count;
Assert-Null $ppg2.ColocationStatus;

$ppgStatus2 =Get-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname2 -ColocationStatus;
Assert-AreEqual 0 $ppgStatus2.VirtualMachines.Count;
Check-ColocationStatus $ppgStatus2.ColocationStatus;

Remove-AzVM -ResourceGroupName $rgname -Name $vmName -Force;
$ppg = Get-AzProximityPlacementGroup -ResourceGroupName $rgname -Name $ppgname;
Assert-Null $ppg.VirtualMachines;
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class UpdateAzureAvailabilitySetCommand : AvailabilitySetBaseCmdlet

[Parameter(
Mandatory = false)]
[ValidateNotNullOrEmpty]
[AllowEmptyString]
public string ProximityPlacementGroupId { get; set; }

[Parameter(
Expand Down Expand Up @@ -79,6 +79,11 @@ public override void ExecuteCmdlet()
: this.AvailabilitySet.ProximityPlacementGroup
};

if (avSetParams.ProximityPlacementGroup != null && string.IsNullOrEmpty(avSetParams.ProximityPlacementGroup.Id))
{
avSetParams.ProximityPlacementGroup.Id = null;
}

var result = this.AvailabilitySetClient.CreateOrUpdateWithHttpMessagesAsync(
this.AvailabilitySet.ResourceGroupName,
this.AvailabilitySet.Name,
Expand Down
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Allow empty value for ProximityPlacementGroupId during update

## Version 3.4.0
* Limit the number of VM status to 100 to avoid throttling when Get-AzVM -Status is performed without VM name.
Expand Down
2 changes: 1 addition & 1 deletion src/Compute/Compute/Compute.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.2.2" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.1.0" />
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public override void ExecuteCmdlet()

[Parameter(
Mandatory = false)]
[ValidateNotNullOrEmpty]
[AllowEmptyString]
public string ProximityPlacementGroupId { get; set; }

[Parameter(
Expand Down Expand Up @@ -1096,6 +1096,13 @@ private void BuildPatchObject()
this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.StorageProfile.OsDisk.VhdContainers = this.VhdContainer;
}

if (this.VirtualMachineScaleSetUpdate != null
&& this.VirtualMachineScaleSetUpdate.ProximityPlacementGroup != null
&& string.IsNullOrEmpty(this.VirtualMachineScaleSetUpdate.ProximityPlacementGroup.Id))
{
this.VirtualMachineScaleSetUpdate.ProximityPlacementGroup.Id = null;
}

if (this.VirtualMachineScaleSetUpdate != null
&& this.VirtualMachineScaleSetUpdate.VirtualMachineProfile != null
&& this.VirtualMachineScaleSetUpdate.VirtualMachineProfile.OsProfile != null
Expand Down Expand Up @@ -1699,6 +1706,13 @@ private void BuildPutObject()
this.VirtualMachineScaleSet.VirtualMachineProfile.StorageProfile.OsDisk.VhdContainers = this.VhdContainer;
}

if (this.VirtualMachineScaleSet != null
&& this.VirtualMachineScaleSet.ProximityPlacementGroup != null
&& string.IsNullOrEmpty(this.VirtualMachineScaleSet.ProximityPlacementGroup.Id))
{
this.VirtualMachineScaleSet.ProximityPlacementGroup.Id = null;
}

if (this.VirtualMachineScaleSet != null
&& this.VirtualMachineScaleSet.VirtualMachineProfile != null
&& this.VirtualMachineScaleSet.VirtualMachineProfile.OsProfile != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class UpdateAzureVMCommand : VirtualMachineBaseCmdlet

[Parameter(
Mandatory = false)]
[ValidateNotNullOrEmpty]
[AllowEmptyString]
public string ProximityPlacementGroupId { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
Expand Down Expand Up @@ -158,6 +158,16 @@ public override void ExecuteCmdlet()
Priority = this.VM.Priority
};

if (parameters.Host != null && string.IsNullOrWhiteSpace(parameters.Host.Id))
{
parameters.Host.Id = null;
}

if (parameters.ProximityPlacementGroup != null && string.IsNullOrWhiteSpace(parameters.ProximityPlacementGroup.Id))
{
parameters.ProximityPlacementGroup.Id = null;
}

if (this.IsParameterBound(c => c.IdentityType))
{
parameters.Identity = new VirtualMachineIdentity(null, null, this.IdentityType, null);
Expand Down
4 changes: 2 additions & 2 deletions src/Compute/Compute/help/New-AzDiskEncryptionSet.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ schema: 2.0.0
# New-AzDiskEncryptionSet

## SYNOPSIS
Creates a disk encryption key.
Creates a disk encryption set.

## SYNTAX

Expand All @@ -18,7 +18,7 @@ New-AzDiskEncryptionSet [-ResourceGroupName] <String> [-Name] <String> [-InputOb
```

## DESCRIPTION
Creates a disk encryption key.
Creates a disk encryption set.

## EXAMPLES

Expand Down
4 changes: 2 additions & 2 deletions src/Compute/Compute/help/Update-AzDiskEncryptionSet.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ schema: 2.0.0
# Update-AzDiskEncryptionSet

## SYNOPSIS
Updates a disk encryption key.
Updates a disk encryption set.

## SYNTAX

Expand All @@ -34,7 +34,7 @@ Update-AzDiskEncryptionSet [-InputObject] <PSDiskEncryptionSet> [-KeyUrl <String
```

## DESCRIPTION
Updates a disk encryption key.
Updates a disk encryption set.

## EXAMPLES

Expand Down
2 changes: 1 addition & 1 deletion src/Network/Network.Test/Network.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.18.0-preview" />
<PackageReference Include="Microsoft.Azure.Insights" Version="0.16.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.1.0" />
<PackageReference Include="Microsoft.Azure.Management.ContainerInstance" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Redis" Version="4.4.1" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.19.0-preview" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.18.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.2.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.0.1-preview" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.18.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.2.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="31.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.18.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="13.1.0" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.0.0-preview" />
Expand Down

0 comments on commit 821b03f

Please sign in to comment.