func NewAgency(
	ctx *simulator.Context,
	baseAgencyConfig types.BaseAgencyConfigInfo,
	initialGoalState string) (*Agency, vim.BaseMethodFault) {
	agencyConfig := baseAgencyConfig.GetAgencyConfigInfo()
	if agencyConfig.AgentName == "" {
		agencyConfig.AgentName = agencyConfig.AgencyName
	}
	agency := &Agency{
		EamObject: EamObject{
			Self: vim.ManagedObjectReference{
				Type:  internal.Agency,
				Value: uuid.New().String(),
			},
		},
		Agency: mo.Agency{
			Config: agencyConfig,
			Runtime: types.EamObjectRuntimeInfo{
				GoalState: initialGoalState,
			},
		},
	}
	ctx.Map.Put(agency)
	rng := rand.New(rand.NewSource(time.Now().UnixNano()))
	vimMap := simulator.Map
	for i, agentConfig := range agencyConfig.AgentConfig {
		vmName := fmt.Sprintf("%s (%d)", agencyConfig.AgentName, i+1)
		vmPlacement, err := getAgentVMPlacementOptions(
			ctx,
			vimMap,
			rng,
			i,
			agencyConfig)
		if err != nil {
			return nil, &vim.MethodFault{
				FaultCause: &vim.LocalizedMethodFault{
					LocalizedMessage: err.Error(),
				},
			}
		}
		if _, fault := NewAgent(
			ctx,
			agency.Self,
			agentConfig,
			vmName,
			vmPlacement); fault != nil {
			return nil, fault
		}
	}
	return agency, nil
}
NewAgency returns a new Agency as if CreateAgency were called on the
EsxAgentManager object.
package simulator
import (
	"fmt"
	"math/rand"
	"time"
	"github.com/google/uuid"
	"github.com/vmware/govmomi/eam/internal"
	"github.com/vmware/govmomi/eam/methods"
	"github.com/vmware/govmomi/eam/mo"
	"github.com/vmware/govmomi/eam/types"
	"github.com/vmware/govmomi/simulator"
	"github.com/vmware/govmomi/vim25/soap"
	vim "github.com/vmware/govmomi/vim25/types"
)
type Agency struct {
	EamObject
	mo.Agency
}