Skip to content

Commit 03152d7

Browse files
committed
VCF module beta
VCF module beta
1 parent 98e6e9b commit 03152d7

File tree

5 files changed

+631
-231
lines changed

5 files changed

+631
-231
lines changed

PureStorage.FlashArray.VMware.Configuration/PureStorage.FlashArray.VMware.Configuration.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
NestedModules = @()
8383

8484
# Functions to export from this module
85-
FunctionsToExport = 'New-PfaRestOperation','New-PfaConnection','Get-PfaDatastore','Get-PfaConnectionOfDatastore','New-PfaRestSession','Remove-PfaRestSession','New-PfaHostFromVmHost','Get-PfaHostFromVmHost','Get-PfaHostGroupfromVcCluster','New-PfaHostGroupfromVcCluster','Set-VmHostPfaiSCSI','Set-ClusterPfaiSCSI','get-PfaConnectionFromArrayId','Initialize-PfaVcfWorkloadDomain'
85+
FunctionsToExport = 'New-PfaRestOperation','New-PfaConnection','Get-PfaDatastore','Get-PfaConnectionOfDatastore','New-PfaRestSession','Remove-PfaRestSession','New-PfaHostFromVmHost','Get-PfaHostFromVmHost','Get-PfaHostGroupfromVcCluster','New-PfaHostGroupfromVcCluster','Set-VmHostPfaiSCSI','Set-ClusterPfaiSCSI','get-PfaConnectionFromArrayId'
8686

8787
# Cmdlets to export from this module
8888
CmdletsToExport = '*'

PureStorage.FlashArray.VMware.Configuration/PureStorage.FlashArray.VMware.Configuration.psm1

