Skip to content
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

DiskIdentifier: Add FriendlyName as a disk identifier to Disk, DiskAccessPath and Wai… #269

Merged
merged 9 commits into from
Jan 26, 2023
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
images - Fixes [Issue #262](https://github.com/dsccommunity/StorageDsc/issues/262).
- Updated pipeline unit tests and integration tests to use Windows Server 2019 and
Windows Server 2022 images - Fixes [Issue #262](https://github.com/dsccommunity/StorageDsc/issues/262).
- Added support to use disk FriendlyName as a disk identifer - Fixes [Issue #268](https://github.com/dsccommunity/StorageDsc/issues/268).
- Pin Azure build agent vmImage to ubuntu-20.04 - Fixes [Issue #270] (https://github.com/dsccommunity/StorageDsc/issues/270).
- Remove confirmation prompt when Clear-Disk is called.
- Add mock Clear-Disk function and verification tests.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stages:
- job: Package_Module
displayName: 'Package Module'
pool:
vmImage: 'ubuntu-latest'
vmImage: 'ubuntu-20.04'
steps:
- pwsh: |
dotnet tool install --global GitVersion.Tool
Expand Down
8 changes: 4 additions & 4 deletions source/DSCResources/DSC_Disk/DSC_Disk.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Get-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -190,7 +190,7 @@ function Set-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -272,7 +272,7 @@ function Set-TargetResource
$($script:localizedData.ClearingDiskMessage -f $DiskIdType, $DiskId)
) -join '' )

$disk | Clear-Disk -RemoveData -RemoveOEM -Confirm:$true
$disk | Clear-Disk -RemoveData -RemoveOEM -Confirm:$false

# Requery the disk
$disk = Get-DiskByIdentifier `
Expand Down Expand Up @@ -687,7 +687,7 @@ function Test-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down
2 changes: 1 addition & 1 deletion source/DSCResources/DSC_Disk/DSC_Disk.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class DSC_Disk : OMI_BaseResource
{
[Key, Description("Specifies the identifier for which disk to modify.")] String DriveLetter;
[Required, Description("Specifies the disk identifier for the disk to modify.")] String DiskId;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location"}, Values{"Number","UniqueId","Guid","Location"}] String DiskIdType;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location","FriendlyName"}, Values{"Number","UniqueId","Guid","Location","FriendlyName"}] String DiskIdType;
[Write, Description("Specifies the partition style of the disk. Defaults to GPT."), ValueMap{"MBR","GPT"}, Values{"MBR","GPT"}] String PartitionStyle;
[Write, Description("Specifies the size of new volume. Leave empty to use the remaining free space.")] Uint64 Size;
[Write, Description("Define volume label if required.")] String FSLabel;
Expand Down
4 changes: 2 additions & 2 deletions source/DSCResources/DSC_Disk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ The resource is used to initialize, format and mount the partition/volume as a d
letter.
The disk to add the partition/volume to is selected by specifying the _DiskId_ and
optionally _DiskIdType_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_ or _Location_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_, _Location_ or _FriendlyName_.

**Important: The _Disk Number_ is not a reliable method of selecting a disk because
it has been shown to change between reboots in some environments.
It is recommended to use the _Unique Id_ if possible.**

The _Disk Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
The _Disk Number_, _Unique Id_, _Guid_, _Location_ and _FriendlyName_ can be identified for a
disk by using the PowerShell command:

```powershell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function Get-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -173,7 +173,7 @@ function Set-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -585,7 +585,7 @@ function Test-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location')]
[ValidateSet('Number', 'UniqueId', 'Guid', 'Location', 'FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DSC_DiskAccessPath : OMI_BaseResource
[Key, Description("Specifies the access path folder to the assign the disk volume to.")] String AccessPath;
[Write, Description("Specifies no automatic drive letter assignment to the partition: Defaults to True")] Boolean NoDefaultDriveLetter;
[Required, Description("Specifies the disk identifier for the disk to modify.")] String DiskId;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location"}, Values{"Number","UniqueId","Guid","Location"}] String DiskIdType;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location","FriendlyName"}, Values{"Number","UniqueId","Guid","Location","FriendlyName"}] String DiskIdType;
[Write, Description("Specifies the size of new volume.")] Uint64 Size;
[Write, Description("Define volume label if required.")] String FSLabel;
[Write, Description("Specifies the allocation unit size to use when formatting the volume.")] Uint32 AllocationUnitSize;
Expand Down
4 changes: 2 additions & 2 deletions source/DSCResources/DSC_DiskAccessPath/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ The resource is used to initialize, format and mount the partition/volume to a f
access path.
The disk to add the partition/volume to is selected by specifying the _DiskId_ and
optionally _DiskIdType_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_ or _Location_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_, _Location_ or _FriendlyName_.

**Important: The _Disk Number_ is not a reliable method of selecting a disk because
it has been shown to change between reboots in some environments.
It is recommended to use the _Unique Id_ if possible.**

The _Disk Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
The _Disk Number_, _Unique Id_, _Guid_, _Location_ and _FriendlyName_ can be identified for a
disk by using the PowerShell command:

```powershell
Expand Down
6 changes: 3 additions & 3 deletions source/DSCResources/DSC_WaitForDisk/DSC_WaitForDisk.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Get-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number','UniqueId','Guid','Location','FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -94,7 +94,7 @@ function Set-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number','UniqueId','Guid','Location','FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down Expand Up @@ -176,7 +176,7 @@ function Test-TargetResource
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number','UniqueId','Guid','Location','FriendlyName')]
[System.String]
$DiskIdType = 'Number',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class DSC_WaitForDisk : OMI_BaseResource
{
[Key, Description("Specifies the disk identifier for the disk to wait for.")] String DiskId;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location"}, Values{"Number","UniqueId","Guid","Location"}] String DiskIdType;
[Write, Description("Specifies the identifier type the DiskId contains. Defaults to Number."), ValueMap{"Number","UniqueId","Guid","Location","FriendlyName"}, Values{"Number","UniqueId","Guid","Location","FriendlyName"}] String DiskIdType;
[Write, Description("Specifies the number of seconds to wait for the disk to become available.")] Uint32 RetryIntervalSec;
[Write, Description("The number of times to loop the retry interval while waiting for the disk.")] Uint32 RetryCount;
[Read, Description("Will indicate whether Disk is available.")] Boolean IsAvailable;
Expand Down
4 changes: 2 additions & 2 deletions source/DSCResources/DSC_WaitForDisk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
This resource is used to wait for a disk to become available.
The disk to wait for is selected by specifying the _DiskId_ and optionally
_DiskIdType_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_ or _Location_.
The _DiskId_ value can be a _Disk Number_, _Unique Id_, _Guid_, _Location_ or _FriendlyName_.

**Important: The _Disk Number_ is not a reliable method of selecting a disk because
it has been shown to change between reboots in some environments.
It is recommended to use the _Unique Id_ if possible.**

The _Disk Number_, _Unique Id_, _Guid_ and _Location_ can be identified for a
The _Disk Number_, _Unique Id_, _Guid_, _Location_ and _FriendlyName_ can be identified for a
disk by using the PowerShell command:

```powershell
Expand Down
4 changes: 2 additions & 2 deletions source/Modules/StorageDsc.Common/StorageDsc.Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ function Get-DiskByIdentifier
$DiskId,

[Parameter()]
[ValidateSet('Number','UniqueId','Guid','Location')]
[ValidateSet('Number','UniqueId','Guid','Location','FriendlyName')]
[System.String]
$DiskIdType = 'Number'
)

switch -regex ($DiskIdType)
{
'Number|UniqueId' # for filters supported by the Get-Disk CmdLet
'Number|UniqueId|FriendlyName' # for filters supported by the Get-Disk CmdLet
{
$diskIdParameter = @{
$DiskIdType = $DiskId
Expand Down
Loading