HPE StoreOnce PowerShell Module Version 2

Nach einer längeren Pause habe ich endlich wieder die Muse und Zeit gefunden an meinem HPE StoreOnce PowerShell Module Version 2 weiterzuarbeiten. Der Umstand, dass man mein StoreOnce Lab auf dem Laptop mitnehmen kann hat das enorm begünstigt.

Ziele der Version 2.0 meines Moduls waren:

  • Verbesserung der Verbindung zu der REST API
  • Löschen von allen Objekten die auch erstellt werden können
  • Pester Tests aller Funktionen
  • Dokumentation wie in dem Artikel von Chris Wahl beschrieben

Alle Features des HPE StoreOnce PowerShell Module Version 2 sind auf der Projekt Seite, auf Read The Docs oder direkt im GitHub Projekt zu finden.

Version 2.1:

Mehrere Nutzer haben mich auf ein Problem mit der StoreOnce Firmware 3.15.1 hingewiesen (Vielen Dank nochmal dafür!). HPE hat in dieser Version TLS 1.0 abgeschaltet, daher kam es zu Problemen bei den REST API Calls. Die Version 2.1 verwendet nun fix TLS 1.2.

Removal of TLS 1.0 support to comply with new Payment Card Industry standards: TLS 1.0 support has been removed from StoreOnce products. Any applications that use TLS 1.0 will not be able to communicate with the StoreOnce System unless they upgrade to a later, more secure version of TLS.

Siehe auch:
StoreOnce software revision 3.13.x to 3.15.1 (P9L02-10528) release notes

Download ist wieder über die PowerShell Gallery möglich:

PowerShell Gallery: PS-StoreOnce

 

Install-Module -Name PS-StoreOnce

StoreOnce PowerShell Module Version 2 – Neuerungen

Neben vielen kleinen Verbesserungen im Error Handling, der Ausgabe und der Dokumentation sind diese drei Punkte der Fokus der Version 2.0 gewesen.

Verbesserung der Verbindung zu der REST API

Als Vorbild habe ich mir da das grandiose PowervRO Modul von Jakku Labs oder besser gesagt Jonathan Medd und Craig G genommen. In dem Modul werden die verbindungsrelevanten Informationen in eine Globale Variable geschrieben. Ich habe dieses Vorgehen nur etwas aufgebohrt und ein Array daraus gemacht, um weiterhin mit mehreren HPE StoreOnce Systemen arbeiten zu können.

StoreOnce PowerShell Module Version 2 - Connect-SOAppliance Verbose

Auch die Abfrage der aktiven Verbindung sollte möglich sein:

StoreOnce PowerShell Module Version 2 - Get-SOAppliance

Löschen von allen Objekten die auch erstellt werden können

Das StoreOnce PowerShell Module Version 2 unterstützt weiterhin nur die Erstellung von Catalyst Stores und Clients, somit mussten im ersten Schritt auch nur die Funktionen für das Löschen der beiden Objekte erstellt werden.

Das war aber dennoch ein großer Schritt, da bisher nur GET und SET verwendet wurden, DELETE ist dann im Falle eines Fehlers doch wesentlich destruktiver.

StoreOnce PowerShell Module Version 2 - Remove-SOCatStore

StoreOnce PowerShell Module Version 2 - Remove-SOCatClient

Pester Tests aller Funktionen

Die Erstellung von Pester Tests für das Module wäre eigentlich schon lange fällig gewesen, aber mit dieser umfangreichen Veränderung in dem StoreOnce PowerShell Module Version 2 sind automatische Tests nun unerlässlich geworden.

StoreOnce PowerShell Module Version 2 - Petser Tests

Pester Tests im Detail

<#
    .EXAMPLE
    Invoke-Pester -Script @{ Path = '.\Tests\StoreOnceModule.Tests.ps1'; Parameters = @{ SOAppliance="192.168.130.129"; SOUser="Admin"; SOPass="admin"} }
#>

$SOAppliance = $Parameters.Get_Item("SOAppliance")
$SOUser = $Parameters.Get_Item("SOUser")
$SOPass = $Parameters.Get_Item("SOPass")

Describe "Module Tests" {

    $error.Clear()
    Remove-Module PS-StoreOnce -ErrorAction SilentlyContinue
    It "Importing PS-StoreOnce Module" {
        Import-Module ./PS-StoreOnce/PS-StoreOnce.psd1
	    Get-Module PS-StoreOnce | Should Be $true
    }
    It "Check errors" {
        $error.Count | should be 0
    }
    
}

