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.
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.
Auch die Abfrage der aktiven Verbindung sollte möglich sein:
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.
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.
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 } }
Some user’s reported an issue with the StoreOnce Firmware 3.15.1.
At the moment I think the connection issue is caused by the removal of TLS 1.0:
See also:
https://h20566.www2.hpe.com/hpsc/doc/public/display?sp4ts.oid=5196525&docLocale=en_US&docId=emr_na-c05273928
I have created a modified version that uses only TLS 1.2:
https://github.com/mycloudrevolution/StoreOnce-PSModule/tree/TLS1.X
Please Note: This Version is in test status!
Further Testers are welcome.