github.com/vmware/govmomi@v0.51.0/simulator/host_storage_system.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package simulator 6 7 import ( 8 "github.com/vmware/govmomi/simulator/esx" 9 "github.com/vmware/govmomi/vim25/methods" 10 "github.com/vmware/govmomi/vim25/mo" 11 "github.com/vmware/govmomi/vim25/soap" 12 "github.com/vmware/govmomi/vim25/types" 13 ) 14 15 type HostStorageSystem struct { 16 mo.HostStorageSystem 17 18 Host *mo.HostSystem 19 HBA []types.BaseHostHostBusAdapter 20 } 21 22 func NewHostStorageSystem(h *mo.HostSystem) *HostStorageSystem { 23 s := &HostStorageSystem{Host: h} 24 25 s.StorageDeviceInfo = &esx.HostStorageDeviceInfo 26 27 s.HBA = fibreChannelHBA 28 29 return s 30 } 31 32 // RescanAllHba swaps HostStorageSystem.HBA and StorageDeviceInfo.HostBusAdapter. 33 // This allows testing HBA with and without Fibre Channel data. 34 func (s *HostStorageSystem) RescanAllHba(ctx *Context, _ *types.RescanAllHba) soap.HasFault { 35 hba := s.StorageDeviceInfo.HostBusAdapter 36 s.StorageDeviceInfo.HostBusAdapter = s.HBA 37 s.HBA = hba 38 39 ctx.WithLock(s.Host, func() { 40 s.Host.Config.StorageDevice.HostBusAdapter = s.StorageDeviceInfo.HostBusAdapter 41 }) 42 43 return &methods.RescanAllHbaBody{ 44 Res: new(types.RescanAllHbaResponse), 45 } 46 } 47 48 func (s *HostStorageSystem) RescanVmfs(*Context, *types.RescanVmfs) soap.HasFault { 49 return &methods.RescanVmfsBody{Res: new(types.RescanVmfsResponse)} 50 } 51 52 func (s *HostStorageSystem) RefreshStorageSystem(*Context, *types.RefreshStorageSystem) soap.HasFault { 53 return &methods.RefreshStorageSystemBody{Res: new(types.RefreshStorageSystemResponse)} 54 } 55 56 // HBA with FibreChannel data, see RescanAllHba() 57 var fibreChannelHBA = []types.BaseHostHostBusAdapter{ 58 &types.HostBlockHba{ 59 HostHostBusAdapter: types.HostHostBusAdapter{ 60 Key: "key-vim.host.BlockHba-vmhba0", 61 Device: "vmhba0", 62 Bus: 0, 63 Status: "unknown", 64 Model: "Lewisburg SATA AHCI Controller", 65 Driver: "vmw_ahci", 66 Pci: "0000:00:11.5", 67 }, 68 }, 69 &types.HostBlockHba{ 70 HostHostBusAdapter: types.HostHostBusAdapter{ 71 Key: "key-vim.host.BlockHba-vmhba1", 72 Device: "vmhba1", 73 Bus: 0, 74 Status: "unknown", 75 Model: "Lewisburg SATA AHCI Controller", 76 Driver: "vmw_ahci", 77 Pci: "0000:00:17.0", 78 }, 79 }, 80 &types.HostFibreChannelHba{ 81 HostHostBusAdapter: types.HostHostBusAdapter{ 82 Key: "key-vim.host.FibreChannelHba-vmhba2", 83 Device: "vmhba2", 84 Bus: 59, 85 Status: "online", 86 Model: "Emulex LightPulse LPe32000 PCIe Fibre Channel Adapter", 87 Driver: "lpfc", 88 Pci: "0000:3b:00.0", 89 }, 90 PortWorldWideName: 1152922127287604726, 91 NodeWorldWideName: 2305843631894451702, 92 PortType: "unknown", 93 Speed: 16, 94 }, 95 &types.HostFibreChannelHba{ 96 HostHostBusAdapter: types.HostHostBusAdapter{ 97 Key: "key-vim.host.FibreChannelHba-vmhba3", 98 Device: "vmhba3", 99 Bus: 95, 100 Status: "online", 101 Model: "Emulex LightPulse LPe32000 PCIe Fibre Channel Adapter", 102 Driver: "lpfc", 103 Pci: "0000:5f:00.0", 104 }, 105 PortWorldWideName: 1152922127287604554, 106 NodeWorldWideName: 2305843631894451530, 107 PortType: "unknown", 108 Speed: 16, 109 }, 110 &types.HostSerialAttachedHba{ 111 HostHostBusAdapter: types.HostHostBusAdapter{ 112 Key: "key-vim.host.SerialAttachedHba-vmhba4", 113 Device: "vmhba4", 114 Bus: 24, 115 Status: "unknown", 116 Model: "PERC H330 Adapter", 117 Driver: "lsi_mr3", 118 Pci: "0000:18:00.0", 119 }, 120 NodeWorldWideName: "5d0946606e78ac00", 121 }, 122 }