Skip to content

[AzureRT] Bug fixes. #4519

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 3 commits into from
Sep 6, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,23 @@ function Test-VirtualMachineProfile
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";

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

$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 0 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 1 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB $null -Lun 2 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;

# Managed data disk setting
$managedDataDiskId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rggroup/providers/Microsoft.Compute/disks/dataDisk";
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB $null -Lun 2 -CreateOption Empty -ManagedDiskId $managedDataDiskId -StorageAccountType StandardLRS;
Assert-AreEqual $managedDataDiskId $p.StorageProfile.DataDisks[2].ManagedDisk.Id;
Assert-AreEqual "StandardLRS" $p.StorageProfile.DataDisks[2].ManagedDisk.StorageAccountType;
Assert-Null $p.StorageProfile.DataDisks[2].DiskSizeGB;

$p = Set-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -StorageAccountType PremiumLRS;
Assert-AreEqual $managedDataDiskId $p.StorageProfile.DataDisks[2].ManagedDisk.Id;
Assert-AreEqual "PremiumLRS" $p.StorageProfile.DataDisks[2].ManagedDisk.StorageAccountType;

$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';

Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public static class HelpMessages
public const string VMDataDiskLun = "The virtual machine data disk's Lun.";
public const string VMDataDiskCreateOption = "The virtual machine data disk's create option.";

public const string VMManagedDiskId = "The virtual machine managed disk's Id.";
public const string VMManagedDiskAccountType = "The virtual machine managed disk's account type.";

public const string VMNetworkInterfaceName = "The virtual machine network interface's name.";
public const string VMNetworkInterfaceID = "The virtual machine network interface's ID.";
public const string VMPublicIPAddressName = "The virtual machine public IP address's name.";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,7 @@ The file needs to be a PowerShell script (.ps1 or .psm1) or a ZIP archive (.zip)
<data name="DiagnosticsExtensionMismatchStorageAccountName" xml:space="preserve">
<value>Storage account names provided in public and private configs do not match.</value>
</data>
<data name="NotManagedDisk" xml:space="preserve">
<value>The given disk is not a managed disk.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ public class AddAzureVMDataDiskCommand : Microsoft.Azure.Commands.ResourceManage

[Parameter(
Position = 8,
ValueFromPipelineByPropertyName = true)]
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMManagedDiskId)]
[ValidateNotNullOrEmpty]
public string ManagedDiskId { get; set; }

[Parameter(
Position = 9,
ValueFromPipelineByPropertyName = true)]
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMManagedDiskAccountType)]
[ValidateNotNullOrEmpty]
public StorageAccountTypes? StorageAccountType { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public class SetAzureVMDataDiskCommand : Microsoft.Azure.Commands.ResourceManage
[AllowNull]
public int? DiskSizeInGB { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMManagedDiskAccountType)]
[ValidateNotNullOrEmpty]
public StorageAccountTypes? StorageAccountType { get; set; }

public override void ExecuteCmdlet()
{
var storageProfile = this.VM.StorageProfile;
Expand Down Expand Up @@ -102,6 +109,22 @@ public override void ExecuteCmdlet()
{
dataDisk.DiskSizeGB = this.DiskSizeInGB;
}
if (this.StorageAccountType != null)
{
if (dataDisk.ManagedDisk == null)
{
ThrowTerminatingError
(new ErrorRecord(
new InvalidOperationException(Properties.Resources.NotManagedDisk),
string.Empty,
ErrorCategory.InvalidData,
null));
}
else
{
dataDisk.ManagedDisk.StorageAccountType = this.StorageAccountType;
}
}
}

