simulator

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2017 License: Apache-2.0 Imports: 39 Imported by: 85

Documentation

Overview

Package simulator is a mock framework for the vSphere API.

See also: https://github.com/vmware/govmomi/blob/master/vcsim/README.md

Example

Example of extending the simulator to inject faults.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/vmware/govmomi"
	"github.com/vmware/govmomi/object"
	"github.com/vmware/govmomi/simulator"
	"github.com/vmware/govmomi/vim25/methods"
	"github.com/vmware/govmomi/vim25/soap"
	"github.com/vmware/govmomi/vim25/types"
)

// BusyVM changes the behavior of simulator.VirtualMachine
type BusyVM struct {
	*simulator.VirtualMachine
}

// Override simulator.VirtualMachine.PowerOffVMTask to inject faults
func (vm *BusyVM) PowerOffVMTask(req *types.PowerOffVM_Task) soap.HasFault {
	task := simulator.CreateTask(req.This, "powerOff", func(*simulator.Task) (types.AnyType, types.BaseMethodFault) {
		return nil, &types.TaskInProgress{}
	})

	return &methods.PowerOffVM_TaskBody{
		Res: &types.PowerOffVM_TaskResponse{
			Returnval: task.Run(),
		},
	}
}

// Add AcquireTicket method, not implemented by simulator.VirtualMachine
func (vm *BusyVM) AcquireTicket(req *types.AcquireTicket) soap.HasFault {
	body := &methods.AcquireTicketBody{}

	if req.TicketType != "mks" {
		body.Fault_ = simulator.Fault("", &types.InvalidArgument{})
	}

	body.Res = &types.AcquireTicketResponse{
		Returnval: types.VirtualMachineTicket{
			Ticket: "welcome 2 the machine",
		},
	}

	return body
}

// Example of extending the simulator to inject faults.
func main() {
	ctx := context.Background()
	model := simulator.VPX()

	defer model.Remove()
	_ = model.Create()

	s := model.Service.NewServer()
	defer s.Close()

	// NewClient connects to s.URL over https and invokes 2 SOAP methods (RetrieveServiceContent + Login)
	c, _ := govmomi.NewClient(ctx, s.URL, true)

	// Shortcut to choose any VM, rather than using the more verbose Finder or ContainerView.
	obj := simulator.Map.Any("VirtualMachine").(*simulator.VirtualMachine)
	// Validate VM is powered on
	if obj.Runtime.PowerState != "poweredOn" {
		log.Fatal(obj.Runtime.PowerState)
	}

	// Wrap the existing vm object, using the same vm.Self (ManagedObjectReference) value as the Map key.
	simulator.Map.Put(&BusyVM{obj})

	vm := object.NewVirtualMachine(c.Client, obj.Reference())

	// Start a PowerOff task using the SOAP client.
	task, _ := vm.PowerOff(ctx)

	// Wait for task completion, expecting failure.
	err := task.Wait(ctx)
	if err == nil {
		log.Fatal("expected error")
	}

	// Invalid ticket type, expecting failure.
	_, err = vm.AcquireTicket(ctx, "pks")
	if err == nil {
		log.Fatal("expected error")
	}

	mks, _ := vm.AcquireTicket(ctx, "mks")

	fmt.Println(mks.Ticket, obj.Runtime.PowerState)
}
Output:

welcome 2 the machine poweredOn

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultUserGroup = []*types.UserSearchResult{
	{FullName: "root", Group: true, Principal: "root"},
	{FullName: "root", Group: false, Principal: "root"},
	{FullName: "administrator", Group: false, Principal: "admin"},
}
View Source
var EvalLicense = types.LicenseManagerLicenseInfo{
	LicenseKey: "00000-00000-00000-00000-00000",
	EditionKey: "eval",
	Name:       "Evaluation Mode",
	Properties: []types.KeyAnyValue{
		{
			Key: "feature",
			Value: types.KeyValue{
				Key:   "serialuri:2",
				Value: "Remote virtual Serial Port Concentrator",
			},
		},
		{
			Key: "feature",
			Value: types.KeyValue{
				Key:   "dvs",
				Value: "vSphere Distributed Switch",
			},
		},
	},
}

EvalLicense is the default license

View Source
var Map = NewRegistry()

Map is the default Registry instance.

View Source
var Trace = false

Trace when set to true, writes SOAP traffic to stderr

Functions

func AddReference

AddReference returns a slice with ref appended if not already in refs.

func CreateDefaultESX

func CreateDefaultESX(f *Folder)

CreateDefaultESX creates a standalone ESX Adds objects of type: Datacenter, Network, ComputeResource, ResourcePool and HostSystem

func DisableRuleset

func DisableRuleset(info *types.HostFirewallInfo, id string) bool

func EnableRuleset