Lines changed: 0 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,196 +1260,6 @@ function Set-ClusterPfaiSCSI {
12601260
return $allEsxiiSCSItargets
12611261
}
12621262
}
1263-
function Initialize-PfaVcfWorkloadDomain {
1264-
<#
1265-
.SYNOPSIS
1266-
Configures a workload domain for Pure Storage
1267-
.DESCRIPTION
1268-
Connects to each ESXi host, configures initiators on the FlashArray and provisions a VMFS. If something fails it will cleanup any changes.
1269-
.INPUTS
1270-
FQDNs or IPs of each host, valid credentials, a FlashArray connection, a datastore name and size.
1271-
.OUTPUTS
1272-
Returns host group.
1273-
.NOTES
1274-
Version: 2.0
1275-
Author: Cody Hosterman https://codyhosterman.com
1276-
Creation Date: 08/24/2020
1277-
Purpose/Change: Core support
1278-
.EXAMPLE
1279-
PS C:\ $faCreds = get-credential
1280-
PS C:\ New-PfaConnection -endpoint flasharray-m20-2 -credentials $faCreds -ignoreCertificateError -defaultArray
1281-
PS C:\ $creds = get-credential
1282-
PS C:\ Initialize-PfaVcfWorkloadDomain -esxiHosts "esxi-02.purecloud.com","esxi-04.purecloud.com" -credentials $creds -datastoreName "vcftest" -sizeInTB 16 -fc
1283-
1284-
Creates a host group and hosts and provisions a 16 TB VMFS to the hosts over FC
1285-
.EXAMPLE
1286-
PS C:\ $faCreds = get-credential
1287-
PS C:\ New-PfaConnection -endpoint flasharray-m20-2 -credentials $faCreds -ignoreCertificateError -defaultArray
1288-
PS C:\ $creds = get-credential
1289-
PS C:\ $allHosts = @()
1290-
PS C:\ Import-Csv C:\hostList.csv | ForEach-Object {$allHosts += $_.hostnames}
1291-
PS C:\ Initialize-PfaVcfWorkloadDomain -esxiHosts $allHosts -credentials $creds -datastoreName "vcftest" -sizeInTB 16 -fc
1292-
1293-
Creates a host group and hosts and provisions a 16 TB VMFS to the hosts over FC. This takes in a csv file of ESXi host FQDNs with one csv header called hostnames
1294-
1295-
*******Disclaimer:******************************************************
1296-
This scripts are offered "as is" with no warranty. While this
1297-
scripts is tested and working in my environment, it is recommended that you test
1298-
this script in a test lab before using in a production environment. Everyone can
1299-
use the scripts/commands provided here without any written permission but I
1300-
will not be liable for any damage or loss to the system.
1301-
************************************************************************
1302-
#>
1303-
1304-
[CmdletBinding()]
1305-
Param(
1306-
1307-
[Parameter(Position=0,mandatory=$true)]
1308-
[string[]]$EsxiHosts,
1309-
1310-
[Parameter(Position=1,ValueFromPipeline=$True,mandatory=$true)]
1311-
[System.Management.Automation.PSCredential]$Credentials,
1312-
1313-
[Parameter(Position=1,ValueFromPipeline=$True)]
1314-
[PurePowerShell.PureArray]$Flasharray,
1315-
1316-
[Parameter(Position=2,mandatory=$true)]
1317-
[string]$DatastoreName,
1318-
1319-
[Parameter(Position=3)]
1320-
[int]$SizeInGB,
1321-
1322-
[Parameter(Position=4)]
1323-
[int]$SizeInTB,
1324-
1325-
[Parameter(Position=5)]
1326-
[switch]$Fc
1327-
1328-
)
1329-
if ($fc -ne $true)
1330-
{
1331-
throw "Please indicate protocol type. Currently only -fc is a supported option."
1332-
}
1333-
$ErrorActionPreference = "stop"
1334-
if (($sizeInGB -eq 0) -and ($sizeInTB -eq 0))
1335-
{
1336-
throw "Please enter a size in GB or TB"
1337-
}
1338-
elseif (($sizeInGB -ne 0) -and ($sizeInTB -ne 0)) {
1339-
throw "Please only enter a size in TB or GB, not both."
1340-
}
1341-
elseif ($sizeInGB -ne 0) {
1342-
$volSize = $sizeInGB * 1024 *1024 *1024
1343-
}
1344-
else {
1345-
$volSize = $sizeInTB * 1024 *1024 *1024 * 1024
1346-
}
1347-
if ($null -eq $flasharray)
1348-
{
1349-
$flasharray = checkDefaultFlashArray
1350-
}
1351-
$esxiConnections = @()
1352-
for ($i =0;$i -lt $esxiHosts.count;$i++)
1353-
{
1354-
try {
1355-
$esxiConnections += connect-viserver -Server $esxiHosts[$i] -Credential ($Credentials) -ErrorAction Stop
1356-
}
1357-
catch
1358-
{
1359-
$scriptCleanupStep = 0
1360-
cleanup-pfaVcf
1361-
}
1362-
}
1363-
$faHosts = @()
1364-
for ($i =0;$i -lt $esxiConnections.count;$i++)
1365-
{
1366-
$foundHost = $null
1367-
try {
1368-
$foundHost = Get-PfaHostFromVmHost -esxi (get-vmhost $esxiConnections[$i].name)
1369-
if ($null -ne $foundHost)
1370-
{
1371-
if ($faHosts.count -ge 1)
1372-
{
1373-
$scriptCleanupStep = 1
1374-
}
1375-
else
1376-
{
1377-
$scriptCleanupStep = 6
1378-
}
1379-
$esxiName =$esxiConnections[$i].name
1380-
cleanup-pfaVcf
1381-
$newError = ("The host " + $esxiName + " already exists on the FlashArray. Ensure you entered the right host and/or array")
1382-
throw ""
1383-
}
1384-
}
1385-
catch {
1386-
if ($null -ne $newError)
1387-
{
1388-
throw $newError
1389-
}
1390-
}
1391-
try{
1392-
$faHosts += (New-PfaHostFromVmHost -esxi (get-vmhost $esxiConnections[$i].name) -FC:$fc -ErrorAction Stop).name
1393-
}
1394-
catch
1395-
{
1396-
$scriptCleanupStep = 1
1397-
cleanup-pfaVcf
1398-
throw $_.Exception
1399-
}
1400-
}
1401-
$groupName = ("vCF-WorkloadDomain-" + (get-random -Maximum 9999 -Minimum 1000))
1402-
try{
1403-
$hostGroup = New-PfaHostGroup -Array $flasharray -Hosts $fahosts -Name $groupName -ErrorAction Stop
1404-
}
1405-
catch
1406-
{
1407-
$scriptCleanupStep = 2
1408-
cleanup-pfaVcf
1409-
throw $_.Exception
1410-
}
1411-
try
1412-
{
1413-
$newVol = New-PfaVolume -Array $flasharray -Size $volSize -VolumeName $datastoreName -ErrorAction Stop
1414-
}
1415-
catch
1416-
{
1417-
$scriptCleanupStep = 3
1418-
cleanup-pfaVcf
1419-
throw $_.Exception
1420-
}
1421-
$Global:CurrentFlashArray = $flasharray
1422-
try
1423-
{
1424-
New-PfaHostGroupVolumeConnection -Array $flasharray -VolumeName $newVol.name -HostGroupName $groupName -ErrorAction Stop|Out-Null
1425-
}
1426-
catch
1427-
{
1428-
$scriptCleanupStep = 4
1429-
cleanup-pfaVcf
1430-
throw $_.Exception
1431-
}
1432-
$newNAA = "naa.624a9370" + $newVol.serial.toLower()
1433-
$esxi = $esxiConnections |Select-Object -Last 1
1434-
get-vmhost $esxi.name |Get-VMHostStorage -RescanAllHba |Out-Null
1435-
try
1436-
{
1437-
$newVMFS = get-vmhost $esxi.name |new-datastore -name $datastoreName -vmfs -Path $newNAA -FileSystemVersion 6 -ErrorAction Stop
1438-
}
1439-
catch
1440-
{
1441-
$scriptCleanupStep = 5
1442-
cleanup-pfaVcf
1443-
throw $_.Exception
1444-
}
1445-
foreach ($esxiConnection in $esxiConnections)
1446-
{
1447-
get-vmhost $esxiConnection.name | Get-VMHostStorage -RescanAllHba |Out-Null
1448-
}
1449-
$scriptCleanupStep = 7
1450-
cleanup-pfaVcf
1451-
return $hostGroup
1452-
}
14531263
function New-PfaRestOperation {
14541264
<#
14551265
.SYNOPSIS
@@ -1599,46 +1409,6 @@ New-Alias -Name Set-clusterPureFAiSCSI -Value Set-clusterPfaiSCSI
15991409

16001410

16011411
#### helper functions
1602-
function Cleanup-PfaVcf{
1603-
if ($scriptCleanupStep -lt 6)
1604-
{
1605-
if ($scriptCleanupStep -eq 5)
1606-
{
1607-
Remove-PfaHostGroupVolumeConnection -Array $flasharray -VolumeName $datastoreName -HostGroupName $groupName |Out-Null
1608-
}
1609-
if ($scriptCleanupStep -ge 4)
1610-
{
1611-
Remove-PfaVolumeOrSnapshot -Array $flasharray -Name $datastoreName |Out-Null
1612-
Remove-PfaVolumeOrSnapshot -Array $flasharray -Name $datastoreName -Eradicate |Out-Null
1613-
}
1614-
if ($scriptCleanupStep -ge 1)
1615-
{
1616-
foreach ($faHost in $faHosts)
1617-
{
1618-
Remove-PfaHost -Array $flasharray -Name $faHost |out-null
1619-
}
1620-
}
1621-
if ($scriptCleanupStep -ge 3)
1622-
{
1623-
remove-PfaHostGroup -Array $flasharray -Name $groupName |out-null
1624-
}
1625-
}
1626-
if ($scriptCleanupStep -ge 0)
1627-
{
1628-
if ($esxiConnections.count -eq 0)
1629-
{
1630-
return
1631-
}
1632-
else
1633-
{
1634-
foreach ($esxiConnection in $esxiConnections)
1635-
{
1636-
$esxiConnection | disconnect-viserver -confirm:$false |out-null
1637-
}
1638-
}
1639-
}
1640-
return
1641-
}
16421412
function checkDefaultFlashArray{
16431413
if ($null -eq $Global:DefaultFlashArray)
16441414
{
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<#
2+
===========================================================================
3+
Created with: VSCode
4+
Created by: Cody Hosterman
5+
Organization: Pure Storage, Inc.
6+
Filename: PureStorage.FlashArray.VMware.VCF.psd1
7+
Version: 2.0.0.0
8+
Copyright: 2020 Pure Storage, Inc.
9+
-------------------------------------------------------------------------
10+
Module Name: PureStorageFlashArrayVMwareVMFSPowerShell
11+
Disclaimer
12+
The sample script and documentation are provided AS IS and are not supported by
13+
the author or the author's employer, unless otherwise agreed in writing. You bear
14+
all risk relating to the use or performance of the sample script and documentation.
15+
The author and the author's employer disclaim all express or implied warranties
16+
(including, without limitation, any warranties of merchantability, title, infringement
17+
or fitness for a particular purpose). In no event shall the author, the author's employer
18+
or anyone else involved in the creation, production, or delivery of the scripts be liable
19+
for any damages whatsoever arising out of the use or performance of the sample script and
20+
documentation (including, without limitation, damages for loss of business profits,
21+
business interruption, loss of business information, or other pecuniary loss), even if
22+
such person has been advised of the possibility of such damages.
23+
===========================================================================
24+
#>
25+
26+
@{
27+
CompatiblePSEditions = @('Desktop', 'Core')
28+
# Script module or binary module file associated with this manifest.
29+
RootModule = 'PureStorage.FlashArray.VMware.VCF.psm1'
30+
31+
# Version number of this module; major.minor[.build[.revision]]
32+
ModuleVersion = '2.0.0.0'
33+
34+
# ID used to uniquely identify this module
35+
GUID = 'd722807a-d903-490a-a1d9-418fd8d90591'
36+
37+
# Author of this module
38+
Author = 'Pure Storage'
39+
40+
# Company or vendor of this module
41+
CompanyName = 'Pure Storage, Inc.'
42+
43+
# Copyright statement for this module
44+
Copyright = '(c) 2020 Pure Storage, Inc. All rights reserved.'
45+
46+
# Description of the functionality provided by this module
47+
Description = 'Pure Storage FlashArray VMware PowerShell VMFS management.'
48+
49+
# Minimum version of the Windows PowerShell engine required by this module
50+
PowerShellVersion = '5.1'
51+
52+
# Name of the Windows PowerShell host required by this module
53+
PowerShellHostName = ''
54+
55+
# Minimum version of the Windows PowerShell host required by this module
56+
PowerShellHostVersion = ''
57+
58+
# Minimum version of Microsoft .NET Framework required by this module
59+
DotNetFrameworkVersion = ''
60+
61+
# Minimum version of the common language runtime (CLR) required by this module
62+
CLRVersion = ''
63+
64+
# Modules that must be imported into the global environment prior to importing this module
65+
RequiredModules = @(
66+
@{"ModuleName"="PureStoragePowerShellSDK";"ModuleVersion"="1.13.1.12"}
67+
@{"ModuleName"="PureStorage.FlashArray.VMware.Configuration";"ModuleVersion"="2.0.0.0"}
68+
@{"ModuleName"="PowerVCF";"ModuleVersion"="2.1.0"}
69+
)
70+
71+
# Assemblies that must be loaded prior to importing this module
72+
RequiredAssemblies = @()
73+
74+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
75+
ScriptsToProcess = @()
76+
77+
# Type files (.ps1xml) to be loaded when importing this module
78+
TypesToProcess = @()
79+
80+
# Format files (.ps1xml) to be loaded when importing this module
81+
FormatsToProcess = @()
82+
83+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
84+
NestedModules = @()
85+
86+
# Functions to export from this module
87+
FunctionsToExport = 'Initialize-PfaVcfWorkloadDomain','Get-PfaVcfVasaProvider','New-PfaVcfVasaProvider'
88+
89+
# Cmdlets to export from this module
90+
CmdletsToExport = '*'
91+
92+
# Variables to export from this module
93+
VariablesToExport = ''
94+
95+
# Aliases to export from this module
96+
AliasesToExport = ''
97+
98+
# List of all modules packaged with this module
99+
ModuleList = @()
100+
101+
# List of all files packaged with this module
102+
FileList = @()
103+
104+
# Private data to pass to the module specified in ModuleToProcess
105+
PrivateData = @{
106+
107+
#Support for PowerShellGet galleries.
108+
PSData = @{
109+
110+
# Tags applied to this module. These help with module discovery in online galleries.
111+
# Tags = @()
112+
113+
# A URL to the license for this module.
114+
# LicenseUri = ''
115+
116+
# A URL to the main website for this project.
117+
# ProjectUri = ''
118+
119+
# A URL to an icon representing this module.
120+
# IconUri = ''
121+
122+
# ReleaseNotes of this module
123+
# ReleaseNotes = ''
124+
125+
}
126+
127+
}
128+
129+
# HelpInfo URI of this module
130+
HelpInfoURI = 'https://www.codyhosterman.com'
131+
132+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
133+
DefaultCommandPrefix = ''
134+
135+
}

0 commit comments

Comments
 (0)