this.VM.StorageProfile = storageProfile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,15 @@ public class SetAzureVMOSDiskCommand : Microsoft.Azure.Commands.ResourceManager.

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMManagedDiskId)]
[ValidateNotNullOrEmpty]
public string ManagedDiskId { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMManagedDiskAccountType)]
[ValidateNotNullOrEmpty]
public StorageAccountTypes? StorageAccountType { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Modifies properties of a virtual machine data disk.
### ChangeWithName
```
Set-AzureRmVMDataDisk [-VM] <PSVirtualMachine> [-Name] <String> [[-Caching] <CachingTypes>]
[[-DiskSizeInGB] <Int32>] [<CommonParameters>]
[[-DiskSizeInGB] <Int32>] [-StorageAccountType <StorageAccountTypes>] [<CommonParameters>]
```

### ChangeWithLun
```
Set-AzureRmVMDataDisk [-VM] <PSVirtualMachine> [-Lun] <Int32> [[-Caching] <CachingTypes>]
[[-DiskSizeInGB] <Int32>] [<CommonParameters>]
[[-DiskSizeInGB] <Int32>] [-StorageAccountType <StorageAccountTypes>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -114,6 +114,22 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -StorageAccountType
The virtual machine managed disk's account type.

```yaml
Type: StorageAccountTypes
Parameter Sets: (All)
Aliases:
Accepted values: StandardLRS, PremiumLRS

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -VM
Specifies the virtual machine for which this cmdlet modifies a data disk.
To obtain a virtual machine object, use the Get-AzureRmVM cmdlet.
Expand All @@ -136,7 +152,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## INPUTS

### PSVirtualMachine

Parameter 'VM' accepts value of type 'PSVirtualMachine' from the pipeline

## OUTPUTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,14 @@ function Test-MigrationAbortAzureStorageAccount
Get-AzureStorageAccount -StorageAccountName $storageName;

Move-AzureStorageAccount -Prepare -StorageAccountName $storageName;
Get-AzureStorageAccount -StorageAccountName $storageName;
$result = Get-AzureStorageAccount -StorageAccountName $storageName;
Assert-AreEqual "Prepared" $result.MigrationState;
$resultOut = $result | Out-String;

Move-AzureStorageAccount -Abort -StorageAccountName $storageName;
Get-AzureStorageAccount -StorageAccountName $storageName;
$result = Get-AzureStorageAccount -StorageAccountName $storageName;
Assert-Null $result.MigrationState;
$resultOut = $result | Out-String;

# Cleanup
Remove-AzureStorageAccount -StorageAccountName $storageName;
Expand Down Expand Up @@ -1039,53 +1043,53 @@ function Run-InitiateMaintenanceTest
# or 400 with error message like "User initiated maintenance on the virtual machine was
# successfully completed". Both are expected reponses.
# To continue script, $ErrorActionPreference should be set to 'SilentlyContinue'.
$tempErrorActionPreference = $ErrorActionPreference;
$tempErrorActionPreference = $ErrorActionPreference;
$ErrorActionPreference = 'SilentlyContinue';
# Setup
$location = "Central US EUAP";
$imgName = Get-DefaultImage $location;
# Setup
$location = "Central US EUAP";
$imgName = Get-DefaultImage $location;

$storageName = 'pstest' + (getAssetName);
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;
$storageName = 'pstest' + (getAssetName);
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;

# Associate the new storage account with the current subscription
Set-CurrentStorageAccountName $storageName;
# Associate the new storage account with the current subscription
Set-CurrentStorageAccountName $storageName;

$vmName = "psvm01";
$svcName = 'pstest' + (Get-CloudServiceName);
$userName = "pstestuser";
$password = $PLACEHOLDER;
$vmName = "psvm01";
$svcName = 'pstest' + (Get-CloudServiceName);
$userName = "pstestuser";
$password = $PLACEHOLDER;

# Test
New-AzureService -ServiceName $svcName -Location $location;
# Test
New-AzureService -ServiceName $svcName -Location $location;

try
{
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername $userName -Password $password;
try
{
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername $userName -Password $password;
#Start-Sleep -s 300; #Uncomment this line for record mode testing.

# Get VM
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName;
Assert-NotNull $vm;
Assert-NotNull $vm.MaintenanceStatus;
# Get VM
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName;
Assert-NotNull $vm;
Assert-NotNull $vm.MaintenanceStatus;

# Test Initiate Maintenance
$result = Restart-AzureVM -InitiateMaintenance -ServiceName $svcName -Name $vmName;
# Test Initiate Maintenance
$result = Restart-AzureVM -InitiateMaintenance -ServiceName $svcName -Name $vmName;

$vm = Get-AzureVM -ServiceName $svcName -Name $vmName
Assert-NotNull $vm.MaintenanceStatus;
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName
Assert-NotNull $vm.MaintenanceStatus;
}
catch
{
Assert-True {$result.Result.Contains("User initiated maintenance on the Virtual Machine was successfully completed.")};
Assert-True {$result.Result.Contains("User initiated maintenance on the Virtual Machine was successfully completed.")};
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName
Assert-NotNull $vm.MaintenanceStatus;
}
finally
{
# Cleanup
Cleanup-CloudService $srcName;
$ErrorActionPreference = $tempErrorActionPreference;
}
}
finally
{
# Cleanup
Cleanup-CloudService $srcName;
$ErrorActionPreference = $tempErrorActionPreference;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected PSStorageService(StorageServicePropertiesOperationContext account, Azu
}

this.Endpoints = endpointList;
this.MigrationState = account.MigrationState;
}

public static PSStorageService Create(StorageManagementClient client,
Expand Down