func EnableRuleset(info *types.HostFirewallInfo, id string) bool

func Fault

func Fault(msg string, fault types.BaseMethodFault) *soap.Fault

Fault wraps the given message and fault in a soap.Fault

func FindReference

FindReference returns the 1st match found in refs, or nil if not found.

func NewAuthorizationManager

func NewAuthorizationManager(ref types.ManagedObjectReference) object.Reference

func NewCustomFieldsManager

func NewCustomFieldsManager(ref types.ManagedObjectReference) object.Reference

func NewPerformanceManager

func NewPerformanceManager(ref types.ManagedObjectReference) object.Reference

func NewPropertyCollector

func NewPropertyCollector(ref types.ManagedObjectReference) object.Reference

func NewVAppConfigSpec

func NewVAppConfigSpec() types.VAppConfigSpec

func NewVirtualDiskManager

func NewVirtualDiskManager(ref types.ManagedObjectReference) object.Reference

func RemoveReference

RemoveReference returns a slice with ref removed from refs

func RenameTask

func RenameTask(e mo.Entity, r *types.Rename_Task) soap.HasFault

Types

type AuthorizationManager

type AuthorizationManager struct {
	mo.AuthorizationManager
	// contains filtered or unexported fields
}

func (*AuthorizationManager) AddAuthorizationRole

func (m *AuthorizationManager) AddAuthorizationRole(req *types.AddAuthorizationRole) soap.HasFault

func (*AuthorizationManager) RemoveAuthorizationRole

func (m *AuthorizationManager) RemoveAuthorizationRole(req *types.RemoveAuthorizationRole) soap.HasFault

func (*AuthorizationManager) RemoveEntityPermission

func (m *AuthorizationManager) RemoveEntityPermission(req *types.RemoveEntityPermission) soap.HasFault

func (*AuthorizationManager) RetrieveAllPermissions

func (m *AuthorizationManager) RetrieveAllPermissions(req *types.RetrieveAllPermissions) soap.HasFault

func (*AuthorizationManager) RetrieveEntityPermissions

func (m *AuthorizationManager) RetrieveEntityPermissions(req *types.RetrieveEntityPermissions) soap.HasFault

func (*AuthorizationManager) RetrieveRolePermissions

func (m *AuthorizationManager) RetrieveRolePermissions(req *types.RetrieveRolePermissions) soap.HasFault

func (*AuthorizationManager) SetEntityPermissions

func (m *AuthorizationManager) SetEntityPermissions(req *types.SetEntityPermissions) soap.HasFault

func (*AuthorizationManager) UpdateAuthorizationRole

func (m *AuthorizationManager) UpdateAuthorizationRole(req *types.UpdateAuthorizationRole) soap.HasFault

type ClusterComputeResource

type ClusterComputeResource struct {
	mo.ClusterComputeResource
}

func (*ClusterComputeResource) AddHostTask

func (c *ClusterComputeResource) AddHostTask(add *types.AddHost_Task) soap.HasFault

type ContainerView

type ContainerView struct {
	mo.ContainerView
	// contains filtered or unexported fields
}

func (*ContainerView) DestroyView

func (v *ContainerView) DestroyView(c *types.DestroyView) soap.HasFault

type CustomFieldsManager

type CustomFieldsManager struct {
	mo.CustomFieldsManager
	// contains filtered or unexported fields
}

func (*CustomFieldsManager) AddCustomFieldDef

func (c *CustomFieldsManager) AddCustomFieldDef(req *types.AddCustomFieldDef) soap.HasFault

func (*CustomFieldsManager) RemoveCustomFieldDef

func (c *CustomFieldsManager) RemoveCustomFieldDef(req *types.RemoveCustomFieldDef) soap.HasFault

func (*CustomFieldsManager) RenameCustomFieldDef

func (c *CustomFieldsManager) RenameCustomFieldDef(req *types.RenameCustomFieldDef) soap.HasFault

func (*CustomFieldsManager) SetField

func (c *CustomFieldsManager) SetField(req *types.SetField) soap.HasFault

type Datastore

type Datastore struct {
	mo.Datastore
}

func (*Datastore) RefreshDatastore

func (ds *Datastore) RefreshDatastore(*types.RefreshDatastore) soap.HasFault

type DistributedVirtualPortgroup

type DistributedVirtualPortgroup struct {
	mo.DistributedVirtualPortgroup
}

func (*DistributedVirtualPortgroup) DestroyTask

func (*DistributedVirtualPortgroup) ReconfigureDVPortgroupTask

func (s *DistributedVirtualPortgroup) ReconfigureDVPortgroupTask(req *types.ReconfigureDVPortgroup_Task) soap.HasFault

type DistributedVirtualSwitch

