mapping.psm1
$VolumeMappingsDefaultProperties = ('index','name', 'lun', 'ig-name','vol-name') .(commonLib) Function Get-XtremVolumeMappings { <# .DESCRIPTION Displays the list of LUN mappings between Volumes and Initiator Groups. .PARAMETER Properties Array of properties requested from this call. .PARAMETER Filters Array of filters for this call. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Get-XtremVolumeMappings .EXAMPLE Get-XtremVolumeMappings -Property name,lun,ig-name,mapping-index,tg-id | select -f 11 #> [cmdletbinding()] [Alias('xmsVolumeListMappings')] Param ( [parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [parameter()] [Alias("Properties")] [Argumentcompleter( { doComplete $args 'lun-maps' prop })] [string[]]$Property = $VolumeMappingsDefaultProperties, [parameter()] [Alias("Filters")] [Argumentcompleter( { doComplete $args 'lun-maps' filter })] [string[]]$Filter, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest, [Parameter()] [switch]$Full = $false ) initCommand $Route = '/types/lun-maps' if ($Full) { $Property = '' } $result = NewXtremRequest -Method GET -endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Properties $Property -ObjectSelection $ObjectSelection -Filters $Filter -ShowRest:$ShowRest.IsPresent -Multi -Full:$Full.IsPresent $result = formatOutPut $Property $result finalizeCommand return $result } Function Get-XtremVolumeMapping { <# .DESCRIPTION displays the selected LUN mapping's details. .PARAMETER MappingName LUN map's name or index number. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Get-XtremVolumeMapping -MappingName mapv23 .EXAMPLE Get-XtremVolumeMapping 342_8_1 -Property mapping-index,ig-name,lun,name #> [cmdletbinding()] [Alias('xmsVolumeGetMapping')] Param ( [parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Alias("Name", "Index")] [Argumentcompleter( { doComplete $args 'lun-maps' name })] $MappingName, [Parameter()] [Alias("Properties")] [Argumentcompleter( { doComplete $args 'lun-maps' prop })] [string[]]$Property, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/types/lun-maps' $Route, $GetProperty = SetParametersForRequest $Route $MappingName $result = NewXtremRequest -Method GET -endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -ObjectSelection $ObjectSelection -GetProperty $GetProperty -Properties $Property -ShowRest:$ShowRest.IsPresent $result = formatOutPut $Property $result finalizeCommand return $result } Function New-XtremVolumeMapping { <# .DESCRIPTION Enables you to create LUN mapping between Volumes and Initiator Groups. .PARAMETER VolName Volume's name or index number. .PARAMETER InitiatorGroup Initiator Group's name or index number .PARAMETER TGId Target Group's name or index number .PARAMETER Lun Unique LUN identification, exposing the Volume to the host .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE New-XtremVolumeMapping -VolName myvol -InitiatorGroup gr12 #> [CmdletBinding()] [Alias('xmsVolumeMap')] Param ( [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Alias("Name", "Index")] [Argumentcompleter( { doComplete $args 'volumes' name })] $VolName, [Parameter(Mandatory = $true, Position = 1)] [Argumentcompleter( { doComplete $args 'initiator-groups' name })] $InitiatorGroup, [Parameter()] $TGId, [Parameter()] [String]$Lun, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/types/lun-maps' $BodyList = @{ } AddIfExists -name "cluster-id" -value $XtremClusterName -list $BodyList AddIfExists -name "vol-id" -value $VolName -list $BodyList AddIfExists -name "ig-id" -value $InitiatorGroup -list $BodyList AddIfExists -name "tg-id" -value $TGId -list $BodyList AddIfExists -name "lun" -value $Lun -list $BodyList $Body = BuildXtremJson -list $BodyList $result = NewXtremRequest -Method POST -endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Body $Body -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Function Remove-XtremVolumeMapping { <# .DESCRIPTION Enables you to remove a Volume's LUN mapping. .PARAMETER MappingName LUN maps index number .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Remove-XtremVolumeMapping -MappingName 50_2_1 #> [cmdletbinding()] [Alias('xmsVolumeUnmap')] Param ( [parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Alias("Name", "Index")] [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Argumentcompleter( { doComplete $args 'lun-maps' name })] $MappingName, [Parameter()] [bool]$Confirm = (Get-XtremDefaultSession)._XtremCLIMode, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) $confirmed = IsConfirmed $Confirm if (!$confirmed) { return } initCommand $Route = '/types/lun-maps' $Route, $GetProperty = SetParametersForRequest $Route $MappingName $result = NewXtremRequest -Method DELETE -XtremClusterName $XtremClusterName -endpoint $Route -Session $Session -GetProperty $GetProperty -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Export-ModuleMember *-* -Alias * |