Skip to content

[AzureRT] October update #3141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ResourceManager/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@
* Overview of change #1
- Additional information about change #1
-->
## Current Release
## Current Release

* Update formats for list of VMs, VMScaleSets and ContainerService
- The default format of Get-AzureRmVM, Get-AzureRmVmss and Get-AzureRmContainerService is not table format when these cmdlets call List Operation
* Fix overprovision issue for VMScaleSet
- Because of the bug in Compute client library (and Swagger spec) regarding overprovision property of VMScaleSet, this property did not show up correctly.
* Better piping scenario for VMScaleSets and ContainerService cmdlets
- VMScaleSet and ContainerService now have "ResourceGroupName" property, so when piping Get command to Delete/Update command, -ResourceGroupName is not required.
* Separate paremater sets for Set-AzureRmVM with Generalized and Redeploy parameter
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.13.0.4-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.13.1.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=7.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -448,6 +448,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineDataDiskNegative.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineGetStatus.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineImageList.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function Test-ContainerService
$loc = 'australiasoutheast';
New-AzureRMResourceGroup -Name $rgname -Location $loc -Force;


$csName = 'cs' + $rgname;
$masterDnsPrefixName = 'master' + $rgname;
$agentPoolDnsPrefixName = 'ap' + $rgname;
Expand Down Expand Up @@ -63,10 +62,13 @@ function Test-ContainerService
| Add-AzureRmContainerServiceAgentPoolProfile -Name $agentPoolProfileName -VmSize $vmSize -DnsPrefix $agentPoolDnsPrefixName `
| New-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;


$cs = Get-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
$output = $cs | Out-String;
Assert-True { $output.Contains("AgentPoolProfiles") };

$cslist = Get-AzureRmContainerService -ResourceGroupName $rgname;
$output = $cslist | Out-String;
Assert-False { $output.Contains("AgentPoolProfiles") };

$st = Remove-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
}
Expand All @@ -92,7 +94,6 @@ function Test-ContainerServiceUpdate
$loc = 'australiasoutheast';
New-AzureRMResourceGroup -Name $rgname -Location $loc -Force;


$csName = 'cs' + $rgname;
$masterDnsPrefixName = 'master' + $rgname;
$agentPoolDnsPrefixName = 'ap' + $rgname;
Expand Down Expand Up @@ -141,10 +142,9 @@ function Test-ContainerServiceUpdate
-VmSize $vmSize `
-DnsPrefix $agentPoolDnsPrefixName `
-Count 2 `
| Update-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
| Update-AzureRmContainerService;

$cs = Get-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
$st = Remove-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
$st = Get-AzureRmContainerService -ResourceGroupName $rgname -Name $csName | Remove-AzureRmContainerService;
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function Test-VirtualMachineScaleSet

Write-Verbose ('Running Command : ' + 'Get-AzureRmVmss');
$vmssResult = Get-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
Assert-AreEqual $vmssName $vmssResult.Name;
Assert-True { $vmssName -eq $vmssResult.Name };
$output = $vmssResult | Out-String;
Write-Verbose ($output);
Expand All @@ -142,18 +143,15 @@ function Test-VirtualMachineScaleSet
Assert-True { ($vmssList | select -ExpandProperty Name) -contains $vmssName };
$output = $vmssList | Out-String;
Write-Verbose ($output);
Assert-True { $output.Contains("VirtualMachineProfile") };
Write-Verbose ('Running Command : ' + 'Get-AzureRmVmss | Format-Table');
$output = $vmssList | Format-Table | Out-String;
Write-Verbose ($output);
Assert-False { $output.Contains("VirtualMachineProfile") };

# List from RG
Write-Verbose ('Running Command : ' + 'Get-AzureRmVmss List');
$vmssList = Get-AzureRmVmss -ResourceGroupName $rgname;
Assert-True { ($vmssList | select -ExpandProperty Name) -contains $vmssName };
$output = $vmssList | Out-String;
Write-Verbose ($output);
Assert-True { $output.Contains("VirtualMachineProfile") };
Assert-False { $output.Contains("VirtualMachineProfile") };