type DistributedVirtualSwitch struct {
	mo.DistributedVirtualSwitch
}

func (*DistributedVirtualSwitch) AddDVPortgroupTask

func (*DistributedVirtualSwitch) DestroyTask

func (*DistributedVirtualSwitch) FetchDVPorts

func (*DistributedVirtualSwitch) ReconfigureDvsTask

func (s *DistributedVirtualSwitch) ReconfigureDvsTask(req *types.ReconfigureDvs_Task) soap.HasFault

type FileManager

type FileManager struct {
	mo.FileManager
}

func (*FileManager) CopyDatastoreFileTask

func (f *FileManager) CopyDatastoreFileTask(req *types.CopyDatastoreFile_Task) soap.HasFault

func (*FileManager) DeleteDatastoreFileTask

func (f *FileManager) DeleteDatastoreFileTask(req *types.DeleteDatastoreFile_Task) soap.HasFault

func (*FileManager) MakeDirectory

func (f *FileManager) MakeDirectory(req *types.MakeDirectory) soap.HasFault

func (*FileManager) MoveDatastoreFileTask

func (f *FileManager) MoveDatastoreFileTask(req *types.MoveDatastoreFile_Task) soap.HasFault

type Folder

type Folder struct {
	mo.Folder
	// contains filtered or unexported fields
}

func (*Folder) AddStandaloneHostTask

func (f *Folder) AddStandaloneHostTask(a *types.AddStandaloneHost_Task) soap.HasFault

func (*Folder) CreateClusterEx

func (f *Folder) CreateClusterEx(c *types.CreateClusterEx) soap.HasFault

func (*Folder) CreateDVSTask

func (f *Folder) CreateDVSTask(req *types.CreateDVS_Task) soap.HasFault

func (*Folder) CreateDatacenter

func (f *Folder) CreateDatacenter(c *types.CreateDatacenter) soap.HasFault

func (*Folder) CreateFolder

func (f *Folder) CreateFolder(c *types.CreateFolder) soap.HasFault

func (*Folder) CreateStoragePod

func (f *Folder) CreateStoragePod(c *types.CreateStoragePod) soap.HasFault

func (*Folder) CreateVMTask

func (f *Folder) CreateVMTask(c *types.CreateVM_Task) soap.HasFault

func (*Folder) MoveIntoFolderTask

func (f *Folder) MoveIntoFolderTask(c *types.MoveIntoFolder_Task) soap.HasFault

func (*Folder) RegisterVMTask

func (f *Folder) RegisterVMTask(c *types.RegisterVM_Task) soap.HasFault

func (*Folder) RenameTask

func (f *Folder) RenameTask(r *types.Rename_Task) soap.HasFault

type HostDatastoreBrowser

type HostDatastoreBrowser struct {
	mo.HostDatastoreBrowser
}

func (*HostDatastoreBrowser) SearchDatastoreSubFoldersTask

func (b *HostDatastoreBrowser) SearchDatastoreSubFoldersTask(s *types.SearchDatastoreSubFolders_Task) soap.HasFault

func (*HostDatastoreBrowser) SearchDatastoreTask

func (b *HostDatastoreBrowser) SearchDatastoreTask(s *types.SearchDatastore_Task) soap.HasFault

type HostDatastoreSystem

type HostDatastoreSystem struct {
	mo.HostDatastoreSystem

	Host *mo.HostSystem
}

func (*HostDatastoreSystem) CreateLocalDatastore

func (dss *HostDatastoreSystem) CreateLocalDatastore(c *types.CreateLocalDatastore) soap.HasFault

func (*HostDatastoreSystem) CreateNasDatastore

func (dss *HostDatastoreSystem) CreateNasDatastore(c *types.CreateNasDatastore) soap.HasFault

type HostFirewallSystem

type HostFirewallSystem struct {
	mo.HostFirewallSystem
}

func NewHostFirewallSystem

func NewHostFirewallSystem(_ *mo.HostSystem) *HostFirewallSystem

func (*HostFirewallSystem) DisableRuleset

func (s *HostFirewallSystem) DisableRuleset(req *types.DisableRuleset) soap.HasFault

func (*HostFirewallSystem) EnableRuleset

func (s *HostFirewallSystem) EnableRuleset(req *types.EnableRuleset) soap.HasFault

type HostNetworkSystem

type HostNetworkSystem struct {
	mo.HostNetworkSystem

	Host *mo.HostSystem
}

func NewHostNetworkSystem

func NewHostNetworkSystem(host *mo.HostSystem) *HostNetworkSystem

func (*HostNetworkSystem) AddPortGroup

func (s *HostNetworkSystem) AddPortGroup(c *types.AddPortGroup) soap.HasFault

func (*HostNetworkSystem) AddVirtualSwitch

