Skip to content

Latest commit

 

History

History
49 lines (25 loc) · 3.58 KB

File metadata and controls

49 lines (25 loc) · 3.58 KB

Description

The resource is used to create a virtual hard disk and attach it to the system.

There are 2 high level scenarios, one where the user uses the 'Present' flag and the second when the user uses the 'Absent' flag in the resource.

  1. When the 'Present' flag is used the resource checks if the virtual hard disk is on the machine using the file path that is entered.

    a. If the file path is correct and it is confirmed to be the location of a real virtual hard disk file. The resource will do nothing.

    b. If the location is a real virtual hard disk file but is not attached, the resource will attach the virtual hard disk to the system.

    c. If the location is not real the resource will throw an error advising that the location does not exist.

  2. When the 'Absent' flag is used the resource checks if the virtual disk is on the machine using the file path that is entered.

    a. If the file path is correct and it is confirmed to be the location of a real virtual hard disk. The resource will detach the virtual hard disk from the system.

    b. If the location is a real virtual hard disk but is not attached to the system, the resource will do nothing.

    c. If the location is not real, the resource will throw an error advising that the location does not exist.

    d. The resource does not delete a virtual hard disk file, that already exists on the system prior to the Set-TargetResource function being called. It will only detach the virtual hard disk from the system. The file will remain, this is to prevent accidental deletions.

How does this differ from the DSC_VHD in the Hyper-V Dsc?

This DSC_VirtualHardDisk resource does not rely on the Hyper-V Windows feature being enabled to allow users to use the resource. Unlike the DSC_VHD, users can use this resource right out of the box assuming they are running at least Windows 8.1 / Windows Server 2008 R2 or later. The resource uses the publicly available Win32 virtual disk apis, to create and attach a virtual hard disk file (.vhd and .vhdx) to the system. See more information about the apis here.

Limitations

  1. The resource only supports .vhd and .vhdx files. No other virtual hard disk file extension is supported at this time.

  2. The ability to expand the max size of the virtual hard disk after its creation is not currently included in this resource.

  3. The resource uses default values internally to create the virtual hard disk file that are not provided in the Get\Test\Set Methods. Values such as:

    a. The ability to set the block size of the virtual hard disk in bytes.

    b. The ability to set the sector size of the virtual hard disk in bytes.

    c. The ability to associate the new virtual hard disk with an existing virtual hard disk.

    d. The ability to specify a resiliency guid for the virtual hard disk.

    e. The ability to set a unique Id for the virtual hard disk and not use one generated by the system.

    f. The ability to prepopulate a new virtual disk with data from an existing virtual disk.

See virtdisk.h to read about what the Win32 api supports. This resource could in theory support all of these, as the parameters just need to be passed to the the CreateVirtualDisk Win32 function call in the resource. So additional help from the community if any of these are wanted, is welcomed.