github.com/vmware/govmomi@v0.51.0/eam/simulator/simulator.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/eam" 9 "github.com/vmware/govmomi/eam/types" 10 "github.com/vmware/govmomi/simulator" 11 vimmo "github.com/vmware/govmomi/vim25/mo" 12 vim "github.com/vmware/govmomi/vim25/types" 13 ) 14 15 func init() { 16 simulator.RegisterEndpoint(func(s *simulator.Service, r *simulator.Registry) { 17 if r.IsVPX() { 18 s.RegisterSDK(New()) 19 } 20 }) 21 } 22 23 func New() *simulator.Registry { 24 r := simulator.NewRegistry() 25 r.Namespace = eam.Namespace 26 r.Path = eam.Path 27 r.Handler = invalidLoginForNilSessionFn 28 29 r.Put(&EsxAgentManager{ 30 EamObject: EamObject{ 31 Self: eam.EsxAgentManager, 32 }, 33 }) 34 35 return r 36 } 37 38 // invalidLoginForNilSessionFn returns EamInvalidLogin if the provided 39 // ctx.Session is nil. This is for validating all calls to EAM methods 40 // have a valid credential. 41 func invalidLoginForNilSessionFn( 42 ctx *simulator.Context, 43 _ *simulator.Method) (vimmo.Reference, vim.BaseMethodFault) { 44 45 if ctx.Session == nil { 46 return nil, new(types.EamInvalidLogin) 47 } 48 return nil, nil 49 }