func (s *HostNetworkSystem) AddVirtualSwitch(c *types.AddVirtualSwitch) soap.HasFault

func (*HostNetworkSystem) RemovePortGroup

func (s *HostNetworkSystem) RemovePortGroup(c *types.RemovePortGroup) soap.HasFault

func (*HostNetworkSystem) RemoveVirtualSwitch

func (s *HostNetworkSystem) RemoveVirtualSwitch(c *types.RemoveVirtualSwitch) soap.HasFault

func (*HostNetworkSystem) UpdateNetworkConfig

func (s *HostNetworkSystem) UpdateNetworkConfig(req *types.UpdateNetworkConfig) soap.HasFault

type HostSystem

type HostSystem struct {
	mo.HostSystem
}

func CreateStandaloneHost

func CreateStandaloneHost(f *Folder, spec types.HostConnectSpec) (*HostSystem, types.BaseMethodFault)

CreateStandaloneHost uses esx.HostSystem as a template, applying the given spec and creating the ComputeResource parent and ResourcePool sibling.

func NewHostSystem

func NewHostSystem(host mo.HostSystem) *HostSystem

func (*HostSystem) EnterMaintenanceModeTask

func (h *HostSystem) EnterMaintenanceModeTask(spec *types.EnterMaintenanceMode_Task) soap.HasFault

func (*HostSystem) ExitMaintenanceModeTask

func (h *HostSystem) ExitMaintenanceModeTask(spec *types.ExitMaintenanceMode_Task) soap.HasFault

type IpPool

type IpPool struct {
	// contains filtered or unexported fields
}

func MustNewIpPool

func MustNewIpPool(config *types.IpPool) *IpPool

func NewIpPool

func NewIpPool(config *types.IpPool) (*IpPool, error)

func (*IpPool) AllocateIPv4

func (p *IpPool) AllocateIPv4(allocation string) (string, error)

func (*IpPool) AllocateIpv6

func (p *IpPool) AllocateIpv6(allocation string) (string, error)

func (*IpPool) ReleaseIpv4

func (p *IpPool) ReleaseIpv4(allocation string) error

func (*IpPool) ReleaseIpv6

func (p *IpPool) ReleaseIpv6(allocation string) error

type IpPoolManager

type IpPoolManager struct {
	mo.IpPoolManager
	// contains filtered or unexported fields
}

IpPoolManager implements a simple IP Pool manager in which all pools are shared across different datacenters.

func NewIpPoolManager

func NewIpPoolManager(ref types.ManagedObjectReference) *IpPoolManager

func (*IpPoolManager) AllocateIpv4Address

func (m *IpPoolManager) AllocateIpv4Address(req *types.AllocateIpv4Address) soap.HasFault

func (*IpPoolManager) AllocateIpv6Address

func (m *IpPoolManager) AllocateIpv6Address(req *types.AllocateIpv6Address) soap.HasFault

func (*IpPoolManager) CreateIpPool

func (m *IpPoolManager) CreateIpPool(req *types.CreateIpPool) soap.HasFault

func (*IpPoolManager) DestroyIpPool

func (m *IpPoolManager) DestroyIpPool(req *types.DestroyIpPool) soap.HasFault

func (*IpPoolManager) QueryIPAllocations

func (m *IpPoolManager) QueryIPAllocations(req *types.QueryIPAllocations) soap.HasFault

func (*IpPoolManager) QueryIpPools

func (m *IpPoolManager) QueryIpPools(req *types.QueryIpPools) soap.HasFault

func (*IpPoolManager) ReleaseIpAllocation

func (m *IpPoolManager) ReleaseIpAllocation(req *types.ReleaseIpAllocation) soap.HasFault

func (*IpPoolManager) UpdateIpPool

func (m *IpPoolManager) UpdateIpPool(req *types.UpdateIpPool) soap.HasFault

type LicenseAssignmentManager

type LicenseAssignmentManager struct {
	mo.LicenseAssignmentManager
}

func (*LicenseAssignmentManager) QueryAssignedLicenses

func (m *LicenseAssignmentManager) QueryAssignedLicenses(req *types.QueryAssignedLicenses) soap.HasFault

type LicenseManager

type LicenseManager struct {
	mo.LicenseManager
}

func (*LicenseManager) AddLicense

func (m *LicenseManager) AddLicense(req *types.AddLicense) soap.HasFault

func (*LicenseManager) RemoveLicense

func (m *LicenseManager) RemoveLicense(req *types.RemoveLicense) soap.HasFault

type Method

type Method struct {
	Name string
	This types.ManagedObjectReference
	Body types.AnyType
}

Method encapsulates a decoded SOAP client request

func UnmarshalBody

func UnmarshalBody(data []byte) (*Method, error)

