Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###########################################################################################################################
- # Cisco UCS automated Configuration and Provisioning Script Version 0.9 #
- # #
- # Planned Enhancements
- # * Add FC Trunking #
- # * Chassis acknowledge after discovery #
- # * After successful UCSC registration - change from Local to Global Policies #
- # * Check status of FC/Uplink PO - bounce and wait #
- # * Disable unused FC uplinks
- # Global Profile
- # * Create Template ( create sp with below ) #
- # * Assign Scrub-Policy
- # * Host-Frimware Package
- # * ESXI bare metal
- #
- # Apply Scrub Policy - REboot - Unapply Scrub-Policy
- # zzScrubPolicy
- ###########################################################################################################################
- Param (
- [Parameter(Mandatory=$True,Position=0,ValueFromPipelineByPropertyName=$True)][alias("ucsvip")][String]$UCS_Fabric_Interconnect_NAME,
- [Parameter(Mandatory=$True,Position=1,ValueFromPipelineByPropertyName=$True)][alias("ucscip")][String]$UCS_Central_IP,
- [Parameter(Mandatory=$True,Position=2,ValueFromPipelineByPropertyName=$True)][alias("fitype")][String]$hfi_hfi3_dfi_mfi,
- #[Parameter(Mandatory=$True,Position=3,ValueFromPipelineByPropertyName=$True)][alias("sertype")][String]$chassis_cseries_ignored,
- [Parameter(Mandatory=$True,Position=4,ValueFromPipelineByPropertyName=$True)][alias("notype")][Int]$no_chassis_or_cseries,
- [Parameter(Mandatory=$True,Position=5,ValueFromPipelineByPropertyName=$True)][alias("usr")][String]$ucsadmin,
- [Parameter(Mandatory=$True)][Security.SecureString]$ucspsswd,
- [Parameter(Mandatory=$True)][Security.SecureString]$UCS_Central_Shared_Secret
- )
- #######################
- # Input variables here#
- #######################
- #Convert User Friendly Variables to Easy-To-Type
- $ucsvip = $UCS_Fabric_Interconnect_NAME
- $ucscip = $UCS_Central_IP
- $ucscpsswd = $UCS_Central_Shared_Secret
- $fitype = $hfi_hfi3_dfi_mfi
- $sertype = $chassis_cseries_ignored
- $notype = $no_chassis_or_cseries
- #Convert Fi Type to Server Ports
- if($fitype -eq "mfi") {$noports = 1}
- elseif ($fitype -eq "hfi3") {$noports = 2}
- else {$noports = 4}
- #DNS + NTP Values // Required for UCS Central
- $dns1 = "10.98.14.253"
- $dns2 = "10.98.14.254"
- $ntp1 = "45.42.35.183"
- $ntp2 = "ntp01.epichosted.com"
- $timezone = "America/Chicago"
- #Total No of FC ports Configured per FI
- if ($fitype -eq "hfi3") {$maxfc = 10}
- else {$maxfc = 8}
- #Total No of Uplink ports Configured per FI
- $maxup = 4
- #Uplink PortChannel Settings
- $uplinkpo_a = 71
- $uplinkpo_b = 72
- $uplinkponm_a = ""
- $uplinkponm_b = ""
- #SAN PortChannel Settings
- $fcpo_ah = 51
- $fcpo_ac = 53
- $fcpo_bh = 52
- $fcpo_bc = 54
- $fcpo_acname = "Clarity_fcpoA"
- $fcpo_ahname = "NonClarity_fcpoA"
- $fcpo_bcname = "Clarity_fcpoB"
- $fcpo_bhname = "NonClarity_fcpoB"
- #######################################################
- # Function Configure Fabric Interconnect Server Ports #
- #######################################################
- function ConfigureServerPorts ($noports, $notype){
- $portstart = 1
- for($i=0; $i -lt $notype; $i++){
- Start-UcsTransaction
- for($j=0; $j -lt $noports; $j++){
- $goserv_a = Get-UcsFabricServerCloud -Id A | Add-UcsServerPort -AdminState enabled -PortId $portstart -SlotId 1
- $goserv_b = Get-UcsFabricServerCloud -Id B | Add-UcsServerPort -AdminState enabled -PortId $portstart -SlotId 1
- $portstart++
- }
- Complete-UcsTransaction
- }
- }
- #######################################################
- # Function Configure Fabric Interconnect Eth Up #
- #######################################################
- function ConfigureUplinkPorts ($fitype, $maxup){
- if($fitype -eq "hfi"){
- $slotvar = 1
- $portstart = 48
- }
- else{
- $slotvar = 2
- $portstart = 8
- }
- Start-UcsTransaction
- for($j=0; $j -lt $maxup; $j++){
- $golan_a = Get-UcsFiLanCloud -Id A | Add-UcsUplinkPort -ModifyPresent -AdminState disabled -SlotId $slotvar -PortId $portstart -UsrLbl "Uplink Port"
- $golan_b = Get-UcsFiLanCloud -Id B | Add-UcsUplinkPort -ModifyPresent -AdminState disabled -SlotId $slotvar -PortId $portstart -UsrLbl "Uplink Port"
- $portstart--
- }
- Complete-UcsTransaction
- }
- #######################################################
- # Function Configure Fabric Interconnect Up PO #
- #######################################################
- function ConfigureUplinkPortChannel ($fitype, $maxup){
- if($fitype -eq "hfi"){
- $slotvar = 1
- $portstart = 48
- }
- else{
- $slotvar = 2
- $portstart = 8
- }
- Start-UcsTransaction
- $gopo_a = Get-UcsFiLanCloud -Id A | Add-UcsUplinkPortChannel -AdminState disabled -Name $uplinkponm_a -PortId $uplinkpo_a
- $gopo_b = Get-UcsFiLanCloud -Id B | Add-UcsUplinkPortChannel -AdminState disabled -Name $uplinkponm_a -PortId $uplinkpo_b
- for($j=0; $j -lt $maxup; $j++){
- $gopo_a | Add-UcsUplinkPortChannelMember -ModifyPresent -AdminState enabled -PortId $portstart -SlotId $slotvar
- $gopo_b | Add-UcsUplinkPortChannelMember -ModifyPresent -AdminState enabled -PortId $portstart -SlotId $slotvar
- $portstart--
- }
- Complete-UcsTransaction
- }
- #######################################################
- # Function Configure Fabric Interconnect UP to FC #
- #######################################################
- function ConfigureUnifiedPorts ($fitype, $maxfc){
- if($fitype -eq "hfi"){ $slotvar = 4 }
- else { $slotvar = 2 }
- $portstart = 16
- Start-UcsTransaction
- for($j=0; $j -lt $maxfc; $j++){
- $gosan_a = Get-UcsFiSanCloud -Id A | Add-UcsFcUplinkPort -ModifyPresent -AdminState enabled -SlotId $slotvar -PortId $portstart
- $gosan_b = Get-UcsFiSanCloud -Id B | Add-UcsFcUplinkPort -ModifyPresent -AdminState enabled -SlotId $slotvar -PortId $portstart
- $portstart--
- }
- Complete-UcsTransaction
- }
- #######################################################
- # Function Configure Fabric Interconnect FC PO #
- #######################################################
- function ConfigureFCPortChannel ($fitype){
- if($fitype -eq "hfi"){
- $slotvar = 4
- $maxfcpo = 2
- $portstart = 16
- $portstart = ExecuteFCPortChannel $maxfcpo $portstart $slotvar $fcpo_ahname $fcpo_bhname $fcpo_ah $fcpo_bh
- #Function returns array of executed functions and then final value. This sets to that final value
- $portstart = $portstart[-1]
- ExecuteFCPortChannel $maxfcpo $portstart $slotvar $fcpo_acname $fcpo_bcname $fcpo_ac $fcpo_bc
- }
- elseif($fitype -eq "mfi"){
- $slotvar = 2
- $maxfcpo = 4
- $portstart = 16
- ExecuteFCPortChannel $maxfcpo $portstart $slotvar $fcpo_ahname $fcpo_bhname $fcpo_ah $fcpo_bh
- }
- elseif($fitype -eq "dfi"){
- $slotvar = 2
- $maxfcpo = 2
- $portstart = 16
- ExecuteFCPortChannel $maxfcpo $portstart $slotvar $fcpo_ahname $fcpo_bhname $fcpo_ah $fcpo_bh
- }
- else{}
- }
- #######################################################
- # Function Execute Fabric Interconnect FC PO #
- #######################################################
- function ExecuteFCPortChannel ($maxfcpo, $portstart, $slotvar, $fcpo_aname, $fcpo_bname, $fcpo_a, $fcpo_b){
- Start-UcsTransaction
- $gosanpo_a = Get-UcsFiSanCloud -Id A | Add-UcsFcUplinkPortChannel -AdminSpeed auto -AdminState disabled -Name $fcpo_aname -PortId $fcpo_a
- $gosanpo_b = Get-UcsFiSanCloud -Id B | Add-UcsFcUplinkPortChannel -AdminSpeed auto -AdminState disabled -Name $fcpo_bname -PortId $fcpo_b
- for($j=0; $j -lt $maxfcpo; $j++){
- $gosanpo_a | Add-UcsFabricFcSanPcEp -ModifyPresent -AdminState enabled -SlotId $slotvar -PortId $portstart
- $gosanpo_b | Add-UcsFabricFcSanPcEp -ModifyPresent -AdminState enabled -SlotId $slotvar -PortId $portstart
- $portstart--
- }
- Complete-UcsTransaction
- Start-UcsTransaction
- $gosanpo_a = Get-UcsFiSanCloud -Id A | Get-UcsFcUplinkPortChannel -Name $fcpo_aname | Set-UcsFcUplinkPortChannel -AdminState enabled -Force
- $gosanpo_b = Get-UcsFiSanCloud -Id B | Get-UcsFcUplinkPortChannel -Name $fcpo_bname | Set-UcsFcUplinkPortChannel -AdminState enabled -Force
- Complete-UcsTransaction
- $portstart
- }
- ######################################
- # Function Configure QoS Class #
- ######################################
- function ConfigureQOSClass {
- Start-UcsTransaction
- Get-UcsQosClass -priority "platinum" | Set-UcsQosClass -mtu 9000 -AdminState disabled -Force
- Get-UcsQosClass -priority "gold" | Set-UcsQosClass -Weight 2 -mtu 9000 -AdminState enabled -Force
- Get-UcsQosClass -priority "silver" | Set-UcsQosClass -Weight "best-effort" -mtu 9000 -AdminState enabled -Force
- Get-UcsQosClass -priority "bronze" | Set-UcsQosClass -Weight "best-effort" -mtu 9000 -AdminState enabled -Force
- Set-UcsBestEffortQosClass -Weight 2 -mtu 9000 -Force
- Set-UcsFcQosClass -Weight 4 -Force
- Complete-UcsTransaction
- }
- ##########################################
- # Function Configure MISC Settings #
- ##########################################
- function ConfigureMISCSettings {
- # Set Global System Policies for chassis discovery and power #
- Get-UcsChassisDiscoveryPolicy | Set-UcsChassisDiscoveryPolicy -Action 4-link -LinkAggregationPref port-channel -Rebalance user-acknowledged -Force
- Get-UcsPowerControlPolicy | Set-UcsPowerControlPolicy -Redundancy grid -Force
- # Create maintenance policy #
- Get-UcsOrg -Level root | Add-UcsMaintenancePolicy -Descr "User acknowledge is required to reboot a server after a disruptive change" -Name user-acknowledge -UptimeDisr user-ack
- # Set UCS Admin Settings #
- Get-UcsNativeAuth | Set-UcsNativeAuth -ConLogin local -DefLogin local -DefRolePolicy no-login -Force
- Add-UcsDnsServer -Name $dns1
- Add-UcsDnsServer -Name $dns2
- Set-UcsTimezone -Timezone $timezone -Force
- Add-UcsNtpServer -Name $ntp1
- Add-UcsNtpServer -Name $ntp2
- }
- #############################
- # (Y) Add to UCS Central #
- #############################
- function RegisterUCSC {
- #$password = $ucscpsswd | ConvertTo-SecureString -AsPlainText -Force
- Register-UcsCentral -Name $ucscip -SharedSecret $ucscpsswd
- }
- #########################################
- # Import the Cisco UCS PowerTool module #
- #########################################
- Import-Module CiscoUcsPS
- ############################################
- # Authenticate to UCSM with the admin user #
- ############################################
- $user = $ucsadmin
- $password = $ucspsswd
- $cred = New-Object system.Management.automation.PSCredential($user, $password)
- # Clear out Connected UCS Domains
- Disconnect-Ucs
- $handle1 = Connect-Ucs -Name $ucsvip -Credential $cred
- #Verify Connection to UCS Manager
- $connected = Get-UcsPSSession
- if ($connected -eq $null) {
- WriteLog "Error connecting to UCS Manager!"
- Return
- }
- ConfigureServerPorts $noports $notype
- ConfigureUplinkPorts $fitype $maxup
- ConfigureUplinkPortChannel $fitype $maxup
- ConfigureUnifiedPorts $fitype $maxfc
- #EnableFCTrunking
- ConfigureFCPortChannel $fitype
- ConfigureQOSClass
- ConfigureMISCSettings
- RegisterUCSC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement