Using vSphere storage policy-based management

Storage policy-based management (SPBM) is the control plane of VMware's management layer for Software-Defined Storage (SDS). SPBM can use the vSphere Storage APIs for Storage Awareness (VASA) providers to expose storage topologies, capabilities, and state information to vCenter Server. You can also manually define storage capabilities by using tags. For example, you can create tags for replicated and nonreplicated storage. These tags will be assigned to datastores. From the capabilities or tags, you can create SPBM rules, rule sets, and storage policies. These storage policies can be used to create virtual machines on storage that is compliant with a certain storage policy. Storage policies can be exported to XML files, which can be imported later.

Tip

All the SPBM-related cmdlets will only work with vCenter Server 5.5 or higher.

Retrieving storage capabilities

If your storage has a VASA provider, you can use the Get-SpbmCapability cmdlet to retrieve the capabilities of your storage system. This cmdlet has the following syntax:

Get-SpbmCapability [[-Name] <String[]>] [-Category <String[]>]
    [-Server <VIServer[]>] [<CommonParameters>]

The Get-SpbmCapability cmdlet has no required parameters. You can use the -Name parameter to filter for specific names. You can use the -Category parameter to filter for specific categories. In the following example, we will retrieve all the storage capabilities and display the Name, Category, DefaultValue, and ValueType properties:

PowerCLI C:> Get-SpbmCapability | Select-Object
    -Property Name,Category,DefaultValue,ValueType


    Name                        Category     DefaultValue ValueType