UnmarshalBody extracts the Body from a soap.Envelope and unmarshals to the corresponding govmomi type

type Model

type Model struct {
	Service *Service

	ServiceContent types.ServiceContent
	RootFolder     mo.Folder

	// Autostart will power on Model created VMs when true
	Autostart bool

	// Datacenter specifies the number of Datacenter entities to create
	Datacenter int

	// Portgroup specifies the number of DistributedVirtualPortgroup entities to create per Datacenter
	Portgroup int

	// Host specifies the number of standalone HostSystems entities to create per Datacenter
	Host int

	// Cluster specifies the number of ClusterComputeResource entities to create per Datacenter
	Cluster int

	// ClusterHost specifies the number of HostSystems entities to create within a Cluster
	ClusterHost int

	// Pool specifies the number of ResourcePool entities to create per Cluster
	Pool int

	// Datastore specifies the number of Datastore entities to create
	// Each Datastore will have temporary local file storage and will be mounted
	// on every HostSystem created by the ModelConfig
	Datastore int

	// Machine specifies the number of VirtualMachine entities to create per ResourcePool
	Machine int

	// Folder specifies the number of Datacenter to place within a Folder.
	// This includes a folder for the Datacenter itself and its host, vm, network and datastore folders.
	// All resources for the Datacenter are placed within these folders, rather than the top-level folders.
	Folder int

	// App specifies the number of VirtualApp to create per Cluster
	App int

	// Pod specifies the number of StoragePod to create per Cluster
	Pod int
	// contains filtered or unexported fields
}

Model is used to populate a Model with an initial set of managed entities. This is a simple helper for tests running against a simulator, to populate an inventory with commonly used models.

Example

Example for starting a simulator with empty inventory, similar to a fresh install of vCenter.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/vmware/govmomi"
	"github.com/vmware/govmomi/simulator"
)

func main() {
	ctx := context.Background()

	model := simulator.VPX()
	model.Datacenter = 0 // No DC == no inventory

	defer model.Remove()
	err := model.Create()
	if err != nil {
		log.Fatal(err)
	}

	s := model.Service.NewServer()
	defer s.Close()

	c, _ := govmomi.NewClient(ctx, s.URL, true)

	fmt.Printf("%s with %d hosts", c.Client.ServiceContent.About.ApiType, model.Count().Host)
}
Output:

VirtualCenter with 0 hosts

func ESX

func ESX() *Model

ESX is the default Model for a standalone ESX instance

Example

Example boilerplate for starting a simulator initialized with an ESX model.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/vmware/govmomi"
	"github.com/vmware/govmomi/simulator"
)

func main() {
	ctx := context.Background()

	// ESXi model + initial set of objects (VMs, network, datastore)
	model := simulator.ESX()

	defer model.Remove()
	err := model.Create()
	if err != nil {
		log.Fatal(err)
	}

	s := model.Service.NewServer()
	defer s.Close()

	c, _ := govmomi.NewClient(ctx, s.URL, true)

	fmt.Printf("%s with %d host", c.Client.ServiceContent.About.ApiType, model.Count().Host)
}
Output:

HostAgent with 1 host

func VPX

func VPX() *Model

VPX is the default Model for a vCenter instance

Example

Example boilerplate for starting a simulator initialized with a vCenter model.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/vmware/govmomi"
	"github.com/vmware/govmomi/simulator"
)

func main() {
	ctx := context.Background()

	// vCenter model + initial set of objects (cluster, hosts, VMs, network, datastore, etc)
	model := simulator.VPX()

	defer model.Remove()
	err := model.Create()
	if err != nil {
		log.Fatal(err)
	}

	s := model.Service.NewServer()
	defer s.Close()

	c, _ := govmomi.NewClient(ctx, s.URL, true)

	fmt.Printf("%s with %d hosts", c.Client.ServiceContent.About.ApiType, model.Count().Host)
}
Output:

VirtualCenter with 4 hosts

func (*Model) Count

func (m *Model) Count() Model

Count returns a Model with total number of each existing type

func (*Model) Create

func (m *Model) Create() error

Create populates the Model with the given ModelConfig

func (*Model) Remove

func (m *Model) Remove()

Remove cleans up items created by the Model, such as local datastore directories

type OptionManager

type OptionManager struct {
	mo.OptionManager
}

func (*OptionManager) QueryOptions

func (m *OptionManager) QueryOptions(req *types.QueryOptions) soap.HasFault

type PerformanceManager

type PerformanceManager struct {
	mo.PerformanceManager
}

type PropertyCollector

type PropertyCollector struct {
	mo.PropertyCollector
}

func (*PropertyCollector) CancelWaitForUpdates

func (pc *PropertyCollector) CancelWaitForUpdates(r *types.CancelWaitForUpdates) soap.HasFault