Describe "Connect-SOAppliance Tests" {

    $error.Clear()
    Clear-Variable SOConnections -Scope Global -ErrorAction SilentlyContinue
    $connection = Connect-SOAppliance -Server $SOAppliance -Username $SOUser -Password $SOPass
    It "Connection exists" {
        ($Global:SOConnections).count | Should Be 1
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Get-SOAppliance Tests" {

    $error.Clear()
    It "Variable is correct" {
        (Get-SOAppliance).Server | Should Be $SOAppliance
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Get-SOSIDs Tests" {

    $error.Clear()
    It "System is correct" {
        (Get-SOSIDs).System | Should Be $SOAppliance
    }
    It "SIDCount is correct" {
        (Get-SOSIDs).SIDCount | Should BeGreaterThan 0 
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Get-SONasShares Tests" {

    $error.Clear()
    It "System is correct" {
        (Get-SONasShares).System | Should Be $SOAppliance
    }
    It "SIDCount is correct" {
        (Get-SONasShares).SIDCount | Should BeGreaterThan 0 
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Get-SOCatStores Tests" {

    $error.Clear()
    It "System is correct" {
        (Get-SOCatStores).System | Should Be $SOAppliance
    }
    It "SIDCount is correct" {
        (Get-SOCatStores).SIDCount | Should BeGreaterThan 0 
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Get-SOCatClients Tests" {

    $error.Clear()
    It "System is correct" {
        (Get-SOCatClients).System | Should Be $SOAppliance
    }
    It "SIDCount is correct" {
        (Get-SOCatClients).SIDCount | Should BeGreaterThan 0 
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Get-SOCatStoreAccess Tests" {

    $error.Clear()
    It "Client is correct" {
        (Get-SOCatStoreAccess -Server $SOAppliance -CatStore myNewStore).Client | Should Be "myNewClient"
    }
    It "allowAccess is correct" {
        (Get-SOCatStoreAccess -Server $SOAppliance -CatStore myNewStore).allowAccess | Should Be "true"
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "New-SOCatStore Tests" {

    $error.Clear()
    <#
    It "Create duplicate Store" {
        (New-SOCatStore -Server $SOAppliance -SSID 1 -SOCatStoreName MyNewStore ) | Should throw
    }
    #>
    It "Create new Catalyst Store" {
        (New-SOCatStore -Server $SOAppliance -SSID 1 -SOCatStoreName myPesterStore)
        (Get-SOCatStores | where {$_.Name -eq "myPesterStore" -and $_.System -eq $SOAppliance}).Status | Should be "Online"
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "New-SOCatClient Tests" {

    $error.Clear()
    <#
    It "Create duplicate Client" {
        (New-SOCatClient -Server $SOAppliance -SOCatClientName myTestClient -SOCatClientPass myTestClientpass!! ) | Should throw
    }
    #>
    It "Create new Client" {
        (New-SOCatClient -Server $SOAppliance -SOCatClientName myPesterClient -SOCatClientPass myPesterClientPas!!)
        (Get-SOCatClients | where {$_.Name -eq "myPesterClient" -and $_.System -eq $SOAppliance} ).Name | Should be "myPesterClient"
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Set-SOCatStoreAccess Tests" {

    $error.Clear()
    It "Set Access" {
        (Set-SOCatStoreAccess -Server $SOAppliance -SOCatClientName myPesterClient -SOCatStoreName myPesterStore -allowAccess:$true)
        (Get-SOCatStoreAccess -Server $SOAppliance -CatStore "myPesterStore").Client | Should be "myPesterClient"
    }
     It "Remove Access" {
        (Set-SOCatStoreAccess -Server $SOAppliance -SOCatClientName myPesterClient -SOCatStoreName myPesterStore -allowAccess:$false)
        (Get-SOCatStoreAccess -Server $SOAppliance -CatStore "myPesterStore").Client | Should not be "myPesterClient"
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Remove-SOCatStore Tests" {

    $error.Clear()
    It "Remove Catalyst Store" {
        (Remove-SOCatStore -Server $SOAppliance -SSID 1 -SOCatStoreName myPesterStore)
        (Get-SOCatStores | where {$_.Name -eq "myPesterStore" -and $_.System -eq $SOAppliance}) | Should not be "Online"
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

Describe "Remove-SOCatClient Tests" {

    $error.Clear()
    It "Remove Client" {
        (Remove-SOCatClient -Server $SOAppliance -SOCatClientName myPesterClient)
        (Get-SOCatClients | where {$_.Name -eq "myPesterClient" -and $_.System -eq $SOAppliance} ).Name | Should not be "myPesterClient"
    }
    It "Check errors" {
        $error.Count | should be 0
    }

}

 

One Response

  1. Markus Kraus 20. Februar 2017

Leave a Reply