classes/HostSystem.ps1
class VexaHostSystem { [string] $Id [string] $Name [string] $Parent [bool] $VmotionEnabled [bool] $FaultToleranceEnabled [string] $Version [string] $Build [VexaHostSystemNetworkAdapter[]] $NetworkAdapter = [VexaHostSystemNetworkAdapter]::new() [VexaHostSystemStorageAdapter[]] $StorageAdapter = [VexaHostSystemStorageAdapter]::new() [VexaHostSystemServices] $ServiceStatus = [VexaHostSystemServices]::new() [VexaHostSystemAdvSettings] $AdvancedSettings = [VexaHostSystemAdvSettings]::new() VexaHostSystem() {} VexaHostSystem($View) { if ($View.GetType().Name -eq "HostSystem" ) { # Construct class using PowerCLI Get-View data $this.Id = $View.MoRef $this.VmotionEnabled = $View.Summary.Config.VmotionEnabled $this.FaultToleranceEnabled = $View.Summary.Config.FaultToleranceEnabled $this.Version = $View.Summary.Config.Product.Version $this.Build = $View.Summary.Config.Product.Build $SwitchList = $View.Config.Network.Vswitch + $View.Config.Network.ProxySwitch $this.NetworkAdapter = foreach ($Pnic in $View.Config.Network.Pnic) { $VexaPnic = [VexaHostSystemNetworkAdapter]::new($Pnic) $SwitchObj = $SwitchList.Where({$Pnic.Key -in $_.Pnic}) if (-not ($null -eq $SwitchObj) -and ($SwitchObj.DvsName)) { $VexaPnic.Switch = $SwitchObj.DvsName } else { $VexaPnic.Switch = $SwitchObj.Name } $VexaPnic } $this.StorageAdapter = foreach ($Hba in $View.Config.StorageDevice.HostBusAdapter) { switch ($Hba.GetType().Name) { "HostBlockHba" {[VexaHostSystemStorageAdapter]::new($Hba)} "HostParallelScsiHba" {[VexaHostSystemStorageAdapter]::new($Hba)} "HostInternetScsiHba" {[VexaHostSystemStorageAdapter]::new($Hba)} "HostFibreChannelHba" {[VexaHostFibreChannelHba]::new($Hba)} "HostSerialAttachedHba" {[VexaHostSerialAttachedHba]::new($Hba)} } } $this.ServiceStatus = [VexaHostSystemServices]::new($View) $this.AdvancedSettings = [VexaHostSystemAdvSettings]::new($View) } else { # Reserialize object from Import-Clixml data $this.Id = $View.Id $this.VmotionEnabled = $View.VmotionEnabled $this.FaultToleranceEnabled = $View.FaultToleranceEnabled $this.Version = $View.Version $this.Build = $View.Build $this.NetworkAdapter = foreach ($Pnic in $View.NetworkAdapter) { [VexaHostSystemNetworkAdapter]::new($Pnic) } $this.StorageAdapter = foreach ($Hba in $View.StorageAdapter) { switch ($Hba.VexaType) { "HostBlockHba" {[VexaHostSystemStorageAdapter]::new($Hba)} "HostParallelScsiHba" {[VexaHostSystemStorageAdapter]::new($Hba)} "HostInternetScsiHba" {[VexaHostSystemStorageAdapter]::new($Hba)} "HostFibreChannelHba" {[VexaHostFibreChannelHba]::new($Hba)} "HostSerialAttachedHba" {[VexaHostSerialAttachedHba]::new($Hba)} } } $this.ServiceStatus = [VexaHostSystemServices]::new($View.ServiceStatus) $this.AdvancedSettings = [VexaHostSystemAdvSettings]::new($View.AdvancedSettings) } $this.Name = $View.Name $this.Parent = $View.Parent } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") -and -not ($_.Name -eq "AdvancedSettings") -and -not ($_.Name -eq "ServiceStatus") -and -not ($_.Name -eq "StorageAdapter") -and -not ($_.Name -eq "NetworkAdapter") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } class VexaHostSystemNetworkAdapter { hidden [string] $VexaType = "HostSystemNetworkAdapter" [string] $Device [string] $Pci [string] $Mac [int] $ActualSpeedMb [int] $ConfiguredSpeedMb [string] $Switch VexaHostSystemNetworkAdapter() {} VexaHostSystemNetworkAdapter($Pnic) { $this.Device = $Pnic.Device $this.Pci = $Pnic.Pci $this.Mac = $Pnic.Mac if ($Pnic.VexaType) { $this.ActualSpeedMb = $Pnic.ActualSpeedMb $this.ConfiguredSpeedMb = $Pnic.ConfiguredSpeedMb $this.Switch = $Pnic.Switch } else { $this.ActualSpeedMb = $Pnic.LinkSpeed.SpeedMb $this.ConfiguredSpeedMb = $Pnic.Spec.LinkSpeed.SpeedMb } } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } class VexaHostSystemStorageAdapter { hidden [string] $VexaType = "HostSystemStorageAdapter" [int] $Bus [string] $Device [string] $Driver [string] $Model [string] $Pci [string] $Status VexaHostSystemStorageAdapter() {} VexaHostSystemStorageAdapter($Hba) { $this.Bus = $Hba.Bus $this.Device = $Hba.Device $this.Driver = $Hba.Driver $this.Model = $Hba.Model $this.Pci = $Hba.Pci $this.Status = $Hba.Status } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } class VexaHostFibreChannelHba : VexaHostSystemStorageAdapter { hidden [string] $VexaType = "HostFibreChannelHba" [bigint] $NodeWorldWideName [bigint] $PortWorldWideName [bigint] $Speed VexaHostFibreChannelHba() {} VexaHostFibreChannelHba($Hba) : base($Hba) { $this.NodeWorldWideName = $Hba.NodeWorldWideName.ToString() $this.PortWorldWideName = $Hba.PortWorldWideName.ToString() $this.Speed = $Hba.Speed.ToString() } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } class VexaHostSerialAttachedHba : VexaHostSystemStorageAdapter { hidden [string] $VexaType = "HostSerialAttachedHba" [string] $NodeWorldWideName VexaHostSerialAttachedHba() {} VexaHostSerialAttachedHba($Hba) : base($Hba) { $this.NodeWorldWideName = $Hba.NodeWorldWideName } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } class VexaHostSystemServices { [bool] $DCUI [bool] $TSM [bool] $TSM_SSH [bool] $lbtd [bool] $lwsmd [bool] $ntpd [bool] $pcscd [bool] $sfcbd_watchdog [bool] $snmpd [bool] $vmsyslogd [bool] $vmware_fdm [bool] $vprobed [bool] $vpxa [bool] $xorg VexaHostSystemServices() {} VexaHostSystemServices($View) { if ($View.Config.Service.Service) { # Construct class using PowerCLI Get-View data $Lookup = @{} $View.Config.Service.Service.ForEach({$Lookup.$($_.Key) = $_.Running}) $this.DCUI = $Lookup.DCUI $this.TSM = $Lookup.TSM $this.TSM_SSH = $Lookup."TSM-SSH" $this.lbtd = $Lookup.lbtd $this.lwsmd = $Lookup.lwsmd $this.ntpd = $Lookup.ntpd $this.pcscd = $Lookup.pcscd $this.sfcbd_watchdog = $Lookup."sfcbd-watchdog" $this.snmpd = $Lookup.snmpd $this.vmsyslogd = $Lookup.vmsyslogd $this.vmware_fdm = $Lookup."vmware-fdm" $this.vprobed = $Lookup.vprobed $this.vpxa = $Lookup.vpxa $this.xorg = $Lookup.xorg } else { # Reserialize object from Import-Clixml data $this.DCUI = $View.DCUI $this.TSM = $View.TSM $this.TSM_SSH = $View.TSM_SSH $this.lbtd = $View.lbtd $this.lwsmd = $View.lwsmd $this.ntpd = $View.ntpd $this.pcscd = $View.pcscd $this.sfcbd_watchdog = $View.sfcbd_watchdog $this.snmpd = $View.snmpd $this.vmsyslogd = $View.vmsyslogd $this.vmware_fdm = $View.vmware_fdm $this.vprobed = $View.vprobed $this.vpxa = $View.vpxa $this.xorg = $View.xorg } } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } class VexaHostSystemAdvSettings { [int] $Security_AccountLockFailures [int] $Security_AccountUnlockTime [string] $DCUI_Access [int] $UserVars_DcuiTimeOut [string] $UserVars_ESXiRhttpproxyDisabledProtocols [int] $UserVars_ESXiShellInteractiveTimeOut [int] $UserVars_ESXiShellTimeOut [string] $UserVars_ESXiVPsDisabledProtocols [int] $UserVars_SuppressCoredumpWarning [int] $UserVars_SuppressHyperthreadWarning [int] $UserVars_HostClientCEIPOptIn [int] $UserVars_SuppressShellWarning VexaHostSystemAdvSettings() {} VexaHostSystemAdvSettings($View) { if ($View.Config.Option) { # Construct class using PowerCLI Get-View data $Lookup = @{} $View.Config.Option.GetEnumerator().ForEach({$Lookup.$($_.Key) = $_.Value}) $this.Security_AccountLockFailures = $Lookup."Security.AccountLockFailures" $this.Security_AccountUnlockTime = $Lookup."Security.AccountUnlockTime" $this.DCUI_Access = $Lookup."DCUI.Access" $this.UserVars_DcuiTimeOut = $Lookup."UserVars.DcuiTimeout" $this.UserVars_ESXiRhttpproxyDisabledProtocols = $Lookup."UserVars.ESXiRhttpproxyDisabledProtocols" $this.UserVars_ESXiShellInteractiveTimeOut = $Lookup."UserVars.ESXiShellInteractiveTimeOut" $this.UserVars_ESXiShellTimeOut = $Lookup."UserVars.ESXiShellTimeOut" $this.UserVars_ESXiVPsDisabledProtocols = $Lookup."UserVars.ESXiVPsDisabledProtocols" $this.UserVars_SuppressCoredumpWarning = $Lookup."UserVars.SuppressCoredumpWarning" $this.UserVars_SuppressHyperthreadWarning = $Lookup."UserVars.SuppressHyperthreadWarning" $this.UserVars_HostClientCEIPOptIn = $Lookup."UserVars.HostClientCEIPOptIn" $this.UserVars_SuppressShellWarning = $Lookup."UserVars.SuppressShellWarning" } else { # Reserialize object from Import-Clixml data $this.Security_AccountLockFailures = $View.Security_AccountLockFailures $this.Security_AccountUnlockTime = $View.Security_AccountUnlockTime $this.DCUI_Access = $View.DCUI_Access $this.UserVars_DcuiTimeOut = $View.UserVars_DcuiTimeout $this.UserVars_ESXiRhttpproxyDisabledProtocols = $View.UserVars_ESXiRhttpproxyDisabledProtocols $this.UserVars_ESXiShellInteractiveTimeOut = $View.UserVars_ESXiShellInteractiveTimeOut $this.UserVars_ESXiShellTimeOut = $View.UserVars_ESXiShellTimeOut $this.UserVars_ESXiVPsDisabledProtocols = $View.UserVars_ESXiVPsDisabledProtocols $this.UserVars_SuppressCoredumpWarning = $View.UserVars_SuppressCoredumpWarning $this.UserVars_SuppressHyperthreadWarning = $View.UserVars_SuppressHyperthreadWarning $this.UserVars_HostClientCEIPOptIn = $View.UserVars_HostClientCEIPOptIn $this.UserVars_SuppressShellWarning = $View.UserVars_SuppressShellWarning } } [array] GetArrayToCompare() { $Items = $this.PSObject.Properties.Where({ ($_.MemberType -eq "Property") }) return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}}) } } |