func (*PropertyCollector) CreateFilter

func (pc *PropertyCollector) CreateFilter(c *types.CreateFilter) soap.HasFault

func (*PropertyCollector) CreatePropertyCollector

func (pc *PropertyCollector) CreatePropertyCollector(c *types.CreatePropertyCollector) soap.HasFault

func (*PropertyCollector) DestroyPropertyCollector

func (pc *PropertyCollector) DestroyPropertyCollector(c *types.DestroyPropertyCollector) soap.HasFault

func (*PropertyCollector) RetrieveProperties

func (pc *PropertyCollector) RetrieveProperties(r *types.RetrieveProperties) soap.HasFault

RetrieveProperties is deprecated, but govmomi is still using it at the moment.

func (*PropertyCollector) RetrievePropertiesEx

func (pc *PropertyCollector) RetrievePropertiesEx(r *types.RetrievePropertiesEx) soap.HasFault

func (*PropertyCollector) WaitForUpdates

func (pc *PropertyCollector) WaitForUpdates(r *types.WaitForUpdates) soap.HasFault

WaitForUpdates is deprecated, but pyvmomi is still using it at the moment.

func (*PropertyCollector) WaitForUpdatesEx

func (pc *PropertyCollector) WaitForUpdatesEx(r *types.WaitForUpdatesEx) soap.HasFault

type PropertyFilter

type PropertyFilter struct {
	mo.PropertyFilter
	// contains filtered or unexported fields
}

func (*PropertyFilter) DestroyPropertyFilter

func (f *PropertyFilter) DestroyPropertyFilter(c *types.DestroyPropertyFilter) soap.HasFault

type RegisterObject

type RegisterObject interface {
	mo.Reference
	PutObject(mo.Reference)
	RemoveObject(types.ManagedObjectReference)
}

RegisterObject interface supports callbacks when objects are added and removed from the Registry

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages a map of mo.Reference objects

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new instances of Registry

func (*Registry) AddHandler

func (r *Registry) AddHandler(h RegisterObject)

AddHandler adds a RegisterObject handler to the Registry.

func (*Registry) Any

func (r *Registry) Any(kind string) mo.Entity

Any returns the first instance of entity type specified by kind.

func (*Registry) FileManager

func (r *Registry) FileManager() *FileManager

FileManager returns the FileManager singleton

func (*Registry) FindByName

func (r *Registry) FindByName(name string, refs []types.ManagedObjectReference) mo.Entity

FindByName returns the first mo.Entity of the given refs whose Name field is equal to the given name. If there is no match, nil is returned. This method is useful for cases where objects are required to have a unique name, such as Datastore with a HostStorageSystem or HostSystem within a ClusterComputeResource.

func (*Registry) Get

Get returns the object for the given reference.

func (*Registry) IsESX

func (r *Registry) IsESX() bool

IsESX returns true if this Registry maps an ESX model

func (*Registry) IsVPX

func (r *Registry) IsVPX() bool

IsVPX returns true if this Registry maps a VPX model

func (*Registry) NewEntity

func (r *Registry) NewEntity(item mo.Entity) mo.Entity

NewEntity sets Entity().Self with a new, unique Value. Useful for creating object instances from templates.

func (*Registry) Put

func (r *Registry) Put(item mo.Reference) mo.Reference

Put adds a new object to Registry, generating a ManagedObjectReference if not already set.

func (*Registry) PutEntity

func (r *Registry) PutEntity(parent mo.Entity, item mo.Entity) mo.Entity

PutEntity sets item.Parent to that of parent.Self before adding item to the Registry.

func (*Registry) Remove

func (r *Registry) Remove(item types.ManagedObjectReference)

Remove removes an object from the Registry.

func (*Registry) SearchIndex

func (r *Registry) SearchIndex() *SearchIndex

SearchIndex returns the SearchIndex singleton

func (*Registry) ViewManager

func (r *Registry) ViewManager() *ViewManager

ViewManager returns the ViewManager singleton

func (*Registry) VirtualDiskManager

func (r *Registry) VirtualDiskManager() *VirtualDiskManager

VirtualDiskManager returns the VirtualDiskManager singleton

type ResourcePool

type ResourcePool struct {
	mo.ResourcePool
}

func NewResourcePool

func NewResourcePool() *ResourcePool

func (*ResourcePool) CreateResourcePool

func (p *ResourcePool) CreateResourcePool(c *types.CreateResourcePool) soap.HasFault

func (*ResourcePool) CreateVApp

func (p *ResourcePool) CreateVApp(req *types.CreateVApp) soap.HasFault

func (*ResourcePool) DestroyTask

func (p *ResourcePool) DestroyTask(req *types.Destroy_Task) soap.HasFault

func (*ResourcePool) UpdateConfig