# List Skus
Write-Verbose ('Running Command : ' + 'Get-AzureRmVmssSku');
Expand All @@ -170,10 +168,7 @@ function Test-VirtualMachineScaleSet
$vmListResult = Get-AzureRmVmssVM -ResourceGroupName $rgname -VMScaleSetName $vmssName;
$output = $vmListResult | Out-String;
Write-Verbose ($output);
Assert-True { $output.Contains("StorageProfile") };
Write-Verbose ('Running Command : ' + 'Get-AzureRmVmssVM | Format-Table');
$output = $vmListResult | Format-Table | Out-String;
Write-Verbose ($output);
Assert-False { $output.Contains("StorageProfile") };

# List each VM
for ($i = 0; $i -lt 2; $i++)
Expand All @@ -189,29 +184,30 @@ function Test-VirtualMachineScaleSet
$vmInstance = Get-AzureRmVmssVM -InstanceView -ResourceGroupName $rgname -VMScaleSetName $vmssName -InstanceId $i;
Assert-NotNull $vmInstance;
$output = $vmInstance | Out-String;

Write-Verbose($output);
Assert-True { $output.Contains("PlatformUpdateDomain") };
}

$st = Stop-AzureRmVmss -StayProvision -ResourceGroupName $rgname -VMScaleSetName $vmssName;
$st = Stop-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
$st = Start-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
$st = Restart-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
$st = $vmssResult | Stop-AzureRmVmss -StayProvision;
$st = $vmssResult | Stop-AzureRmVmss;
$st = $vmssResult | Start-AzureRmVmss;
$st = $vmssResult | Restart-AzureRmVmss;

$instanceListParam = @();
for ($i = 0; $i -lt 2; $i++)
{
$instanceListParam += $i.ToString();
}

$st = Stop-AzureRmVmss -StayProvision -ResourceGroupName $rgname -VMScaleSetName $vmssName -InstanceId $instanceListParam;
$st = Stop-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName -InstanceId $instanceListParam;
$st = Start-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName -InstanceId $instanceListParam;
$st = Restart-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName -InstanceId $instanceListParam;
$st = $vmssResult | Stop-AzureRmVmss -StayProvision -InstanceId $instanceListParam;
$st = $vmssResult | Stop-AzureRmVmss -InstanceId $instanceListParam;
$st = $vmssResult | Start-AzureRmVmss -InstanceId $instanceListParam;
$st = $vmssResult | Restart-AzureRmVmss -InstanceId $instanceListParam;

# Remove
$st = Remove-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName -InstanceId 1;
$st = Remove-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
$st = $vmssResult | Remove-AzureRmVmss;
}
finally
{
Expand Down Expand Up @@ -491,15 +487,15 @@ function Test-VirtualMachineScaleSetLB
Assert-True { ($vmssList | select -ExpandProperty Name) -contains $vmssName };
$output = $vmssList | Out-String;
Write-Verbose ($output);
Assert-True { $output.Contains("VirtualMachineProfile") };
Assert-False { $output.Contains("VirtualMachineProfile") };

# List from RG
Write-Verbose ('Running Command : ' + 'Get-AzureRmVmss List');
$vmssList = Get-AzureRmVmss -ResourceGroupName $rgname;
Assert-True { ($vmssList | select -ExpandProperty Name) -contains $vmssName };
$output = $vmssList | Out-String;
Write-Verbose ($output);
Assert-True { $output.Contains("VirtualMachineProfile") };
Assert-False { $output.Contains("VirtualMachineProfile") };

# List Skus
Write-Verbose ('Running Command : ' + 'Get-AzureRmVmssSku');
Expand All @@ -512,7 +508,7 @@ function Test-VirtualMachineScaleSetLB
$vmListResult = Get-AzureRmVmssVM -ResourceGroupName $rgname -VMScaleSetName $vmssName; # -Select $null;
$output = $vmListResult | Out-String;
Write-Verbose ($output);
Assert-True { $output.Contains("StorageProfile") };
Assert-False { $output.Contains("StorageProfile") };

# List each VM
for ($i = 0; $i -lt 2; $i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,12 @@ public void TestVirtualMachineRedeploy()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineRedeploy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineGetStatus()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineGetStatus");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function Test-VirtualMachine
$a = $vms | Out-String;
Write-Verbose("Get-AzureRmVM (List) output:");
Write-Verbose($a);
Assert-True{$a.Contains("NIC");}
Assert-AreNotEqual $vms $null;

# Remove All VMs
Expand Down Expand Up @@ -2657,3 +2658,133 @@ function Test-VirtualMachineRedeploy
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Virtual Machines
#>
function Test-VirtualMachineGetStatus
{
param ($loc)
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
if ($loc -eq $null)
{
$loc = Get-ComputeVMLocation;
}
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmsize = 'Standard_A4';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;

# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;

$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;

# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;

$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";

$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;

Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;

# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";

# $p.StorageProfile.OSDisk = $null;
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;

$imgRef = Get-DefaultCRPImage -loc $loc;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);

Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;

Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer;
Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus;
Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version;

# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;

# Get VM
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
$a = $vm1 | Out-String;
Write-Verbose("Get-AzureRmVM output:");
Write-Verbose($a);
$a = $vm1 | Format-Table | Out-String;
Write-Verbose("Get-AzureRmVM | Format-Table output:");
Write-Verbose($a);

Assert-AreEqual $vm1.Name $vmname;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].Id $nicId;

Assert-AreEqual $vm1.StorageProfile.ImageReference.Offer $imgRef.Offer;
Assert-AreEqual $vm1.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
Assert-AreEqual $vm1.StorageProfile.ImageReference.Sku $imgRef.Skus;
Assert-AreEqual $vm1.StorageProfile.ImageReference.Version $imgRef.Version;

Assert-AreEqual $vm1.OSProfile.AdminUsername $user;
Assert-AreEqual $vm1.OSProfile.ComputerName $computerName;
Assert-AreEqual $vm1.HardwareProfile.VmSize $vmsize;

$vm = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname -Status;
$a = $vm | Out-String;
Write-Verbose($a);
Assert-True {$a.Contains("Statuses");}

$vms = Get-AzureRmVM -ResourceGroupName $rgname -Status;
$a = $vms | Out-String;
Write-Verbose($a);
Assert-True {$a.Contains("PowerState");}

$vms = Get-AzureRmVM -Status;
$a = $vms | Out-String;
Write-Verbose($a);
Assert-True {$a.Contains("PowerState");}

# Remove
Remove-AzureRmVM -Name $vmname -ResourceGroupName $rgname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Graph.RBAC" version="3.2.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="13.0.4-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="13.1.0-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="7.1.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="4.1.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6052.28118-prerelease" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.13.0.4-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.13.1.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=7.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -307,6 +307,8 @@
<Compile Include="Models\PSAvailabilitySet.cs" />
<Compile Include="Models\PSVirtualMachineImageResource.cs" />
<Compile Include="Models\PSVirtualMachineInstanceView.cs" />
<Compile Include="Models\PSVirtualMachineList.cs" />
<Compile Include="Models\PSVirtualMachineListStatus.cs" />
<Compile Include="Models\PSVirtualMachineSize.cs" />
<Compile Include="Common\LocationStringExtensions.cs" />
<Compile Include="Models\UploadParameters.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ protected override void Configure()
Mapper.CreateMap<AzureOperationResponse<IEnumerable<FROM.VirtualMachine>>, TO.PSVirtualMachine>()
.ForMember(c => c.StatusCode, o => o.MapFrom(r => r.Response.StatusCode));

// VirtualMachine => PSVirtualMachineListStatusContext
Mapper.CreateMap<FROM.VirtualMachine, TO.PSVirtualMachineListStatus>()
.ForMember(c => c.AvailabilitySetReference, o => o.MapFrom(r => r.AvailabilitySet))
.ForMember(c => c.Extensions, o => o.MapFrom(r => r.Resources))
.ForMember(c => c.OSProfile, o => o.MapFrom(r => r.OsProfile));

Mapper.CreateMap<AzureOperationResponse<FROM.VirtualMachine>, TO.PSVirtualMachineListStatus>()
.ForMember(c => c.StatusCode, o => o.MapFrom(r => r.Response.StatusCode));

Mapper.CreateMap<AzureOperationResponse<IPage<FROM.VirtualMachine>>, TO.PSVirtualMachineListStatus>()
.ForMember(c => c.StatusCode, o => o.MapFrom(r => r.Response.StatusCode));

Mapper.CreateMap<AzureOperationResponse<IEnumerable<FROM.VirtualMachine>>, TO.PSVirtualMachineListStatus>()
.ForMember(c => c.StatusCode, o => o.MapFrom(r => r.Response.StatusCode));

Mapper.CreateMap<TO.PSVirtualMachineListStatus, TO.PSVirtualMachineList>();

// VirtualMachineSize => PSVirtualMachineSize
Mapper.CreateMap<FROM.VirtualMachineSize, TO.PSVirtualMachineSize>();

Expand Down
Loading