Skip to content

Commit aad1665

Browse files
committed
Adding profile template script to update san volume targets to manual
Signed-off-by: Chris Lynch <chris.lynch@hpe.com>
1 parent 0d6f2e8 commit aad1665

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Script to change the SAN storage ports from Auto to specific TargetPorts within a server profile template.
2+
# Script assumes two FC connections, and the FC connections are named.
3+
4+
# Specify the new target ports needed, per connection
5+
$FCConnection1TargetPortWWIDs = "20:23:00:02:AC:01:BD:6B", "21:23:00:02:AC:01:BD:6B"
6+
$FCConnection2TargetPortWWIDs = "22:24:00:02:AC:01:BD:6B", "23:24:00:02:AC:01:BD:6B"
7+
$FCConnect1Name = "SAN_A"
8+
$FCConnect2Name = "SAN_B"
9+
10+
$SPT = Get-HPOVServerProfileTemplate -Name "My SPT Name"
11+
12+
# Make a backup
13+
$SptToUpdate = $SPT.PSObject.Copy()
14+
15+
# Figure out FC connection ID's
16+
$Connection1 = $SptToUpdate.connectionSettings.connections | ? { $_.functionType -eq 'FibreChannel' -and $_.name -eq $FCConnect1Name }
17+
$Connection2 = $SptToUpdate.connectionSettings.connections | ? { $_.functionType -eq 'FibreChannel' -and $_.name -eq $FCConnect2Name }
18+
19+
# Update all first connection paths
20+
$SptToUpdate.sanStorage.volumeAttachments | ForEach-Object {
21+
22+
($_.storagePaths | ? connectionId -eq $Connection1.id) | Add-Member -NotePropertyName targetSelector -NotePropertyValue 'TargetPorts' -Force
23+
($_.storagePaths | ? connectionId -eq $Connection1.id) | Add-Member -NotePropertyName targets -NotePropertyValue @()
24+
25+
ForEach ($TargetWWID in $FCConnection1TargetPortWWIDs)
26+
{
27+
28+
$_.storagePaths.targets += @{name = $TargetWWID }
29+
30+
}
31+
32+
}
33+
34+
# Update all second connection paths
35+
$SptToUpdate.sanStorage.volumeAttachments | ForEach-Object {
36+
37+
($_.storagePaths | ? connectionId -eq $Connection2.id) | Add-Member -NotePropertyName targetSelector -NotePropertyValue 'TargetPorts' -Force
38+
($_.storagePaths | ? connectionId -eq $Connection2.id) | Add-Member -NotePropertyName targets -NotePropertyValue @()
39+
40+
ForEach ($TargetWWID in $FCConnection2TargetPortWWIDs)
41+
{
42+
43+
$_.storagePaths.targets += @{name = $TargetWWID }
44+
45+
}
46+
47+
}
48+
49+
Save-HPOVServerProfileTemplate -InputObject $SptToUpdate
50+
51+
## Uncomment below to restore the original SPT
52+
# $SPT.eTag = '*/*'
53+
# Save-HPOVServerProfileTemplate -InputObject $SPT

0 commit comments

Comments
 (0)