func (p *ResourcePool) UpdateConfig(c *types.UpdateConfig) soap.HasFault

type SearchIndex

type SearchIndex struct {
	mo.SearchIndex
}

func (*SearchIndex) FindByDatastorePath

func (s *SearchIndex) FindByDatastorePath(r *types.FindByDatastorePath) soap.HasFault

func (*SearchIndex) FindByInventoryPath

func (s *SearchIndex) FindByInventoryPath(req *types.FindByInventoryPath) soap.HasFault

func (*SearchIndex) FindByUuid

func (s *SearchIndex) FindByUuid(req *types.FindByUuid) soap.HasFault

func (*SearchIndex) FindChild

func (s *SearchIndex) FindChild(req *types.FindChild) soap.HasFault

type Server

type Server struct {
	*httptest.Server
	URL *url.URL
	// contains filtered or unexported fields
}

Server provides a simulator Service over HTTP

func (*Server) Certificate

func (s *Server) Certificate() *x509.Certificate

Certificate returns the TLS certificate for the Server if started with TLS enabled. This method will panic if TLS is not enabled for the server.

func (*Server) CertificateFile

func (s *Server) CertificateFile() (string, error)

CertificateFile returns a file name, where the file contains the PEM encoded Server.Certificate. The temporary file is removed when Server.Close() is called.

func (*Server) CertificateInfo

func (s *Server) CertificateInfo() *object.HostCertificateInfo

CertificateInfo returns Server.Certificate() as object.HostCertificateInfo

func (*Server) Close

func (s *Server) Close()

Close shuts down the server and blocks until all outstanding requests on this server have completed.

type Service

type Service struct {
	TLS *tls.Config
	// contains filtered or unexported fields
}

Service decodes incoming requests and dispatches to a Handler

func New

func New(instance *ServiceInstance) *Service

New returns an initialized simulator Service instance

func (*Service) About

func (s *Service) About(w http.ResponseWriter, r *http.Request)

About generates some info about the simulator.

func (*Service) NewServer

func (s *Service) NewServer() *Server

NewServer returns an http Server instance for the given service

func (*Service) RoundTrip

func (s *Service) RoundTrip(ctx context.Context, request, response soap.HasFault) error

RoundTrip implements the soap.RoundTripper interface in process. Rather than encode/decode SOAP over HTTP, this implementation uses reflection.

func (*Service) ServeDatastore

func (s *Service) ServeDatastore(w http.ResponseWriter, r *http.Request)

ServeDatastore handler for Datastore access via /folder path.

func (*Service) ServeSDK

func (s *Service) ServeSDK(w http.ResponseWriter, r *http.Request)

ServeSDK implements the http.Handler interface

func (*Service) ServiceVersions

func (*Service) ServiceVersions(w http.ResponseWriter, r *http.Request)

ServiceVersions handler for the /sdk/vimServiceVersions.xml path.

type ServiceInstance

type ServiceInstance struct {
	mo.ServiceInstance
}

func NewServiceInstance

func NewServiceInstance(content types.ServiceContent, folder mo.Folder) *ServiceInstance

func (*ServiceInstance) CurrentTime

func (*ServiceInstance) RetrieveServiceContent

func (s *ServiceInstance) RetrieveServiceContent(*types.RetrieveServiceContent) soap.HasFault

type SessionManager

type SessionManager struct {
	mo.SessionManager

	ServiceHostName string
}

func (*SessionManager) AcquireGenericServiceTicket

func (s *SessionManager) AcquireGenericServiceTicket(ticket *types.AcquireGenericServiceTicket) soap.HasFault

func (*SessionManager) Login

func (s *SessionManager) Login(login *types.Login) soap.HasFault

func (*SessionManager) Logout

func (s *SessionManager) Logout(*types.Logout) soap.HasFault

type StoragePod

type StoragePod struct {
	mo.StoragePod
}

StoragePod aka "Datastore Cluster"

func (*StoragePod) MoveIntoFolderTask

func (p *StoragePod) MoveIntoFolderTask(c *types.MoveIntoFolder_Task) soap.HasFault

type Task

type Task struct {
	mo.Task

	Execute func(*Task) (types.AnyType, types.BaseMethodFault)
}

func CreateTask

func CreateTask(e mo.Reference, name string, run func(*Task) (types.AnyType, types.BaseMethodFault)) *Task

func NewTask

func NewTask(runner TaskRunner) *Task

func (*Task) Run

type TaskManager

type TaskManager struct {
	mo.TaskManager
}

func (*TaskManager) PutObject

func (m *TaskManager) PutObject(obj mo.Reference)

func (*TaskManager) RemoveObject

func (m *TaskManager) RemoveObject(_ types.ManagedObjectReference)

type TaskRunner