----                        --------     ------------ ---------
VSAN.cacheReservation       Performance             0 System.Int32
VSAN.checksumDisabled       Availability        False System.Boolean
VSAN.forceProvisioning      Placement           False System.Boolean
VSAN.hostFailuresToTolerate Availability            1 System.Int32
VSAN.proportionalCapacity   Space                   0 System.Int32
VSAN.replicaPreference      Availability RAID-1 (M... System.String
VSAN.stripeWidth            Performance             1 System.Int32

As you can see in the output of the preceding example, the vSAN VASA provider has seven capabilities. If you want to know more about the meaning of the capabilities, each capability has the FriendlyName and Description property that gives you more information. In the following example, we will retrieve the Name, FriendlyName, and Description property of the VSAN.hostFailuresToTolerate capability. We will display the output in a list format:

PowerCLI C:> Get-SpbmCapability -Name VSAN.hostFailuresToTolerate |
>> Select-Object -Property Name,FriendlyName,Description | Format-List


    Name         : VSAN.hostFailuresToTolerate
FriendlyName : Number of failures to tolerate
Description  : Defines the number of host, disk, or network
               failures a storage object can tolerate. When the
               fault tolerance method is mirroring: to tolerate "n"
               failures, "n+1" copies of the object are created and
               "2n+1" hosts contributing storage are required (if
               fault domains are configured, "2n+1" fault domains
               with hosts contributing storage are required). When
               the fault tolerance method is erasure coding: to
               tolerate 1 failure, 4 hosts (or fault domains) are
               required; and to tolerate 2 failures, 6 hosts (or
               fault domains) are required. Note: A host which is
               not part of a fault domain is counted as its own
               single-host fault domain. Default value: 1, Maximum
               value: 3.

Using tags to define storage capabilities

If your storage system does not have a VASA provider, you can use tags to manually assign storage capabilities to datastores. You will probably have different storage tiers, such as replicated and nonreplicated datastores or datastores with flash drives, SATA drives, or SAS drives. You define tags for each storage tier. For example, you can create a tag named Gold and assign it to the replicated datastores storage tier. You can create a tag named Silver and assign it to the nonreplicated datastores storage tier. In the following example, we will first create a tag category named StorageType for the Datastore entity type. We will give this tag category the cardinality Single, so you can only assign one tag from the StorageType tag category to a datastore:

PowerCLI C:> New-TagCategory -Name StorageType -Description
    'Type of storage' -EntityType Datastore -Cardinality Single


    Name                                     Cardinality Description
----                                     ----------- -----------
StorageType                              Single      Type of storage

Next, we will create a tag named Gold in the StorageType tag category:

PowerCLI C:> New-Tag -Name Gold -Description 'Gold storage'
    -Category StorageType


    Name                           Category                   Description
----                           --------                   -----------
Gold                           StorageType                Gold storage

Finally, we will assign the Gold tag to datastore datastore1:

PowerCLI C:> Get-Datastore -Name datastore1 | New-TagAssignment
    -Tag Gold


    Tag                                      Entity
---                                      ------
StorageType/Gold                         datastore1

Creating SPBM rules

We can use storage capabilities retrieved by a VASA provider, or we can use tags to create SPBM rules. If you use storage capabilities, you can create a rule based on a capability and value. You can also create a rule based on one or more tags. To create an SPBM rule, you can use the New-SpbmRule cmdlet. This cmdlet has two parameter sets. The first parameter set is for creating rules based on capabilities:

New-SpbmRule [-Capability] <SpbmCapability> [-Value] <Object>
    [-Server <VIServer>] [-WhatIf] [-Confirm] [<CommonParameters>]

The second parameter set is for creating rules based on tags:

New-SpbmRule -AnyOfTags <Tag[]> [-Server <VIServer>] [-WhatIf]
    [-Confirm] [<CommonParameters>]

The -Capability, -Value, and -AnyOfTags parameters are required:

In the first example, we will create an SPBM rule based on the VSAN.hostFailuresToTolerate capability and give it the value 2. We will assign the rule to the variable $CapabilityRule:

PowerCLI C:> $CapabilityRule = New-SpbmRule -Capability 
    VSAN.hostFailuresToTolerate -Value 2
PowerCLI C:> $CapabilityRule


    Capability                     Value                  AnyOfTags
----------                     -----                  ---------
VSAN.hostFailuresToTolerate    2 

In the following example, we will create an SPBM rule based on the tag Gold and assign the rule to the variable $TagRule:

PowerCLI C:> $TagRule = New-SpbmRule -AnyOfTags (Get-Tag -Name Gold)
PowerCLI C:> $TagRule


    Capability                     Value                  AnyOfTags
----------                     -----                  ---------
                                                      {StorageType/Gold}

Creating SPBM rule sets

You can combine SPBM rules into SPBM rule sets. A rule set will contain one or more rules. The New-SpbmRuleSet cmdlet will do this for you. The New-SpbmRuleSet cmdlet has the following syntax:

New-SpbmRuleSet [-AllOfRules] <SpbmRule[]> [-Name <String>]
    [-WhatIf] [-Confirm] [<CommonParameters>]

The -AllOfRules parameter is required.

In the following example, we will create a new SPBM rule set named GoldRuleSet from the SPBM rule in the $TagRule variable created in the preceding example:

PowerCLI C:> $RuleSet = New-SpbmRuleSet -Name GoldRuleSet
    -AllOfRules $TagRule
PowerCLI C:> $RuleSet


    AllOfRules
----------
{Gold}

Creating SPBM storage policies

To create SPBM storages policies, we can use the New-SpbmStoragePolicy cmdlet. This cmdlet will combine one or more SPBM rule sets or rules into a storage policy. The New-SpbmStoragePolicy has the following syntax:

New-SpbmStoragePolicy [-Name] <String> [-Description <String>]
    [-AnyOfRuleSets <SpbmRuleSet[]>] [-CommonRule <SpbmRule[]>]
    [-Server <VIServer>] [-WhatIf] [-Confirm] [<CommonParameters>]

The -Name parameter is required. If you use the -CommonRule parameter, you can only use rules from the VAIOFilter namespace.

Note

vSphere APIs for IO Filtering (VAIO), introduced in ESXi 6.0 Update 1, is a framework for filters created by VMware partners, which run in ESXi and can intercept any IO requests from a guest operating system to a virtual disk. Filters are installed as a vSphere Installation Bundle (VIB) on the ESXi server. In ESXi 6.0 Update 1, only filters for caching and replication are supported by VMware. You can use SPBM to create storage policies that use VAIO filters. For example, you can create a storage policy that applies a caching policy to virtual machines.

PowerCLI has the following four cmdlets to install, retrieve, modify, and remove VAIO filters: New-VAIOFilter, Get-VAIOFilter, Set-VAIOFilter, and Remove-VAIOFilter. While writing this book, there are no VAIO filters available. Therefore, we will not discuss the PowerCLI VAIO cmdlets in detail.

The following example will create a storage policy named GoldPolicy from the rule set created in the preceding example:

PowerCLI C:> New-SpbmStoragePolicy -Name GoldPolicy -Description
    'Policy for Gold storage' -RuleSet $RuleSet


    Name                 Description                        AnyOfRuleSets
----                 -----------                        -------------
GoldPolicy           Policy for Gold storage            {(Gold)}

Retrieving SPBM storage policies

The Get-SpbmStoragePolicy cmdlet can be used to retrieve SPBM storage policies. This cmdlet has the following syntax. The first parameter set is for retrieving storage policies by requirement, name, name space, capability, or tag:

Get-SpbmStoragePolicy [-Requirement] [-Resource] [[-Name]
    <String[]>] [-Namespace <String[]>] [-Capability <SpbmCapability[]>]
    [-Tag <Tag[]>] [-Server <VIServer[]>] [<CommonParameters>]

The second parameter set is for retrieving storage policies by ID:

Get-SpbmStoragePolicy [-Id <String[]>] [-Server <VIServer[]>]
    [<CommonParameters>]

The Get-SpbmStoragePolicy cmdlet has no required parameters.

In the following example, we will retrieve a list of all of the SPBM storage policies:

PowerCLI C:> Get-SpbmStoragePolicy


    Name                 Description                        AnyOfRuleSets
----                 -----------                        -------------
Default-VirtualDisk                                     {(VSAN.hos...
VSANStorageCapabi...                                    {(VSAN.hos...
Default-VM-Home                                         {(VSAN.hos...
Virtual SAN Defau... Storage policy used as default ... {(VSAN.hos...
VVol No Requireme... Allow the datastore to determi...
GoldPolicy           Policy for Gold storage            {(Gold)}
VM Encryption Policy Sample storage policy for VMwar... {(com....

As you can see in the output of the preceding example, besides the GoldPolicy storage policy that we created, there are also policies created by vSAN and a policy for Virtual Volumes (VVols).

Note

VMware VVols is an integration and management framework for external storage. VVols enables VM-aware storage and storage policy-based management. VVols eliminates physical containers such as LUNs. With VVols a storage administrator creates a VVols datastore. vSphere administrators create virtual disk containers (VVols) that are specific to a virtual machine. VVols becomes the unit of data management at the storage array level. All of the major storage vendors support VVols. VVols are included in all editions of vSphere 6.0 and higher.

Modifying SPBM storage policies

You can use the Set-SpbmStoragePolicy cmdlet to override the current name, description, and rule sets of an existing storage policy. The syntax of the Set-SpbmStoragePolicy cmdlet is as follows:

Set-SpbmStoragePolicy -StoragePolicy <SpbmStoragePolicy[]>
    [-Name <String>] [-Description <String>] [-AnyOfRuleSets
    <SpbmRuleSet[]>] [-CommonRule <SpbmRule[]>] [-Server <VIServer>]
    [-WhatIf] [-Confirm] [<CommonParameters>]

The -StoragePolicy parameter is required.

In the following example, we will use the Set-SpbmStoragePolicy cmdlet to modify the description of the GoldPolicy storage policy:

PowerCLI C:> Set-SpbmStoragePolicy -Policy GoldPolicy -Description
    'Storage policy for tier-1 storage'


    Name               Description                           AnyOfRuleSets
----               -----------                           -------------
GoldPolicy         Storage policy for tier-1 storage     {(Gold)}

Retrieving SPBM compatible storage

If you create a new virtual machine and want to store this virtual machine on storage that is compatible with a certain storage policy, you can use the Get-SpbmCompatibleStorage cmdlet to retrieve a list of compatible storage:

Get-SpbmCompatibleStorage -StoragePolicy <SpbmStoragePolicy>
    [-CandidateStorage <StorageResource[]>] [-Server <VIServer[]>]
    [<CommonParameters>]

The -StoragePolicy parameter is required.

You can use the -CandidateStorage parameter to specify a list of datastores that must be checked for compliance with the storage policy. If you don't use the -CandidateStorage parameter, all of your datastores will be checked for compliance with the storage policy.

In the following example, we will retrieve all the datastores that are compliant with the GoldPolicy storage policy:

PowerCLI C:> Get-SpbmCompatibleStorage -StoragePolicy GoldPolicy


    Name                               FreeSpaceGB      CapacityGB
----                               -----------      ----------
datastore1                             151.550         250.000

As you can see in the output of the preceding example, datastore datastore1 is found to be compliant with the GoldPolicy storage policy. This was expected because we assigned the Gold tag to the datastore datastore1 in the preceding section,  Using tags to define storage capabilities .

Using SPBM to create virtual machines

Now we know how to retrieve SPBM compatible storage. We can use this to create virtual machines on datastores with a certain storage policy. In the following example, we will use the New-VM cmdlet to create a new virtual machine named VM10. We will use the Get-SpbmCompatibleStorage cmdlet to retrieve storage compatible with the GoldPolicy storage policy. Because the output of this cmdlet can be an array of datastores, we will pipe the output to the Get-Random cmdlet to randomly select a compatible datastore:

PowerCLI C:> New-VM -Name VM10 -Datastore (Get-SpbmCompatibleStorage
    -StoragePolicy GoldPolicy | Get-Random) -VMHost 192.168.0.133


    Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
VM10                 PoweredOff 1        0.250

Retrieving SPBM-related configuration data of clusters, virtual machines, and hard disks

The Get-SpbmEntityConfiguration cmdlet will retrieve SPBM-related configuration data of clusters, virtual machines, and hard disks. This configuration data consists of:

  • SPBM enablement status for clusters
  • Associated storage policy for virtual machines or hard disks
  • Compliance status for virtual machines or hard disks

The syntax of the Get-SpbmEntityConfiguration cmdlet is as follows. The first parameter set is for retrieving entity configurations by storage policy:

Get-SpbmEntityConfiguration [-StoragePolicy <SpbmStoragePolicy[]>]
    [-VMsOnly] [-HardDisksOnly] [-CheckComplianceNow] [-Server
    <VIServer[]>] [<CommonParameters>]

The second parameter set is for retrieving entity configurations by entity:

Get-SpbmEntityConfiguration [[-VM] <VIObject[]>] [-HardDisk
    <HardDisk[]>] [-Cluster <Cluster[]>] [-CheckComplianceNow]
    [-Server <VIServer[]>] [<CommonParameters>]

The Get-SpbmEntityConfiguration cmdlet has no required parameters. If you don't specify a storage policy, the cmdlet returns the status for all available storage policies.

In the following example we will retrieve the status for all the available storage policies:

PowerCLI C:> Get-SpbmEntityConfiguration


    Entity      Storage Policy            Status      Time Of Check
------      --------------            ------      -------------
VM10        GoldPolicy                compliant   2/1/2017 4:42:39 PM

As you can see in the output of the preceding example, the virtual machine VM10 is compliant with the GoldPolicy storage policy.

In the following example, we will retrieve the SPBM-enabled status of cluster Cluster01:

PowerCLI C:> Get-SpbmEntityConfiguration -Cluster Cluster01


    Name                           SpbmEnabled
----                           -----------
Cluster01                      False

Associating storage policies with virtual machines and hard disks and enabling SPBM on clusters

You can associate SPBM storage policies with virtual machines and hard disks. You can also enable or disable SPBM for clusters. This all can be done using the Set-SpbmEntityConfiguration cmdlet. The syntax of this cmdlet is as follows:

Set-SpbmEntityConfiguration [-Configuration] 
    <SpbmEntityConfiguration[]> [-SpbmEnabled [<Boolean>]]
    [-StoragePolicy <SpbmStoragePolicy>] [-Server <VIServer>]
    [-WhatIf] [-Confirm] [<CommonParameters>]

The -Configuration parameter is required.

As you can see in the output of one of the preceding examples, virtual machine VM2 is not associated with any storage policy. In the following example, we will associate virtual machine VM2 with the GoldPolicy storage policy:

PowerCLI C:> Get-VM -Name VM2 | Set-SpbmEntityConfiguration
    -StoragePolicy GoldPolicy

 
    Entity     Storage Policy     Status           Time Of Check
------     --------------     ------           -------------
VM2        GoldPolicy         nonCompliant     2/1/2017 6:08:55 PM

As you can see in the output of the preceding example, virtual machine VM2 is not compliant with the GoldPolicy storage policy. This is because virtual machine VM2 is not stored on a datastore associated with the GoldPolicy storage policy. To make virtual machine VM2 compliant with storage policy GoldPolicy, you have to migrate virtual machine VM2 to a datastore associated with the GoldPolicy storage policy.

In the following example, we will enable SPBM on cluster Cluster01:

PowerCLI C:> Set-SpbmEntityConfiguration -Configuration
    Cluster01 -SpbmEnabled $true


    Name                           SpbmEnabled
----                           -----------
Cluster01                      True

Exporting SPBM storage policies

You can use the Export-SpbmStoragePolicy cmdlet to export a storage policy to an XML file. This can be useful for copying storage policies from one vCenter Server to another. The syntax of the Export-SpbmStoragePolicy cmdlet is as follows:

Export-SpbmStoragePolicy [-FilePath] <String> [-StoragePolicy]
    <SpbmStoragePolicy> [-Force] [-Server <VIServer>] [-WhatIf]
    [-Confirm] [<CommonParameters>]

The -FilePath and -StoragePolicy parameters are required.

In the following example, we will export the GoldPolicy storage policy to a file named GoldPolicy.xml in your home folder. The -Force parameter is used to overwrite any existing destination file:

PowerCLI C:> Export-SpbmStoragePolicy -StoragePolicy GoldPolicy
    -FilePath $env:HOMEPATHGoldPolicy.xml -Force


    Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---          2/1/2017   8:26 PM       1597 GoldPolicy.xml

Importing SPBM storage policies

Storage policies can be imported using the Import-SpbmStoragePolicy cmdlet. This cmdlet has the following syntax.

Import-SpbmStoragePolicy [-FilePath] <String> [-Name]
    <String> [-Description <String>] [-Server <VIServer>]
    [-WhatIf] [-Confirm] [<CommonParameters>]

The -FilePath and -Name parameters are required.

We will import the GoldPolicy.XML file we created in the preceding example, and name the new storage policy GoldPolicy2 using the following command:

PowerCLI C:> Import-SpbmStoragePolicy -FilePath
    $env:HOMEPATHGoldPolicy.xml -Name GoldPolicy2


    Name               Description                           AnyOfRuleSets
----               -----------                           -------------
GoldPolicy2        Storage policy for tier-1 storage     {(Gold)}

Removing SPBM storage policies

To remove a storage policy you can use the Remove-SpbmStoragePolicy cmdlet. The syntax of this cmdlet is as follows:

Remove-SpbmStoragePolicy [-StoragePolicy] <SpbmStoragePolicy[]>
    [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

The -StoragePolicy parameter is required.

In the following example, we will remove storage policy GoldPolicy2:

PowerCLI C:> Remove-SpbmStoragePolicy -StoragePolicy
    GoldPolicy2 -Confirm:$false

The preceding command does not return any output.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.219.65