iscsi.psm1


.(commonLib) 

Function Get-XtremISCSIPortals {
  <#
    .DESCRIPTION
    displays the list of all iSCSI portals and their parameters.
 
    .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-XtremISCSIPortals
  #>

    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [parameter()]
        [Alias("Properties")]
        [Argumentcompleter( { doComplete $args 'iscsi-portals' prop })]
        [string[]]$Property,
        [parameter()]
        [Alias("Filters")]
        [Argumentcompleter( { doComplete $args 'iscsi-portals' filter })]
        [string[]]$Filter,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest,
        [Parameter()]
        [switch]$Full = $false
    )
    initCommand
    $Route = '/types/iscsi-portals'

    if ($Full) { $Property = '' }
    
    $result = NewXtremRequest -Method GET -endpoint $Route -Session $Session  -XtremClusterName $XtremClusterName -Properties $Property -Filters $Filter -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent -Multi -Full:$Full.IsPresent
    
    $result = formatOutPut $Property $result
    
    finalizeCommand
    return $result
}

Function Get-XtremISCSIPortal {
   <#
    .DESCRIPTION
    Displays details of an iSCSI portals.
 
    .PARAMETER ISCSIPortalName
    Index or name of the ISCSI Portal Name
 
    .PARAMETER Properties
    Array of properties requested from this call.
 
    .PARAMETER ShowRest
    Return an object represents the REST operation including URI , Method and JSON
 
    .EXAMPLE
    Get-XtremISCSIPortal -ISCSIPortalName myportal
  #>

    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [Alias("Name", "Index")]
        [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)]
        [Argumentcompleter( { doComplete $args 'iscsi-portals' name })]
        $ISCSIPortalName,
        [Parameter()]
        [Alias("Properties")]
        [Argumentcompleter( { doComplete $args 'iscsi-portals' prop })]
        [string[]]$Property,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest
    )
    initCommand
    $Route = '/types/iscsi-portals'
    $Route, $GetProperty = SetParametersForRequest $Route $ISCSIPortalName
    
    $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
}

#Deletes an ISCSI Portal.
Function Remove-XtremISCSIPortal
{
    
  <#
    .DESCRIPTION
    enables you to remove a portal mapping from a Target.
 
    .PARAMETER ISCSIPortalName
    Index or name of the ISCSI Portal Name
 
    .PARAMETER ShowRest
    Return an object represents the REST operation including URI , Method and JSON
 
    .EXAMPLE
    Remove-XtremISCSIPortal -ISCSIPortalName portal
  #>

    
    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [Alias("Name", "Index")]
        [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)]
        $ISCSIPortalName,
        [Parameter()]
        [bool]$Confirm =  (Get-XtremDefaultSession)._XtremCLIMode,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest
    )
    
    $confirmed = IsConfirmed $Confirm
    if (!$confirmed)
    {
        return
    }
    
    $Route = '/types/iscsi-portals'
    $Route, $GetProperty = SetParametersForRequest $Route $ISCSIPortalName
    
    NewXtremRequest -Method DELETE -endpoint $Route -Session $Session  -XtremClusterName $XtremClusterName -GetProperty $GetProperty -ShowRest:$ShowRest.IsPresent
    
}

Function New-XtremISCSIPortal
{
    
 <#
    .DESCRIPTION
    Enables you to map a portal (which is a combination of an IP address and an IP port) to Target.
 
    .PARAMETER TarId
    Target's name or index number
 
    .PARAMETER IpAddr
    IP address (cannot be used for another portal)
 
    .PARAMETER VLan
    VLAN index number
 
    .PARAMETER ShowRest
    Return an object represents the REST operation including URI , Method and JSON
 
    .EXAMPLE
    New-XtremISCSIPortal -TarId 1 -IpAddr "152.62.109.54/24"
  #>

    [CmdletBinding()]
    Param (
        [Parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [Alias("Name", "Index")]
        [Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $true, Position = 0)]
        $TarId,
        [Parameter(Mandatory = $True, Position = 1)]
        [String]$IpAddr,
        [Parameter()]
        [String]$VLan,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest
    )
    
    $Route = '/types/iscsi-portals'
    
    $BodyList = @{ }
    
    AddIfExists -name "cluster-id" -value $XtremClusterName -list $BodyList
    AddIfExists -name "tar-id" -value $TarId -list $BodyList
    AddIfExists -name "ip-addr" -value $IpAddr -list $BodyList
    AddIfExists -name "port-address" -value $PortAddress -list $BodyList
    AddIfExists -name "vLan" -value $VLan -list $BodyList
    $Body = BuildXtremJson -list $BodyList
    
    $ObjectSelection = 'content'
    
    NewXtremRequest -Method POST -endpoint $Route -Session $Session  -XtremClusterName $XtremClusterName -Body $Body -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent
}

Function Get-XtremISCSIRoutes
{
    
    <#
    .DESCRIPTION
    displays the list of iSCSI routes and their parameters.
 
    .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-XtremISCSIRoutes
  #>

    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [parameter()]
        [Alias("Properties")]
        [string[]]$Property,
        [parameter()]
        [Alias("Filters")]
        [string[]]$Filter,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest,
        [Parameter()]
        [switch]$Full = $false
    )
    
    $Route = '/types/iscsi-routes'
    $ObjectSelection = 'iscsi-routes'
    
    $result = NewXtremRequest -Method GET -endpoint $Route -Session $Session  -XtremClusterName $XtremClusterName -Properties $Property -Filters $Filter -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent -Multi -Full:$Full.IsPresent

    $result = formatOutPut $Property $result
    
    return $result
    
}

Function Get-XtremISCSIRoute
{
    
  <#
    .DESCRIPTION
    displays a specific iSCSI route and its parameters.
 
    .PARAMETER ISCSIRouteName
    ISCSI Route Index or name.
 
    .PARAMETER Properties
    Array of properties requested from this call.
 
    .PARAMETER ShowRest
    Return an object represents the REST operation including URI , Method and JSON
 
    .EXAMPLE
    Get-XtremISCSIRoute -ISCSIRouteName route
  #>

    
    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [Alias("Name", "Index")]
        [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)]
        $ISCSIRouteName,
        [Parameter()]
        [Alias("Properties")]
        [string[]]$Property,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest
    )
    
    $Route = '/types/iscsi-routes'
    $Route, $GetProperty = SetParametersForRequest $Route $ISCSIRouteName
    
    $result = NewXtremRequest -Method GET -endpoint $Route -Session $Session  -XtremClusterName $XtremClusterName -ObjectSelection $ObjectSelection -GetProperty $GetProperty -Properties $Property -ShowRest:$ShowRest.IsPresent

    $result = formatOutPut $Property $result

    return $result
}

Export-ModuleMember Get-XtremISCSIPortals
Export-ModuleMember Get-XtremISCSIPortal
Export-ModuleMember Remove-XtremISCSIPortal
Export-ModuleMember New-XtremISCSIPortal
Export-ModuleMember Get-XtremISCSIRoutes
Export-ModuleMember Get-XtremISCSIRoute