Guest User

Untitled

a guest
Jun 3rd, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. $vmhost = 'esxi-01.domain.local'
  2. $vcenter = 'vcenter.domain.local'
  3. $vcenter_user = 'administrator@vsphere.local'
  4. # Save encrypted password to a file
  5. # Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File vcenter-password.txt
  6. $vcenter_password = Get-Content vcenter-password.txt | ConvertTo-SecureString
  7.  
  8. $nimble_mgmt_address = '10.1.1.1'
  9. $nimble_user = 'admin'
  10. # Save encrypted password to a file
  11. # Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File nimble-password.txt
  12. $nimble_password = Get-Content nimble-password.txt | ConvertTo-SecureString
  13.  
  14. $datastores = Import-Csv 'Nimble Datastores.csv'
  15. $initiator_group = 'VMware-ESXi-Hosts'
  16. $performance_policy = 'VMware ESX 5'
  17. $volumes = @()
  18.  
  19. # Connect to Nimble
  20. $nimble_creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $nimble_user, $nimble_password
  21. Connect-NSGroup -Group $nimble_mgmt_address -credential $nimble_creds | Out-Null
  22.  
  23. # Connect to vCenter
  24. if ($global:defaultviservers -eq $null) {
  25. $vcenter_creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $vcenter_user, $vcenter_password
  26. Write-Host "Connecting to $vcenter"
  27. Connect-VIServer -Server $vcenter -Credential $vcenter_creds
  28. }
  29.  
  30. # Create new volumes
  31. $initiator_group_id = Get-NSInitiatorGroup -Name $initiator_group | Select-Object -ExpandProperty Id
  32. $performance_policy_id = Get-NSPerformancePolicy -Name $performance_policy | Select-Object -ExpandProperty Id
  33. foreach ($ds in $datastores) {
  34. $volume = New-NSVolume -Name $ds.Name -Size $ds.Size -Multi_Initiator:$true -PerfPolicy_Id $performance_policy_id
  35. # Set access control record
  36. New-NSAccessControlRecord -Vol_Id $volume.id -Initiator_Group_Id $initiator_group_id | Out-Null
  37. $volumes += $volume
  38. }
  39.  
  40. # Create new datastores
  41. Get-VMHostStorage -VMHost $vmhost -RescanAllHba
  42. foreach ($v in $volumes) {
  43. $canonical_name = "eui.$($v.serial_number)"
  44. New-Datastore -Name $v.Name -Path $canonical_name -Vmfs -VMHost $vmhost
  45. }
Add Comment
Please, Sign In to add comment