type TaskRunner interface {
	mo.Reference

	Run(*Task) (types.AnyType, types.BaseMethodFault)
}

type UserDirectory

type UserDirectory struct {
	mo.UserDirectory
	// contains filtered or unexported fields
}

func (*UserDirectory) RetrieveUserGroups

func (u *UserDirectory) RetrieveUserGroups(req *types.RetrieveUserGroups) soap.HasFault

type ViewManager

type ViewManager struct {
	mo.ViewManager
	// contains filtered or unexported fields
}

func (*ViewManager) CreateContainerView

func (m *ViewManager) CreateContainerView(req *types.CreateContainerView) soap.HasFault

type VirtualApp

type VirtualApp struct {
	mo.VirtualApp
}

func (*VirtualApp) CreateChildVMTask

func (a *VirtualApp) CreateChildVMTask(req *types.CreateChildVM_Task) soap.HasFault

func (*VirtualApp) DestroyTask

func (a *VirtualApp) DestroyTask(req *types.Destroy_Task) soap.HasFault

type VirtualDiskManager

type VirtualDiskManager struct {
	mo.VirtualDiskManager
}

func (*VirtualDiskManager) CopyVirtualDiskTask

func (m *VirtualDiskManager) CopyVirtualDiskTask(req *types.CopyVirtualDisk_Task) soap.HasFault

func (*VirtualDiskManager) CreateVirtualDiskTask

func (m *VirtualDiskManager) CreateVirtualDiskTask(req *types.CreateVirtualDisk_Task) soap.HasFault

func (*VirtualDiskManager) DeleteVirtualDiskTask

func (m *VirtualDiskManager) DeleteVirtualDiskTask(req *types.DeleteVirtualDisk_Task) soap.HasFault

func (*VirtualDiskManager) MoveVirtualDiskTask

func (m *VirtualDiskManager) MoveVirtualDiskTask(req *types.MoveVirtualDisk_Task) soap.HasFault

type VirtualMachine

type VirtualMachine struct {
	mo.VirtualMachine
	// contains filtered or unexported fields
}

func (*VirtualMachine) CloneVMTask

func (vm *VirtualMachine) CloneVMTask(req *types.CloneVM_Task) soap.HasFault

func (*VirtualMachine) CreateSnapshotTask

func (vm *VirtualMachine) CreateSnapshotTask(req *types.CreateSnapshot_Task) soap.HasFault

func (*VirtualMachine) DestroyTask

func (vm *VirtualMachine) DestroyTask(req *types.Destroy_Task) soap.HasFault

func (*VirtualMachine) PowerOffVMTask

func (vm *VirtualMachine) PowerOffVMTask(c *types.PowerOffVM_Task) soap.HasFault

func (*VirtualMachine) PowerOnVMTask

func (vm *VirtualMachine) PowerOnVMTask(c *types.PowerOnVM_Task) soap.HasFault

func (*VirtualMachine) ReconfigVMTask

func (vm *VirtualMachine) ReconfigVMTask(req *types.ReconfigVM_Task) soap.HasFault

func (*VirtualMachine) RelocateVMTask

func (vm *VirtualMachine) RelocateVMTask(req *types.RelocateVM_Task) soap.HasFault

func (*VirtualMachine) RemoveAllSnapshotsTask

func (vm *VirtualMachine) RemoveAllSnapshotsTask(req *types.RemoveAllSnapshots_Task) soap.HasFault

func (*VirtualMachine) RevertToCurrentSnapshotTask

func (vm *VirtualMachine) RevertToCurrentSnapshotTask(req *types.RevertToCurrentSnapshot_Task) soap.HasFault

func (*VirtualMachine) ShutdownGuest

func (vm *VirtualMachine) ShutdownGuest(c *types.ShutdownGuest) soap.HasFault

func (*VirtualMachine) UnregisterVM

func (vm *VirtualMachine) UnregisterVM(c *types.UnregisterVM) soap.HasFault

type VirtualMachineSnapshot

type VirtualMachineSnapshot struct {
	mo.VirtualMachineSnapshot
}

func (*VirtualMachineSnapshot) RemoveSnapshotTask

func (v *VirtualMachineSnapshot) RemoveSnapshotTask(req *types.RemoveSnapshot_Task) soap.HasFault

func (*VirtualMachineSnapshot) RevertToSnapshotTask

func (v *VirtualMachineSnapshot) RevertToSnapshotTask(req *types.RevertToSnapshot_Task) soap.HasFault

Directories

Path Synopsis
Package esx contains SOAP responses from an ESX server, captured using `govc ...
Package esx contains SOAP responses from an ESX server, captured using `govc ...
Package vpx contains SOAP responses from a vCenter server, captured using `govc ...
Package vpx contains SOAP responses from a vCenter server, captured using `govc ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL