Skip to content

Commit

Permalink
Adding patchStatus property to VM Instance View (#12777)
Browse files Browse the repository at this point in the history
* updated .net to 38.1 and added patchstatus property

* Adding tests and upgrading sdk version for dependent projects

* Update PSVirtualMachineInstanceView.cs

Adding comma
  • Loading branch information
haagha authored Sep 3, 2020
1 parent 8639a13 commit 17cd174
Show file tree
Hide file tree
Showing 6 changed files with 5,150 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@ public void TestInvokeAzVmPatchAssessment()
{
TestRunner.RunTestScript("Test-InvokeAzVmPatchAssessment");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestPatchStatusGetAzVMinstanceview()
{
TestRunner.RunTestScript("Test-PatchStatusGetAzVMinstanceview");
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,47 @@ function Test-InvokeAzVmPatchAssessment
# Cleanup
Clean-ResourceGroup $rgname
}
}


<#
.SYNOPSIS
Test PatchStatus in Get-Azvm instance view
#>
function Test-PatchStatusGetAzVMinstanceview
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = Get-ComputeVMLocation;
$loc = $loc.Replace(' ', '');

New-AzResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmsize = Get-AvailableSku $loc "virtualMachine"
$vmname = 'vm' + $rgname;

$username = "admin01"
$password = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
[string]$domainNameLabel = "$vmname-$vmname".tolower();

$x = New-AzVM -ResourceGroupName $rgname -Name $vmname -Location $loc -Credential $cred -DomainNameLabel $domainNameLabel
$patchResult = invoke-azvmpatchAssessment -resourcegroupname $rgname -vmname $vmname

$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname -Status;

Assert-NotNull $vm.PatchStatus;
Assert-NotNull $vm.PatchStatus.availablePatchSummary;
Assert-AreEqual "Succeeded" $vm.PatchStatus.availablePatchSummary.status;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

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
* Added 'PatchStatus'Property to VirtualMachine Instance View
* Added ``VMHealth`` property to the virtual machine's instance view, which is the returned object when ``Get-AzVm`` is invoked with ``-Status``
* Added 'AssignedHost' field to Get-AzVM and Get-AzVmss's instance views. The field shows the resource id of the virtual machine instance
* Added `SupportAutomaticPlacement` to New-AzHostGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public partial class PSVirtualMachineInstanceView
public IList<VirtualMachineExtensionInstanceView> Extensions { get; set; }
public BootDiagnosticsInstanceView BootDiagnostics { get; set; }
public IList<InstanceViewStatus> Statuses { get; set; }
public VirtualMachinePatchStatus PatchStatus { get; set; }
public VirtualMachineHealthStatus VmHealth { get; set; }

}
Expand Down
2 changes: 2 additions & 0 deletions src/Compute/Compute/Models/PSVirtualMachineInstanceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class PSVirtualMachineInstanceView
public IList<InstanceViewStatus> Statuses { get; set; }

public MaintenanceRedeployStatus MaintenanceRedeployStatus { get; set; }
public VirtualMachinePatchStatus PatchStatus { get; set; }
public VirtualMachineHealthStatus VMHealth { get; set; }
}

Expand Down Expand Up @@ -72,6 +73,7 @@ public static PSVirtualMachineInstanceView ToPSVirtualMachineInstanceView(
OsName = virtualMachineInstanceView.OsName,
OsVersion = virtualMachineInstanceView.OsVersion,
HyperVGeneration = virtualMachineInstanceView.HyperVGeneration,
PatchStatus = virtualMachineInstanceView.PatchStatus,
VMHealth = virtualMachineInstanceView.VmHealth,
AssignedHost = virtualMachineInstanceView.AssignedHost
};
Expand Down

0 comments on commit 17cd174

Please sign in to comment.