Documentation ¶
Index ¶
- Constants
- Variables
- func ReferenceFromString(s string) *types.ManagedObjectReference
- func SnapshotSize(info types.ManagedObjectReference, parent *types.ManagedObjectReference, ...) int
- type AuthorizationManager
- func (m AuthorizationManager) AddRole(ctx context.Context, name string, ids []string) (int32, error)
- func (m AuthorizationManager) DisableMethods(ctx context.Context, entity []types.ManagedObjectReference, ...) error
- func (m AuthorizationManager) EnableMethods(ctx context.Context, entity []types.ManagedObjectReference, method []string, ...) error
- func (m AuthorizationManager) FetchUserPrivilegeOnEntities(ctx context.Context, entities []types.ManagedObjectReference, userName string) ([]types.UserPrivilegeResult, error)
- func (m AuthorizationManager) HasPrivilegeOnEntity(ctx context.Context, entity types.ManagedObjectReference, sessionID string, ...) ([]bool, error)
- func (m AuthorizationManager) HasUserPrivilegeOnEntities(ctx context.Context, entities []types.ManagedObjectReference, userName string, ...) ([]types.EntityPrivilege, error)
- func (m AuthorizationManager) RemoveEntityPermission(ctx context.Context, entity types.ManagedObjectReference, user string, ...) error
- func (m AuthorizationManager) RemoveRole(ctx context.Context, id int32, failIfUsed bool) error
- func (m AuthorizationManager) RetrieveAllPermissions(ctx context.Context) ([]types.Permission, error)
- func (m AuthorizationManager) RetrieveEntityPermissions(ctx context.Context, entity types.ManagedObjectReference, inherited bool) ([]types.Permission, error)
- func (m AuthorizationManager) RetrieveRolePermissions(ctx context.Context, id int32) ([]types.Permission, error)
- func (m AuthorizationManager) RoleList(ctx context.Context) (AuthorizationRoleList, error)
- func (m AuthorizationManager) SetEntityPermissions(ctx context.Context, entity types.ManagedObjectReference, ...) error
- func (m AuthorizationManager) UpdateRole(ctx context.Context, id int32, name string, ids []string) error
- type AuthorizationRoleList
- type ClusterComputeResource
- func (c ClusterComputeResource) AddHost(ctx context.Context, spec types.HostConnectSpec, asConnected bool, ...) (*Task, error)
- func (c ClusterComputeResource) Configuration(ctx context.Context) (*types.ClusterConfigInfoEx, error)
- func (c ClusterComputeResource) MoveInto(ctx context.Context, hosts ...*HostSystem) (*Task, error)
- func (c ClusterComputeResource) PlaceVm(ctx context.Context, spec types.PlacementSpec) (*types.PlacementResult, error)
- type Common
- func (c Common) Client() *vim25.Client
- func (c Common) Destroy(ctx context.Context) (*Task, error)
- func (c Common) Name() string
- func (c Common) ObjectName(ctx context.Context) (string, error)
- func (c Common) Properties(ctx context.Context, r types.ManagedObjectReference, ps []string, ...) error
- func (c Common) Reference() types.ManagedObjectReference
- func (c Common) Rename(ctx context.Context, name string) (*Task, error)
- func (c Common) SetCustomValue(ctx context.Context, key string, value string) error
- func (c *Common) SetInventoryPath(p string)
- func (c Common) String() string
- type ComputeResource
- func (c ComputeResource) Datastores(ctx context.Context) ([]*Datastore, error)
- func (c ComputeResource) Hosts(ctx context.Context) ([]*HostSystem, error)
- func (c ComputeResource) Reconfigure(ctx context.Context, spec types.BaseComputeResourceConfigSpec, modify bool) (*Task, error)
- func (c ComputeResource) ResourcePool(ctx context.Context) (*ResourcePool, error)
- type CustomFieldDefList
- type CustomFieldsManager
- func (m CustomFieldsManager) Add(ctx context.Context, name string, moType string, ...) (*types.CustomFieldDef, error)
- func (m CustomFieldsManager) Field(ctx context.Context) (CustomFieldDefList, error)
- func (m CustomFieldsManager) FindKey(ctx context.Context, name string) (int32, error)
- func (m CustomFieldsManager) Remove(ctx context.Context, key int32) error
- func (m CustomFieldsManager) Rename(ctx context.Context, key int32, name string) error
- func (m CustomFieldsManager) Set(ctx context.Context, entity types.ManagedObjectReference, key int32, ...) error
- type CustomizationSpecManager
- func (cs CustomizationSpecManager) CreateCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error
- func (cs CustomizationSpecManager) CustomizationSpecItemToXml(ctx context.Context, item types.CustomizationSpecItem) (string, error)
- func (cs CustomizationSpecManager) DeleteCustomizationSpec(ctx context.Context, name string) error
- func (cs CustomizationSpecManager) DoesCustomizationSpecExist(ctx context.Context, name string) (bool, error)
- func (cs CustomizationSpecManager) DuplicateCustomizationSpec(ctx context.Context, name string, newName string) error
- func (cs CustomizationSpecManager) GetCustomizationSpec(ctx context.Context, name string) (*types.CustomizationSpecItem, error)
- func (cs CustomizationSpecManager) Info(ctx context.Context) ([]types.CustomizationSpecInfo, error)
- func (cs CustomizationSpecManager) OverwriteCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error
- func (cs CustomizationSpecManager) RenameCustomizationSpec(ctx context.Context, name string, newName string) error
- func (cs CustomizationSpecManager) XmlToCustomizationSpecItem(ctx context.Context, xml string) (*types.CustomizationSpecItem, error)
- type Datacenter
- type DatacenterFolders
- type Datastore
- func (d Datastore) AttachedClusterHosts(ctx context.Context, cluster *ComputeResource) ([]*HostSystem, error)
- func (d Datastore) AttachedHosts(ctx context.Context) ([]*HostSystem, error)
- func (d Datastore) Browser(ctx context.Context) (*HostDatastoreBrowser, error)
- func (d Datastore) Download(ctx context.Context, path string, param *soap.Download) (io.ReadCloser, int64, error)
- func (d Datastore) DownloadFile(ctx context.Context, path string, file string, param *soap.Download) error
- func (d Datastore) HostContext(ctx context.Context, host *HostSystem) context.Context
- func (d Datastore) NewFileManager(dc *Datacenter, force bool) *DatastoreFileManager
- func (d Datastore) NewURL(path string) *url.URL
- func (d Datastore) Open(ctx context.Context, name string) (*DatastoreFile, error)
- func (d Datastore) Path(path string) string
- func (d Datastore) ServiceTicket(ctx context.Context, path string, method string) (*url.URL, *http.Cookie, error)
- func (d Datastore) Stat(ctx context.Context, file string) (types.BaseFileInfo, error)
- func (d Datastore) Type(ctx context.Context) (types.HostFileSystemVolumeFileSystemType, error)
- func (d Datastore) URL(ctx context.Context, dc *Datacenter, path string) (*url.URL, error)
- func (d Datastore) Upload(ctx context.Context, f io.Reader, path string, param *soap.Upload) error
- func (d Datastore) UploadFile(ctx context.Context, file string, path string, param *soap.Upload) error
- type DatastoreFile
- func (f *DatastoreFile) Close() error
- func (f *DatastoreFile) Follow(interval time.Duration) io.ReadCloser
- func (f *DatastoreFile) Read(b []byte) (int, error)
- func (f *DatastoreFile) Seek(offset int64, whence int) (int64, error)
- func (f *DatastoreFile) Stat() (os.FileInfo, error)
- func (f *DatastoreFile) Tail(n int) error
- func (f *DatastoreFile) TailFunc(lines int, include func(line int, message string) bool) error
- type DatastoreFileManager
- func (m *DatastoreFileManager) Copy(ctx context.Context, src string, dst string) error
- func (m *DatastoreFileManager) CopyFile(ctx context.Context, src string, dst string) error
- func (m *DatastoreFileManager) Delete(ctx context.Context, name string) error
- func (m *DatastoreFileManager) DeleteFile(ctx context.Context, name string) error
- func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Context, name string) error
- func (m *DatastoreFileManager) Move(ctx context.Context, src string, dst string) error
- func (m *DatastoreFileManager) MoveFile(ctx context.Context, src string, dst string) error
- func (m *DatastoreFileManager) Path(name string) *DatastorePath
- func (m *DatastoreFileManager) WithProgress(ctx context.Context, s progress.Sinker) context.Context
- type DatastoreNamespaceManager
- type DatastoreNoSuchDirectoryError
- type DatastoreNoSuchFileError
- type DatastorePath
- type DiagnosticLog
- type DiagnosticManager
- func (m DiagnosticManager) BrowseLog(ctx context.Context, host *HostSystem, key string, start, lines int32) (*types.DiagnosticManagerLogHeader, error)
- func (m DiagnosticManager) GenerateLogBundles(ctx context.Context, includeDefault bool, host []*HostSystem) (*Task, error)
- func (m DiagnosticManager) Log(ctx context.Context, host *HostSystem, key string) *DiagnosticLog
- func (m DiagnosticManager) QueryDescriptions(ctx context.Context, host *HostSystem) ([]types.DiagnosticManagerLogDescriptor, error)
- type DisabledMethodRequest
- type DistributedVirtualPortgroup
- func (p DistributedVirtualPortgroup) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error)
- func (p DistributedVirtualPortgroup) GetInventoryPath() string
- func (p DistributedVirtualPortgroup) Reconfigure(ctx context.Context, spec types.DVPortgroupConfigSpec) (*Task, error)
- type DistributedVirtualSwitch
- func (s DistributedVirtualSwitch) AddPortgroup(ctx context.Context, spec []types.DVPortgroupConfigSpec) (*Task, error)
- func (s DistributedVirtualSwitch) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error)
- func (s DistributedVirtualSwitch) FetchDVPorts(ctx context.Context, criteria *types.DistributedVirtualSwitchPortCriteria) ([]types.DistributedVirtualPort, error)
- func (s DistributedVirtualSwitch) GetInventoryPath() string
- func (s DistributedVirtualSwitch) Reconfigure(ctx context.Context, spec types.BaseDVSConfigSpec) (*Task, error)
- func (s DistributedVirtualSwitch) ReconfigureDVPort(ctx context.Context, spec []types.DVPortConfigSpec) (*Task, error)
- func (s DistributedVirtualSwitch) ReconfigureLACP(ctx context.Context, spec []types.VMwareDvsLacpGroupSpec) (*Task, error)
- type ExtensionManager
- func (m ExtensionManager) Find(ctx context.Context, key string) (*types.Extension, error)
- func (m ExtensionManager) List(ctx context.Context) ([]types.Extension, error)
- func (m ExtensionManager) Register(ctx context.Context, extension types.Extension) error
- func (m ExtensionManager) SetCertificate(ctx context.Context, key string, certificatePem string) error
- func (m ExtensionManager) Unregister(ctx context.Context, key string) error
- func (m ExtensionManager) Update(ctx context.Context, extension types.Extension) error
- type FileManager
- func (f FileManager) CopyDatastoreFile(ctx context.Context, sourceName string, sourceDatacenter *Datacenter, ...) (*Task, error)
- func (f FileManager) DeleteDatastoreFile(ctx context.Context, name string, dc *Datacenter) (*Task, error)
- func (f FileManager) MakeDirectory(ctx context.Context, name string, dc *Datacenter, createParentDirectories bool) error
- func (f FileManager) MoveDatastoreFile(ctx context.Context, sourceName string, sourceDatacenter *Datacenter, ...) (*Task, error)
- type Folder
- func (f Folder) AddStandaloneHost(ctx context.Context, spec types.HostConnectSpec, addConnected bool, ...) (*Task, error)
- func (f Folder) Children(ctx context.Context) ([]Reference, error)
- func (f Folder) CreateCluster(ctx context.Context, cluster string, spec types.ClusterConfigSpecEx) (*ClusterComputeResource, error)
- func (f Folder) CreateDVS(ctx context.Context, spec types.DVSCreateSpec) (*Task, error)
- func (f Folder) CreateDatacenter(ctx context.Context, datacenter string) (*Datacenter, error)
- func (f Folder) CreateFolder(ctx context.Context, name string) (*Folder, error)
- func (f Folder) CreateStoragePod(ctx context.Context, name string) (*StoragePod, error)
- func (f Folder) CreateVM(ctx context.Context, config types.VirtualMachineConfigSpec, pool *ResourcePool, ...) (*Task, error)
- func (f Folder) MoveInto(ctx context.Context, list []types.ManagedObjectReference) (*Task, error)
- func (f Folder) PlaceVmsXCluster(ctx context.Context, spec types.PlaceVmsXClusterSpec) (*types.PlaceVmsXClusterResult, error)
- func (f Folder) RegisterVM(ctx context.Context, path string, name string, asTemplate bool, ...) (*Task, error)
- type HostAccountManager
- type HostCertificateInfo
- func (info *HostCertificateInfo) FromCertificate(cert *x509.Certificate) *HostCertificateInfo
- func (info *HostCertificateInfo) FromURL(u *url.URL, config *tls.Config) error
- func (info *HostCertificateInfo) IssuerName() *pkix.Name
- func (info *HostCertificateInfo) SubjectName() *pkix.Name
- func (info *HostCertificateInfo) Write(w io.Writer) error
- type HostCertificateManager
- func (m HostCertificateManager) CertificateInfo(ctx context.Context) (*HostCertificateInfo, error)
- func (m HostCertificateManager) GenerateCertificateSigningRequest(ctx context.Context, useIPAddressAsCommonName bool) (string, error)
- func (m HostCertificateManager) GenerateCertificateSigningRequestByDn(ctx context.Context, distinguishedName string) (string, error)
- func (m HostCertificateManager) InstallServerCertificate(ctx context.Context, cert string) error
- func (m HostCertificateManager) ListCACertificateRevocationLists(ctx context.Context) ([]string, error)
- func (m HostCertificateManager) ListCACertificates(ctx context.Context) ([]string, error)
- func (m HostCertificateManager) ReplaceCACertificatesAndCRLs(ctx context.Context, caCert []string, caCrl []string) error
- type HostConfigManager
- func (m HostConfigManager) AccountManager(ctx context.Context) (*HostAccountManager, error)
- func (m HostConfigManager) CertificateManager(ctx context.Context) (*HostCertificateManager, error)
- func (m HostConfigManager) DatastoreSystem(ctx context.Context) (*HostDatastoreSystem, error)
- func (m HostConfigManager) DateTimeSystem(ctx context.Context) (*HostDateTimeSystem, error)
- func (m HostConfigManager) FirewallSystem(ctx context.Context) (*HostFirewallSystem, error)
- func (m HostConfigManager) NetworkSystem(ctx context.Context) (*HostNetworkSystem, error)
- func (m HostConfigManager) OptionManager(ctx context.Context) (*OptionManager, error)
- func (m HostConfigManager) ServiceSystem(ctx context.Context) (*HostServiceSystem, error)
- func (m HostConfigManager) StorageSystem(ctx context.Context) (*HostStorageSystem, error)
- func (m HostConfigManager) VirtualNicManager(ctx context.Context) (*HostVirtualNicManager, error)
- func (m HostConfigManager) VsanInternalSystem(ctx context.Context) (*HostVsanInternalSystem, error)
- func (m HostConfigManager) VsanSystem(ctx context.Context) (*HostVsanSystem, error)
- type HostDatastoreBrowser
- type HostDatastoreSystem
- func (s HostDatastoreSystem) CreateLocalDatastore(ctx context.Context, name string, path string) (*Datastore, error)
- func (s HostDatastoreSystem) CreateNasDatastore(ctx context.Context, spec types.HostNasVolumeSpec) (*Datastore, error)
- func (s HostDatastoreSystem) CreateVmfsDatastore(ctx context.Context, spec types.VmfsDatastoreCreateSpec) (*Datastore, error)
- func (s HostDatastoreSystem) QueryAvailableDisksForVmfs(ctx context.Context) ([]types.HostScsiDisk, error)
- func (s HostDatastoreSystem) QueryVmfsDatastoreCreateOptions(ctx context.Context, devicePath string) ([]types.VmfsDatastoreOption, error)
- func (s HostDatastoreSystem) Remove(ctx context.Context, ds *Datastore) error
- func (s HostDatastoreSystem) ResignatureUnresolvedVmfsVolumes(ctx context.Context, devicePaths []string) (*Task, error)
- type HostDateTimeSystem
- type HostFirewallRulesetList
- func (l HostFirewallRulesetList) ByRule(rule types.HostFirewallRule) HostFirewallRulesetList
- func (l HostFirewallRulesetList) Disabled() HostFirewallRulesetList
- func (l HostFirewallRulesetList) Enabled() HostFirewallRulesetList
- func (l HostFirewallRulesetList) EnabledByRule(rule types.HostFirewallRule, enabled bool) (HostFirewallRulesetList, error)
- func (l HostFirewallRulesetList) Keys() []string
- type HostFirewallSystem
- func (s HostFirewallSystem) DisableRuleset(ctx context.Context, id string) error
- func (s HostFirewallSystem) EnableRuleset(ctx context.Context, id string) error
- func (s HostFirewallSystem) Info(ctx context.Context) (*types.HostFirewallInfo, error)
- func (s HostFirewallSystem) Refresh(ctx context.Context) error
- type HostNetworkSystem
- func (o HostNetworkSystem) AddPortGroup(ctx context.Context, portgrp types.HostPortGroupSpec) error
- func (o HostNetworkSystem) AddServiceConsoleVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error)
- func (o HostNetworkSystem) AddVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error)
- func (o HostNetworkSystem) AddVirtualSwitch(ctx context.Context, vswitchName string, spec *types.HostVirtualSwitchSpec) error
- func (o HostNetworkSystem) QueryNetworkHint(ctx context.Context, device []string) ([]types.PhysicalNicHintInfo, error)
- func (o HostNetworkSystem) RefreshNetworkSystem(ctx context.Context) error
- func (o HostNetworkSystem) RemovePortGroup(ctx context.Context, pgName string) error
- func (o HostNetworkSystem) RemoveServiceConsoleVirtualNic(ctx context.Context, device string) error
- func (o HostNetworkSystem) RemoveVirtualNic(ctx context.Context, device string) error
- func (o HostNetworkSystem) RemoveVirtualSwitch(ctx context.Context, vswitchName string) error
- func (o HostNetworkSystem) RestartServiceConsoleVirtualNic(ctx context.Context, device string) error
- func (o HostNetworkSystem) UpdateConsoleIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error
- func (o HostNetworkSystem) UpdateDnsConfig(ctx context.Context, config types.BaseHostDnsConfig) error
- func (o HostNetworkSystem) UpdateIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error
- func (o HostNetworkSystem) UpdateIpRouteTableConfig(ctx context.Context, config types.HostIpRouteTableConfig) error
- func (o HostNetworkSystem) UpdateNetworkConfig(ctx context.Context, config types.HostNetworkConfig, changeMode string) (*types.HostNetworkConfigResult, error)
- func (o HostNetworkSystem) UpdatePhysicalNicLinkSpeed(ctx context.Context, device string, linkSpeed *types.PhysicalNicLinkInfo) error
- func (o HostNetworkSystem) UpdatePortGroup(ctx context.Context, pgName string, portgrp types.HostPortGroupSpec) error
- func (o HostNetworkSystem) UpdateServiceConsoleVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error
- func (o HostNetworkSystem) UpdateVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error
- func (o HostNetworkSystem) UpdateVirtualSwitch(ctx context.Context, vswitchName string, spec types.HostVirtualSwitchSpec) error
- type HostServiceSystem
- func (s HostServiceSystem) Restart(ctx context.Context, id string) error
- func (s HostServiceSystem) Service(ctx context.Context) ([]types.HostService, error)
- func (s HostServiceSystem) Start(ctx context.Context, id string) error
- func (s HostServiceSystem) Stop(ctx context.Context, id string) error
- func (s HostServiceSystem) UpdatePolicy(ctx context.Context, id string, policy string) error
- type HostStorageSystem
- func (s HostStorageSystem) AttachScsiLun(ctx context.Context, uuid string) error
- func (s HostStorageSystem) ComputeDiskPartitionInfo(ctx context.Context, devicePath string, layout types.HostDiskPartitionLayout) (*types.HostDiskPartitionInfo, error)
- func (s HostStorageSystem) MarkAsLocal(ctx context.Context, uuid string) (*Task, error)
- func (s HostStorageSystem) MarkAsNonLocal(ctx context.Context, uuid string) (*Task, error)
- func (s HostStorageSystem) MarkAsNonSsd(ctx context.Context, uuid string) (*Task, error)
- func (s HostStorageSystem) MarkAsSsd(ctx context.Context, uuid string) (*Task, error)
- func (s HostStorageSystem) QueryUnresolvedVmfsVolumes(ctx context.Context) ([]types.HostUnresolvedVmfsVolume, error)
- func (s HostStorageSystem) Refresh(ctx context.Context) error
- func (s HostStorageSystem) RescanAllHba(ctx context.Context) error
- func (s HostStorageSystem) RescanVmfs(ctx context.Context) error
- func (s HostStorageSystem) RetrieveDiskPartitionInfo(ctx context.Context, devicePath string) (*types.HostDiskPartitionInfo, error)
- func (s HostStorageSystem) UnmountVmfsVolume(ctx context.Context, vmfsUuid string) error
- func (s HostStorageSystem) UpdateDiskPartitionInfo(ctx context.Context, devicePath string, spec types.HostDiskPartitionSpec) error
- type HostSystem
- func (h HostSystem) ConfigManager() *HostConfigManager
- func (h HostSystem) Disconnect(ctx context.Context) (*Task, error)
- func (h HostSystem) EnterMaintenanceMode(ctx context.Context, timeout int32, evacuate bool, ...) (*Task, error)
- func (h HostSystem) ExitMaintenanceMode(ctx context.Context, timeout int32) (*Task, error)
- func (h HostSystem) ManagementIPs(ctx context.Context) ([]net.IP, error)
- func (h HostSystem) Reconnect(ctx context.Context, cnxSpec *types.HostConnectSpec, ...) (*Task, error)
- func (h HostSystem) ResourcePool(ctx context.Context) (*ResourcePool, error)
- type HostVirtualNicManager
- func (m HostVirtualNicManager) DeselectVnic(ctx context.Context, nicType string, device string) error
- func (m HostVirtualNicManager) Info(ctx context.Context) (*types.HostVirtualNicManagerInfo, error)
- func (m HostVirtualNicManager) SelectVnic(ctx context.Context, nicType string, device string) error
- type HostVsanInternalSystem
- func (m HostVsanInternalSystem) DeleteVsanObjects(ctx context.Context, uuids []string, force *bool) ([]types.HostVsanInternalSystemDeleteVsanObjectsResult, error)
- func (m HostVsanInternalSystem) GetVsanObjExtAttrs(ctx context.Context, uuids []string) (map[string]VsanObjExtAttrs, error)
- func (m HostVsanInternalSystem) QueryVsanObjectUuidsByFilter(ctx context.Context, uuids []string, limit int32, version int32) ([]string, error)
- type HostVsanSystem
- type Network
- type NetworkReference
- type OpaqueNetwork
- type OptionManager
- type Reference
- type ResourcePool
- func (p ResourcePool) Create(ctx context.Context, name string, spec types.ResourceConfigSpec) (*ResourcePool, error)
- func (p ResourcePool) CreateVApp(ctx context.Context, name string, resSpec types.ResourceConfigSpec, ...) (*VirtualApp, error)
- func (p ResourcePool) Destroy(ctx context.Context) (*Task, error)
- func (p ResourcePool) DestroyChildren(ctx context.Context) error
- func (p ResourcePool) ImportVApp(ctx context.Context, spec types.BaseImportSpec, folder *Folder, ...) (*nfc.Lease, error)
- func (p ResourcePool) Owner(ctx context.Context) (Reference, error)
- func (p ResourcePool) UpdateConfig(ctx context.Context, name string, config *types.ResourceConfigSpec) error
- type SearchIndex
- func (s SearchIndex) FindAllByDnsName(ctx context.Context, dc *Datacenter, dnsName string, vmSearch bool) ([]Reference, error)
- func (s SearchIndex) FindAllByIp(ctx context.Context, dc *Datacenter, ip string, vmSearch bool) ([]Reference, error)
- func (s SearchIndex) FindAllByUuid(ctx context.Context, dc *Datacenter, uuid string, vmSearch bool, ...) ([]Reference, error)
- func (s SearchIndex) FindByDatastorePath(ctx context.Context, dc *Datacenter, path string) (Reference, error)
- func (s SearchIndex) FindByDnsName(ctx context.Context, dc *Datacenter, dnsName string, vmSearch bool) (Reference, error)
- func (s SearchIndex) FindByInventoryPath(ctx context.Context, path string) (Reference, error)
- func (s SearchIndex) FindByIp(ctx context.Context, dc *Datacenter, ip string, vmSearch bool) (Reference, error)
- func (s SearchIndex) FindByUuid(ctx context.Context, dc *Datacenter, uuid string, vmSearch bool, ...) (Reference, error)
- func (s SearchIndex) FindChild(ctx context.Context, entity Reference, name string) (Reference, error)
- type StoragePod
- type StorageResourceManager
- func (sr StorageResourceManager) ApplyStorageDrsRecommendation(ctx context.Context, key []string) (*Task, error)
- func (sr StorageResourceManager) ApplyStorageDrsRecommendationToPod(ctx context.Context, pod *StoragePod, key string) (*Task, error)
- func (sr StorageResourceManager) CancelStorageDrsRecommendation(ctx context.Context, key []string) error
- func (sr StorageResourceManager) ConfigureDatastoreIORM(ctx context.Context, datastore *Datastore, spec types.StorageIORMConfigSpec, ...) (*Task, error)
- func (sr StorageResourceManager) ConfigureStorageDrsForPod(ctx context.Context, pod *StoragePod, spec types.StorageDrsConfigSpec, ...) (*Task, error)
- func (sr StorageResourceManager) QueryDatastorePerformanceSummary(ctx context.Context, datastore *Datastore) ([]types.StoragePerformanceSummary, error)
- func (sr StorageResourceManager) QueryIORMConfigOption(ctx context.Context, host *HostSystem) (*types.StorageIORMConfigOption, error)
- func (sr StorageResourceManager) RecommendDatastores(ctx context.Context, storageSpec types.StoragePlacementSpec) (*types.StoragePlacementResult, error)
- func (sr StorageResourceManager) RefreshStorageDrsRecommendation(ctx context.Context, pod *StoragePod) error
- type Task
- func (t *Task) Cancel(ctx context.Context) error
- func (t *Task) SetDescription(ctx context.Context, description types.LocalizableMessage) error
- func (t *Task) SetState(ctx context.Context, state types.TaskInfoState, result types.AnyType, ...) error
- func (t *Task) UpdateProgress(ctx context.Context, percentDone int) error
- func (t *Task) Wait(ctx context.Context) error
- func (t *Task) WaitForResult(ctx context.Context, s ...progress.Sinker) (*types.TaskInfo, error)
- type TenantManager
- func (t TenantManager) MarkServiceProviderEntities(ctx context.Context, entities []types.ManagedObjectReference) error
- func (t TenantManager) RetrieveServiceProviderEntities(ctx context.Context) ([]types.ManagedObjectReference, error)
- func (t TenantManager) UnmarkServiceProviderEntities(ctx context.Context, entities []types.ManagedObjectReference) error
- type VirtualApp
- func (p VirtualApp) Clone(ctx context.Context, name string, target types.ManagedObjectReference, ...) (*Task, error)
- func (p VirtualApp) CreateChildVM(ctx context.Context, config types.VirtualMachineConfigSpec, host *HostSystem) (*Task, error)
- func (p VirtualApp) PowerOff(ctx context.Context, force bool) (*Task, error)
- func (p VirtualApp) PowerOn(ctx context.Context) (*Task, error)
- func (p VirtualApp) Suspend(ctx context.Context) (*Task, error)
- func (p VirtualApp) UpdateConfig(ctx context.Context, spec types.VAppConfigSpec) error
- type VirtualDeviceList
- func (l VirtualDeviceList) AssignController(device types.BaseVirtualDevice, c types.BaseVirtualController)
- func (l VirtualDeviceList) BootOrder(order []string) []types.BaseVirtualMachineBootOptionsBootableDevice
- func (l VirtualDeviceList) ChildDisk(parent *types.VirtualDisk) *types.VirtualDisk
- func (l VirtualDeviceList) ConfigSpec(op types.VirtualDeviceConfigSpecOperation) ([]types.BaseVirtualDeviceConfigSpec, error)
- func (l VirtualDeviceList) Connect(device types.BaseVirtualDevice) error
- func (l VirtualDeviceList) ConnectSerialPort(device *types.VirtualSerialPort, uri string, client bool, proxyuri string) *types.VirtualSerialPort
- func (l VirtualDeviceList) CreateCdrom(c *types.VirtualIDEController) (*types.VirtualCdrom, error)
- func (l VirtualDeviceList) CreateDisk(c types.BaseVirtualController, ds types.ManagedObjectReference, name string) *types.VirtualDisk
- func (l VirtualDeviceList) CreateEthernetCard(name string, backing types.BaseVirtualDeviceBackingInfo) (types.BaseVirtualDevice, error)
- func (l VirtualDeviceList) CreateFloppy() (*types.VirtualFloppy, error)
- func (l VirtualDeviceList) CreateIDEController() (types.BaseVirtualDevice, error)
- func (l VirtualDeviceList) CreateNVMEController() (types.BaseVirtualDevice, error)
- func (l VirtualDeviceList) CreateSCSIController(name string) (types.BaseVirtualDevice, error)
- func (l VirtualDeviceList) CreateSerialPort() (*types.VirtualSerialPort, error)
- func (l VirtualDeviceList) Disconnect(device types.BaseVirtualDevice) error
- func (l VirtualDeviceList) DisconnectSerialPort(device *types.VirtualSerialPort) *types.VirtualSerialPort
- func (l VirtualDeviceList) EjectImg(device *types.VirtualFloppy) *types.VirtualFloppy
- func (l VirtualDeviceList) EjectIso(device *types.VirtualCdrom) *types.VirtualCdrom
- func (l VirtualDeviceList) Find(name string) types.BaseVirtualDevice
- func (l VirtualDeviceList) FindByKey(key int32) types.BaseVirtualDevice
- func (l VirtualDeviceList) FindCdrom(name string) (*types.VirtualCdrom, error)
- func (l VirtualDeviceList) FindDiskController(name string) (types.BaseVirtualController, error)
- func (l VirtualDeviceList) FindFloppy(name string) (*types.VirtualFloppy, error)
- func (l VirtualDeviceList) FindIDEController(name string) (*types.VirtualIDEController, error)
- func (l VirtualDeviceList) FindNVMEController(name string) (*types.VirtualNVMEController, error)
- func (l VirtualDeviceList) FindSCSIController(name string) (*types.VirtualSCSIController, error)
- func (l VirtualDeviceList) FindSerialPort(name string) (*types.VirtualSerialPort, error)
- func (l VirtualDeviceList) InsertImg(device *types.VirtualFloppy, img string) *types.VirtualFloppy
- func (l VirtualDeviceList) InsertIso(device *types.VirtualCdrom, iso string) *types.VirtualCdrom
- func (l VirtualDeviceList) Name(device types.BaseVirtualDevice) string
- func (l VirtualDeviceList) NewKey() int32
- func (l VirtualDeviceList) PickController(kind types.BaseVirtualController) types.BaseVirtualController
- func (l VirtualDeviceList) PrimaryMacAddress() string
- func (l VirtualDeviceList) Select(f func(device types.BaseVirtualDevice) bool) VirtualDeviceList
- func (l VirtualDeviceList) SelectBootOrder(order []types.BaseVirtualMachineBootOptionsBootableDevice) VirtualDeviceList
- func (l VirtualDeviceList) SelectByBackingInfo(backing types.BaseVirtualDeviceBackingInfo) VirtualDeviceList
- func (l VirtualDeviceList) SelectByType(deviceType types.BaseVirtualDevice) VirtualDeviceList
- func (l VirtualDeviceList) Type(device types.BaseVirtualDevice) string
- func (l VirtualDeviceList) TypeName(device types.BaseVirtualDevice) string
- type VirtualDiskInfo
- type VirtualDiskManager
- func (m VirtualDiskManager) CopyVirtualDisk(ctx context.Context, sourceName string, sourceDatacenter *Datacenter, ...) (*Task, error)
- func (m VirtualDiskManager) CreateChildDisk(ctx context.Context, parent string, pdc *Datacenter, name string, ...) (*Task, error)
- func (m VirtualDiskManager) CreateVirtualDisk(ctx context.Context, name string, datacenter *Datacenter, ...) (*Task, error)
- func (m VirtualDiskManager) DeleteVirtualDisk(ctx context.Context, name string, dc *Datacenter) (*Task, error)
- func (m VirtualDiskManager) InflateVirtualDisk(ctx context.Context, name string, dc *Datacenter) (*Task, error)
- func (m VirtualDiskManager) MoveVirtualDisk(ctx context.Context, sourceName string, sourceDatacenter *Datacenter, ...) (*Task, error)
- func (m VirtualDiskManager) QueryVirtualDiskInfo(ctx context.Context, name string, dc *Datacenter, includeParents bool) ([]VirtualDiskInfo, error)
- func (m VirtualDiskManager) QueryVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter) (string, error)
- func (m VirtualDiskManager) SetVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter, uuid string) error
- func (m VirtualDiskManager) ShrinkVirtualDisk(ctx context.Context, name string, dc *Datacenter, copy *bool) (*Task, error)
- type VirtualMachine
- func (v VirtualMachine) AcquireTicket(ctx context.Context, kind string) (*types.VirtualMachineTicket, error)
- func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
- func (v VirtualMachine) Answer(ctx context.Context, id, answer string) error
- func (v VirtualMachine) AttachDisk(ctx context.Context, id string, datastore *Datastore, controllerKey int32, ...) error
- func (v VirtualMachine) BootOptions(ctx context.Context) (*types.VirtualMachineBootOptions, error)
- func (v VirtualMachine) Clone(ctx context.Context, folder *Folder, name string, ...) (*Task, error)
- func (v VirtualMachine) CreateSnapshot(ctx context.Context, name string, description string, memory bool, ...) (*Task, error)
- func (v VirtualMachine) Customize(ctx context.Context, spec types.CustomizationSpec) (*Task, error)
- func (v VirtualMachine) Destroy(ctx context.Context) (*Task, error)
- func (v VirtualMachine) DetachDisk(ctx context.Context, id string) error
- func (v VirtualMachine) Device(ctx context.Context) (VirtualDeviceList, error)
- func (v VirtualMachine) EditDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
- func (v VirtualMachine) Export(ctx context.Context) (*nfc.Lease, error)
- func (v *VirtualMachine) ExportSnapshot(ctx context.Context, snapshot *types.ManagedObjectReference) (*nfc.Lease, error)
- func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (*types.ManagedObjectReference, error)
- func (v VirtualMachine) HostSystem(ctx context.Context) (*HostSystem, error)
- func (v VirtualMachine) InstantClone(ctx context.Context, config types.VirtualMachineInstantCloneSpec) (*Task, error)
- func (v VirtualMachine) IsTemplate(ctx context.Context) (bool, error)
- func (v VirtualMachine) IsToolsRunning(ctx context.Context) (bool, error)
- func (v VirtualMachine) MarkAsTemplate(ctx context.Context) error
- func (v VirtualMachine) MarkAsVirtualMachine(ctx context.Context, pool ResourcePool, host *HostSystem) error
- func (v VirtualMachine) Migrate(ctx context.Context, pool *ResourcePool, host *HostSystem, ...) (*Task, error)
- func (v VirtualMachine) MountToolsInstaller(ctx context.Context) error
- func (v VirtualMachine) PowerOff(ctx context.Context) (*Task, error)
- func (v VirtualMachine) PowerOn(ctx context.Context) (*Task, error)
- func (v VirtualMachine) PowerState(ctx context.Context) (types.VirtualMachinePowerState, error)
- func (v VirtualMachine) PutUsbScanCodes(ctx context.Context, spec types.UsbScanCodeSpec) (int32, error)
- func (v VirtualMachine) QueryChangedDiskAreas(ctx context.Context, baseSnapshot, curSnapshot *types.ManagedObjectReference, ...) (types.DiskChangeInfo, error)
- func (v VirtualMachine) QueryConfigTarget(ctx context.Context) (*types.ConfigTarget, error)
- func (v VirtualMachine) RebootGuest(ctx context.Context) error
- func (v VirtualMachine) Reconfigure(ctx context.Context, config types.VirtualMachineConfigSpec) (*Task, error)
- func (v VirtualMachine) RefreshStorageInfo(ctx context.Context) error
- func (v VirtualMachine) Relocate(ctx context.Context, config types.VirtualMachineRelocateSpec, ...) (*Task, error)
- func (v VirtualMachine) RemoveAllSnapshot(ctx context.Context, consolidate *bool) (*Task, error)
- func (v VirtualMachine) RemoveDevice(ctx context.Context, keepFiles bool, device ...types.BaseVirtualDevice) error
- func (v VirtualMachine) RemoveSnapshot(ctx context.Context, name string, removeChildren bool, consolidate *bool) (*Task, error)
- func (v VirtualMachine) Reset(ctx context.Context) (*Task, error)
- func (v VirtualMachine) ResourcePool(ctx context.Context) (*ResourcePool, error)
- func (v VirtualMachine) RevertToCurrentSnapshot(ctx context.Context, suppressPowerOn bool) (*Task, error)
- func (v VirtualMachine) RevertToSnapshot(ctx context.Context, name string, suppressPowerOn bool) (*Task, error)
- func (v VirtualMachine) SetBootOptions(ctx context.Context, options *types.VirtualMachineBootOptions) error
- func (v VirtualMachine) ShutdownGuest(ctx context.Context) error
- func (v VirtualMachine) StandbyGuest(ctx context.Context) error
- func (v VirtualMachine) Suspend(ctx context.Context) (*Task, error)
- func (v VirtualMachine) UUID(ctx context.Context) string
- func (v VirtualMachine) UnmountToolsInstaller(ctx context.Context) error
- func (v VirtualMachine) Unregister(ctx context.Context) error
- func (v VirtualMachine) UpgradeTools(ctx context.Context, options string) (*Task, error)
- func (v VirtualMachine) UpgradeVM(ctx context.Context, version string) (*Task, error)
- func (v VirtualMachine) WaitForIP(ctx context.Context, v4 ...bool) (string, error)
- func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...string) (map[string][]string, error)
- func (v VirtualMachine) WaitForPowerState(ctx context.Context, state types.VirtualMachinePowerState) error
- type VmwareDistributedVirtualSwitch
- type VsanObjExtAttrs
Examples ¶
- Common.Destroy
- Common.Rename
- CustomFieldsManager.Set
- CustomizationSpecManager.Info
- Folder.CreateVM
- HostConfigManager.OptionManager
- ResourcePool.Owner
- VirtualDeviceList.SelectByBackingInfo
- VirtualMachine (ResourcePoolOwner)
- VirtualMachine.Clone
- VirtualMachine.CreateSnapshot
- VirtualMachine.Customize
- VirtualMachine.HostSystem
- VirtualMachine.Reconfigure
- VirtualMachine.ResourcePool
Constants ¶
const ( DeviceTypeNone = "-" DeviceTypeCdrom = "cdrom" DeviceTypeDisk = "disk" DeviceTypeEthernet = "ethernet" DeviceTypeFloppy = "floppy" )
Type values for use in BootOrder
const ( PropRuntimePowerState = "summary.runtime.powerState" PropConfigTemplate = "summary.config.template" )
Variables ¶
var (
ErrKeyNameNotFound = errors.New("key name not found")
)
var (
ErrNotSupported = errors.New("product/version specific feature not supported by target")
)
Functions ¶
func ReferenceFromString ¶
func ReferenceFromString(s string) *types.ManagedObjectReference
func SnapshotSize ¶
func SnapshotSize(info types.ManagedObjectReference, parent *types.ManagedObjectReference, vmlayout *types.VirtualMachineFileLayoutEx, isCurrent bool) int
SnapshotSize calculates the size of a given snapshot in bytes. If the snapshot is current, disk files not associated with any parent snapshot are included in size calculations. This allows for measuring and including the growth from the last fixed snapshot to the present state.
Types ¶
type AuthorizationManager ¶
type AuthorizationManager struct {
Common
}
func NewAuthorizationManager ¶
func NewAuthorizationManager(c *vim25.Client) *AuthorizationManager
func (AuthorizationManager) DisableMethods ¶
func (m AuthorizationManager) DisableMethods(ctx context.Context, entity []types.ManagedObjectReference, method []DisabledMethodRequest, source string) error
func (AuthorizationManager) EnableMethods ¶
func (m AuthorizationManager) EnableMethods(ctx context.Context, entity []types.ManagedObjectReference, method []string, source string) error
func (AuthorizationManager) FetchUserPrivilegeOnEntities ¶
func (m AuthorizationManager) FetchUserPrivilegeOnEntities(ctx context.Context, entities []types.ManagedObjectReference, userName string) ([]types.UserPrivilegeResult, error)
func (AuthorizationManager) HasPrivilegeOnEntity ¶
func (m AuthorizationManager) HasPrivilegeOnEntity(ctx context.Context, entity types.ManagedObjectReference, sessionID string, privID []string) ([]bool, error)
func (AuthorizationManager) HasUserPrivilegeOnEntities ¶
func (m AuthorizationManager) HasUserPrivilegeOnEntities(ctx context.Context, entities []types.ManagedObjectReference, userName string, privID []string) ([]types.EntityPrivilege, error)
func (AuthorizationManager) RemoveEntityPermission ¶
func (m AuthorizationManager) RemoveEntityPermission(ctx context.Context, entity types.ManagedObjectReference, user string, isGroup bool) error
func (AuthorizationManager) RemoveRole ¶
func (AuthorizationManager) RetrieveAllPermissions ¶
func (m AuthorizationManager) RetrieveAllPermissions(ctx context.Context) ([]types.Permission, error)
func (AuthorizationManager) RetrieveEntityPermissions ¶
func (m AuthorizationManager) RetrieveEntityPermissions(ctx context.Context, entity types.ManagedObjectReference, inherited bool) ([]types.Permission, error)
func (AuthorizationManager) RetrieveRolePermissions ¶
func (m AuthorizationManager) RetrieveRolePermissions(ctx context.Context, id int32) ([]types.Permission, error)
func (AuthorizationManager) RoleList ¶
func (m AuthorizationManager) RoleList(ctx context.Context) (AuthorizationRoleList, error)
func (AuthorizationManager) SetEntityPermissions ¶
func (m AuthorizationManager) SetEntityPermissions(ctx context.Context, entity types.ManagedObjectReference, permission []types.Permission) error
func (AuthorizationManager) UpdateRole ¶
type AuthorizationRoleList ¶
type AuthorizationRoleList []types.AuthorizationRole
func (AuthorizationRoleList) ById ¶
func (l AuthorizationRoleList) ById(id int32) *types.AuthorizationRole
func (AuthorizationRoleList) ByName ¶
func (l AuthorizationRoleList) ByName(name string) *types.AuthorizationRole
type ClusterComputeResource ¶
type ClusterComputeResource struct {
ComputeResource
}
func NewClusterComputeResource ¶
func NewClusterComputeResource(c *vim25.Client, ref types.ManagedObjectReference) *ClusterComputeResource
func (ClusterComputeResource) AddHost ¶
func (c ClusterComputeResource) AddHost(ctx context.Context, spec types.HostConnectSpec, asConnected bool, license *string, resourcePool *types.ManagedObjectReference) (*Task, error)
func (ClusterComputeResource) Configuration ¶
func (c ClusterComputeResource) Configuration(ctx context.Context) (*types.ClusterConfigInfoEx, error)
func (ClusterComputeResource) MoveInto ¶
func (c ClusterComputeResource) MoveInto(ctx context.Context, hosts ...*HostSystem) (*Task, error)
func (ClusterComputeResource) PlaceVm ¶
func (c ClusterComputeResource) PlaceVm(ctx context.Context, spec types.PlacementSpec) (*types.PlacementResult, error)
type Common ¶
type Common struct { InventoryPath string // contains filtered or unexported fields }
Common contains the fields and functions common to all objects.
func (Common) Destroy ¶
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" ) func main() { model := simulator.VPX() model.Datastore = 2 simulator.Run(func(ctx context.Context, c *vim25.Client) error { // Change to "LocalDS_0" will cause ResourceInUse error, // as simulator VMs created by the VPX model use "LocalDS_0". ds, err := find.NewFinder(c).Datastore(ctx, "LocalDS_1") if err != nil { return err } task, err := ds.Destroy(ctx) if err != nil { return err } if err = task.Wait(ctx); err != nil { return err } fmt.Println("destroyed", ds.InventoryPath) return nil }, model) }
Output: destroyed /DC0/datastore/LocalDS_1
func (Common) ObjectName ¶
ObjectName fetches the mo.ManagedEntity.Name field via the property collector.
func (Common) Properties ¶
func (c Common) Properties(ctx context.Context, r types.ManagedObjectReference, ps []string, dst interface{}) error
Properties is a wrapper for property.DefaultCollector().RetrieveOne()
func (Common) Reference ¶
func (c Common) Reference() types.ManagedObjectReference
func (Common) Rename ¶
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" ) func main() { model := simulator.VPX() simulator.Run(func(ctx context.Context, c *vim25.Client) error { dc, err := find.NewFinder(c).Datacenter(ctx, "DC0") if err != nil { return err } task, err := dc.Rename(ctx, "MyDC") if err != nil { return err } if err = task.Wait(ctx); err != nil { return err } name, err := dc.ObjectName(ctx) if err != nil { return err } fmt.Println(name) return nil }, model) }
Output: MyDC
func (Common) SetCustomValue ¶
func (*Common) SetInventoryPath ¶
type ComputeResource ¶
type ComputeResource struct {
Common
}
func NewComputeResource ¶
func NewComputeResource(c *vim25.Client, ref types.ManagedObjectReference) *ComputeResource
func (ComputeResource) Datastores ¶
func (c ComputeResource) Datastores(ctx context.Context) ([]*Datastore, error)
func (ComputeResource) Hosts ¶
func (c ComputeResource) Hosts(ctx context.Context) ([]*HostSystem, error)
func (ComputeResource) Reconfigure ¶
func (c ComputeResource) Reconfigure(ctx context.Context, spec types.BaseComputeResourceConfigSpec, modify bool) (*Task, error)
func (ComputeResource) ResourcePool ¶
func (c ComputeResource) ResourcePool(ctx context.Context) (*ResourcePool, error)
type CustomFieldDefList ¶
type CustomFieldDefList []types.CustomFieldDef
func (CustomFieldDefList) ByKey ¶
func (l CustomFieldDefList) ByKey(key int32) *types.CustomFieldDef
type CustomFieldsManager ¶
type CustomFieldsManager struct {
Common
}
func GetCustomFieldsManager ¶
func GetCustomFieldsManager(c *vim25.Client) (*CustomFieldsManager, error)
GetCustomFieldsManager wraps NewCustomFieldsManager, returning ErrNotSupported when the client is not connected to a vCenter instance.
func NewCustomFieldsManager ¶
func NewCustomFieldsManager(c *vim25.Client) *CustomFieldsManager
func (CustomFieldsManager) Add ¶
func (m CustomFieldsManager) Add(ctx context.Context, name string, moType string, fieldDefPolicy *types.PrivilegePolicyDef, fieldPolicy *types.PrivilegePolicyDef) (*types.CustomFieldDef, error)
func (CustomFieldsManager) Field ¶
func (m CustomFieldsManager) Field(ctx context.Context) (CustomFieldDefList, error)
func (CustomFieldsManager) Remove ¶
func (m CustomFieldsManager) Remove(ctx context.Context, key int32) error
func (CustomFieldsManager) Set ¶
func (m CustomFieldsManager) Set(ctx context.Context, entity types.ManagedObjectReference, key int32, value string) error
Example ¶
package main import ( "context" "fmt" "log" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/property" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/view" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/types" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { m, err := object.GetCustomFieldsManager(c) if err != nil { return err } any := []string{"ManagedEntity"} field, err := m.Add(ctx, "backup", any[0], nil, nil) // adds the custom field "backup" to all types if err != nil { return err } v, err := view.NewManager(c).CreateContainerView(ctx, c.ServiceContent.RootFolder, any, true) if err != nil { log.Fatal(err) } all, err := v.Find(ctx, any, nil) // gives us the count of all objects in the inventory if err != nil { return err } refs, err := v.Find(ctx, []string{"VirtualMachine", "Datastore"}, nil) if err != nil { return err } for _, ref := range refs { err = m.Set(ctx, ref, field.Key, "true") // sets the custom value "backup=true" on specific types if err != nil { return err } } // filter used to find objects with "backup=true" filter := property.Filter{"customValue": &types.CustomFieldStringValue{ CustomFieldValue: types.CustomFieldValue{Key: field.Key}, Value: "true", }} var objs []mo.ManagedEntity err = v.RetrieveWithFilter(ctx, any, []string{"name", "customValue"}, &objs, filter) if err != nil { return err } fmt.Printf("backup %d of %d objects", len(objs), len(all)) return v.Destroy(ctx) }) }
Output: backup 5 of 22 objects
type CustomizationSpecManager ¶
type CustomizationSpecManager struct {
Common
}
func NewCustomizationSpecManager ¶
func NewCustomizationSpecManager(c *vim25.Client) *CustomizationSpecManager
func (CustomizationSpecManager) CreateCustomizationSpec ¶
func (cs CustomizationSpecManager) CreateCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error
func (CustomizationSpecManager) CustomizationSpecItemToXml ¶
func (cs CustomizationSpecManager) CustomizationSpecItemToXml(ctx context.Context, item types.CustomizationSpecItem) (string, error)
func (CustomizationSpecManager) DeleteCustomizationSpec ¶
func (cs CustomizationSpecManager) DeleteCustomizationSpec(ctx context.Context, name string) error
func (CustomizationSpecManager) DoesCustomizationSpecExist ¶
func (CustomizationSpecManager) DuplicateCustomizationSpec ¶
func (CustomizationSpecManager) GetCustomizationSpec ¶
func (cs CustomizationSpecManager) GetCustomizationSpec(ctx context.Context, name string) (*types.CustomizationSpecItem, error)
func (CustomizationSpecManager) Info ¶
func (cs CustomizationSpecManager) Info(ctx context.Context) ([]types.CustomizationSpecInfo, error)
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { m := object.NewCustomizationSpecManager(c) info, err := m.Info(ctx) if err != nil { return err } for i := range info { item, err := m.GetCustomizationSpec(ctx, info[i].Name) if err != nil { return err } fmt.Printf("%s=%T\n", item.Info.Name, item.Spec.Identity) } return nil }) }
Output: vcsim-linux=*types.CustomizationLinuxPrep vcsim-linux-static=*types.CustomizationLinuxPrep vcsim-windows-static=*types.CustomizationSysprep vcsim-windows-domain=*types.CustomizationSysprep
func (CustomizationSpecManager) OverwriteCustomizationSpec ¶
func (cs CustomizationSpecManager) OverwriteCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error
func (CustomizationSpecManager) RenameCustomizationSpec ¶
func (CustomizationSpecManager) XmlToCustomizationSpecItem ¶
func (cs CustomizationSpecManager) XmlToCustomizationSpecItem(ctx context.Context, xml string) (*types.CustomizationSpecItem, error)
type Datacenter ¶
type Datacenter struct {
Common
}
func NewDatacenter ¶
func NewDatacenter(c *vim25.Client, ref types.ManagedObjectReference) *Datacenter
func (*Datacenter) Folders ¶
func (d *Datacenter) Folders(ctx context.Context) (*DatacenterFolders, error)
func (Datacenter) PowerOnVM ¶
func (d Datacenter) PowerOnVM(ctx context.Context, vm []types.ManagedObjectReference, option ...types.BaseOptionValue) (*Task, error)
PowerOnVM powers on multiple virtual machines with a single vCenter call. If called against ESX, serially powers on the list of VMs and the returned *Task will always be nil.
type DatacenterFolders ¶
type Datastore ¶
func NewDatastore ¶
func NewDatastore(c *vim25.Client, ref types.ManagedObjectReference) *Datastore
func (Datastore) AttachedClusterHosts ¶
func (d Datastore) AttachedClusterHosts(ctx context.Context, cluster *ComputeResource) ([]*HostSystem, error)
AttachedClusterHosts returns hosts that have this Datastore attached, accessible and writable and are members of the given cluster.
func (Datastore) AttachedHosts ¶
func (d Datastore) AttachedHosts(ctx context.Context) ([]*HostSystem, error)
AttachedHosts returns hosts that have this Datastore attached, accessible and writable.
func (Datastore) Browser ¶
func (d Datastore) Browser(ctx context.Context) (*HostDatastoreBrowser, error)
func (Datastore) Download ¶
func (d Datastore) Download(ctx context.Context, path string, param *soap.Download) (io.ReadCloser, int64, error)
Download via soap.Download with an http service ticket
func (Datastore) DownloadFile ¶
func (d Datastore) DownloadFile(ctx context.Context, path string, file string, param *soap.Download) error
DownloadFile via soap.Download with an http service ticket
func (Datastore) HostContext ¶
HostContext returns a Context where the given host will be used for datastore HTTP access via the ServiceTicket method.
func (Datastore) NewFileManager ¶
func (d Datastore) NewFileManager(dc *Datacenter, force bool) *DatastoreFileManager
NewFileManager creates a new instance of DatastoreFileManager
func (Datastore) NewURL ¶
NewURL constructs a url.URL with the given file path for datastore access over HTTP.
func (Datastore) ServiceTicket ¶
func (d Datastore) ServiceTicket(ctx context.Context, path string, method string) (*url.URL, *http.Cookie, error)
ServiceTicket obtains a ticket via AcquireGenericServiceTicket and returns it an http.Cookie with the url.URL that can be used along with the ticket cookie to access the given path. An host is chosen at random unless the the given Context was created with a specific host via the HostContext method.
type DatastoreFile ¶
type DatastoreFile struct {
// contains filtered or unexported fields
}
DatastoreFile implements io.Reader, io.Seeker and io.Closer interfaces for datastore file access.
func (*DatastoreFile) Follow ¶
func (f *DatastoreFile) Follow(interval time.Duration) io.ReadCloser
Follow returns an io.ReadCloser to stream the file contents as data is appended.
func (*DatastoreFile) Read ¶
func (f *DatastoreFile) Read(b []byte) (int, error)
Read reads up to len(b) bytes from the DatastoreFile.
func (*DatastoreFile) Seek ¶
func (f *DatastoreFile) Seek(offset int64, whence int) (int64, error)
Seek sets the offset for the next Read on the DatastoreFile.
func (*DatastoreFile) Stat ¶
func (f *DatastoreFile) Stat() (os.FileInfo, error)
Stat returns the os.FileInfo interface describing file.
func (*DatastoreFile) Tail ¶
func (f *DatastoreFile) Tail(n int) error
Tail seeks to the position of the last N lines of the file.
type DatastoreFileManager ¶
type DatastoreFileManager struct { Datacenter *Datacenter Datastore *Datastore FileManager *FileManager VirtualDiskManager *VirtualDiskManager Force bool DatacenterTarget *Datacenter }
DatastoreFileManager combines FileManager and VirtualDiskManager to manage files on a Datastore
func (*DatastoreFileManager) Copy ¶
Copy dispatches to the appropriate FileManager or VirtualDiskManager Copy method based on file name extension
func (*DatastoreFileManager) Delete ¶
func (m *DatastoreFileManager) Delete(ctx context.Context, name string) error
Delete dispatches to the appropriate Delete method based on file name extension
func (*DatastoreFileManager) DeleteFile ¶
func (m *DatastoreFileManager) DeleteFile(ctx context.Context, name string) error
DeleteFile calls FileManager.DeleteDatastoreFile
func (*DatastoreFileManager) DeleteVirtualDisk ¶
func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Context, name string) error
DeleteVirtualDisk calls VirtualDiskManager.DeleteVirtualDisk Regardless of the Datastore type, DeleteVirtualDisk will fail if 'ddb.deletable=false', so if Force=true this method attempts to set 'ddb.deletable=true' before starting the delete task.
func (*DatastoreFileManager) Move ¶
Move dispatches to the appropriate FileManager or VirtualDiskManager Move method based on file name extension
func (*DatastoreFileManager) Path ¶
func (m *DatastoreFileManager) Path(name string) *DatastorePath
Path converts path name to a DatastorePath
func (*DatastoreFileManager) WithProgress ¶
type DatastoreNamespaceManager ¶
type DatastoreNamespaceManager struct {
Common
}
func NewDatastoreNamespaceManager ¶
func NewDatastoreNamespaceManager(c *vim25.Client) *DatastoreNamespaceManager
func (DatastoreNamespaceManager) CreateDirectory ¶
func (nm DatastoreNamespaceManager) CreateDirectory(ctx context.Context, ds *Datastore, displayName string, policy string) (string, error)
CreateDirectory creates a top-level directory on the given vsan datastore, using the given user display name hint and opaque storage policy.
func (DatastoreNamespaceManager) DeleteDirectory ¶
func (nm DatastoreNamespaceManager) DeleteDirectory(ctx context.Context, dc *Datacenter, datastorePath string) error
DeleteDirectory deletes the given top-level directory from a vsan datastore.
type DatastoreNoSuchDirectoryError ¶
type DatastoreNoSuchDirectoryError struct {
// contains filtered or unexported fields
}
DatastoreNoSuchDirectoryError is returned when a directory could not be found.
func (DatastoreNoSuchDirectoryError) Error ¶
func (e DatastoreNoSuchDirectoryError) Error() string
type DatastoreNoSuchFileError ¶
type DatastoreNoSuchFileError struct {
// contains filtered or unexported fields
}
DatastoreNoSuchFileError is returned when a file could not be found.
func (DatastoreNoSuchFileError) Error ¶
func (e DatastoreNoSuchFileError) Error() string
type DatastorePath ¶
DatastorePath contains the components of a datastore path.
func (*DatastorePath) FromString ¶
func (p *DatastorePath) FromString(s string) bool
FromString parses a datastore path. Returns true if the path could be parsed, false otherwise.
func (*DatastorePath) IsVMDK ¶
func (p *DatastorePath) IsVMDK() bool
IsVMDK returns true if Path has a ".vmdk" extension
func (*DatastorePath) String ¶
func (p *DatastorePath) String() string
String formats a datastore path.
type DiagnosticLog ¶
type DiagnosticLog struct { Key string Host *HostSystem Start int32 // contains filtered or unexported fields }
DiagnosticLog wraps DiagnosticManager.BrowseLog
type DiagnosticManager ¶
type DiagnosticManager struct {
Common
}
func NewDiagnosticManager ¶
func NewDiagnosticManager(c *vim25.Client) *DiagnosticManager
func (DiagnosticManager) BrowseLog ¶
func (m DiagnosticManager) BrowseLog(ctx context.Context, host *HostSystem, key string, start, lines int32) (*types.DiagnosticManagerLogHeader, error)
func (DiagnosticManager) GenerateLogBundles ¶
func (m DiagnosticManager) GenerateLogBundles(ctx context.Context, includeDefault bool, host []*HostSystem) (*Task, error)
func (DiagnosticManager) Log ¶
func (m DiagnosticManager) Log(ctx context.Context, host *HostSystem, key string) *DiagnosticLog
func (DiagnosticManager) QueryDescriptions ¶
func (m DiagnosticManager) QueryDescriptions(ctx context.Context, host *HostSystem) ([]types.DiagnosticManagerLogDescriptor, error)
type DisabledMethodRequest ¶
type DistributedVirtualPortgroup ¶
type DistributedVirtualPortgroup struct {
Common
}
func NewDistributedVirtualPortgroup ¶
func NewDistributedVirtualPortgroup(c *vim25.Client, ref types.ManagedObjectReference) *DistributedVirtualPortgroup
func (DistributedVirtualPortgroup) EthernetCardBackingInfo ¶
func (p DistributedVirtualPortgroup) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error)
EthernetCardBackingInfo returns the VirtualDeviceBackingInfo for this DistributedVirtualPortgroup
func (DistributedVirtualPortgroup) GetInventoryPath ¶
func (p DistributedVirtualPortgroup) GetInventoryPath() string
func (DistributedVirtualPortgroup) Reconfigure ¶
func (p DistributedVirtualPortgroup) Reconfigure(ctx context.Context, spec types.DVPortgroupConfigSpec) (*Task, error)
type DistributedVirtualSwitch ¶
type DistributedVirtualSwitch struct {
Common
}
func NewDistributedVirtualSwitch ¶
func NewDistributedVirtualSwitch(c *vim25.Client, ref types.ManagedObjectReference) *DistributedVirtualSwitch
func (DistributedVirtualSwitch) AddPortgroup ¶
func (s DistributedVirtualSwitch) AddPortgroup(ctx context.Context, spec []types.DVPortgroupConfigSpec) (*Task, error)
func (DistributedVirtualSwitch) EthernetCardBackingInfo ¶
func (s DistributedVirtualSwitch) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error)
func (DistributedVirtualSwitch) FetchDVPorts ¶
func (s DistributedVirtualSwitch) FetchDVPorts(ctx context.Context, criteria *types.DistributedVirtualSwitchPortCriteria) ([]types.DistributedVirtualPort, error)
func (DistributedVirtualSwitch) GetInventoryPath ¶
func (s DistributedVirtualSwitch) GetInventoryPath() string
func (DistributedVirtualSwitch) Reconfigure ¶
func (s DistributedVirtualSwitch) Reconfigure(ctx context.Context, spec types.BaseDVSConfigSpec) (*Task, error)
func (DistributedVirtualSwitch) ReconfigureDVPort ¶
func (s DistributedVirtualSwitch) ReconfigureDVPort(ctx context.Context, spec []types.DVPortConfigSpec) (*Task, error)
func (DistributedVirtualSwitch) ReconfigureLACP ¶
func (s DistributedVirtualSwitch) ReconfigureLACP(ctx context.Context, spec []types.VMwareDvsLacpGroupSpec) (*Task, error)
type ExtensionManager ¶
type ExtensionManager struct {
Common
}
func GetExtensionManager ¶
func GetExtensionManager(c *vim25.Client) (*ExtensionManager, error)
GetExtensionManager wraps NewExtensionManager, returning ErrNotSupported when the client is not connected to a vCenter instance.
func NewExtensionManager ¶
func NewExtensionManager(c *vim25.Client) *ExtensionManager
func (ExtensionManager) SetCertificate ¶
func (ExtensionManager) Unregister ¶
func (m ExtensionManager) Unregister(ctx context.Context, key string) error
type FileManager ¶
type FileManager struct {
Common
}
func NewFileManager ¶
func NewFileManager(c *vim25.Client) *FileManager
func (FileManager) CopyDatastoreFile ¶
func (f FileManager) CopyDatastoreFile(ctx context.Context, sourceName string, sourceDatacenter *Datacenter, destinationName string, destinationDatacenter *Datacenter, force bool) (*Task, error)
func (FileManager) DeleteDatastoreFile ¶
func (f FileManager) DeleteDatastoreFile(ctx context.Context, name string, dc *Datacenter) (*Task, error)
DeleteDatastoreFile deletes the specified file or folder from the datastore.
func (FileManager) MakeDirectory ¶
func (f FileManager) MakeDirectory(ctx context.Context, name string, dc *Datacenter, createParentDirectories bool) error
MakeDirectory creates a folder using the specified name.
func (FileManager) MoveDatastoreFile ¶
func (f FileManager) MoveDatastoreFile(ctx context.Context, sourceName string, sourceDatacenter *Datacenter, destinationName string, destinationDatacenter *Datacenter, force bool) (*Task, error)
type Folder ¶
type Folder struct {
Common
}
func NewRootFolder ¶
func (Folder) AddStandaloneHost ¶
func (Folder) CreateCluster ¶
func (f Folder) CreateCluster(ctx context.Context, cluster string, spec types.ClusterConfigSpecEx) (*ClusterComputeResource, error)
func (Folder) CreateDatacenter ¶
func (Folder) CreateFolder ¶
func (Folder) CreateStoragePod ¶
func (Folder) CreateVM ¶
func (f Folder) CreateVM(ctx context.Context, config types.VirtualMachineConfigSpec, pool *ResourcePool, host *HostSystem) (*Task, error)
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/types" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { finder := find.NewFinder(c) dc, err := finder.Datacenter(ctx, "DC0") if err != nil { return err } finder.SetDatacenter(dc) folders, err := dc.Folders(ctx) if err != nil { return err } pool, err := finder.ResourcePool(ctx, "DC0_C0/Resources") if err != nil { return err } spec := types.VirtualMachineConfigSpec{ Name: "example-vm", GuestId: string(types.VirtualMachineGuestOsIdentifierOtherGuest), Files: &types.VirtualMachineFileInfo{ VmPathName: "[LocalDS_0]", }, } task, err := folders.VmFolder.CreateVM(ctx, spec, pool, nil) if err != nil { return err } info, err := task.WaitForResult(ctx) if err != nil { return err } vm := object.NewVirtualMachine(c, info.Result.(types.ManagedObjectReference)) name, err := vm.ObjectName(ctx) if err != nil { return err } fmt.Println(name) return nil }) }
Output: example-vm
func (Folder) PlaceVmsXCluster ¶
func (f Folder) PlaceVmsXCluster(ctx context.Context, spec types.PlaceVmsXClusterSpec) (*types.PlaceVmsXClusterResult, error)
func (Folder) RegisterVM ¶
func (f Folder) RegisterVM(ctx context.Context, path string, name string, asTemplate bool, pool *ResourcePool, host *HostSystem) (*Task, error)
type HostAccountManager ¶
type HostAccountManager struct {
Common
}
func NewHostAccountManager ¶
func NewHostAccountManager(c *vim25.Client, ref types.ManagedObjectReference) *HostAccountManager
func (HostAccountManager) Create ¶
func (m HostAccountManager) Create(ctx context.Context, user *types.HostAccountSpec) error
func (HostAccountManager) Remove ¶
func (m HostAccountManager) Remove(ctx context.Context, userName string) error
func (HostAccountManager) Update ¶
func (m HostAccountManager) Update(ctx context.Context, user *types.HostAccountSpec) error
type HostCertificateInfo ¶
type HostCertificateInfo struct { types.HostCertificateManagerCertificateInfo ThumbprintSHA1 string ThumbprintSHA256 string Err error Certificate *x509.Certificate `json:"-"` // contains filtered or unexported fields }
HostCertificateInfo provides helpers for types.HostCertificateManagerCertificateInfo
func (*HostCertificateInfo) FromCertificate ¶
func (info *HostCertificateInfo) FromCertificate(cert *x509.Certificate) *HostCertificateInfo
FromCertificate converts x509.Certificate to HostCertificateInfo
func (*HostCertificateInfo) FromURL ¶
FromURL connects to the given URL.Host via tls.Dial with the given tls.Config and populates the HostCertificateInfo via tls.ConnectionState. If the certificate was verified with the given tls.Config, the Err field will be nil. Otherwise, Err will be set to the x509.UnknownAuthorityError or x509.HostnameError. If tls.Dial returns an error of any other type, that error is returned.
func (*HostCertificateInfo) IssuerName ¶
func (info *HostCertificateInfo) IssuerName() *pkix.Name
IssuerName parses Issuer into a pkix.Name
func (*HostCertificateInfo) SubjectName ¶
func (info *HostCertificateInfo) SubjectName() *pkix.Name
SubjectName parses Subject into a pkix.Name
type HostCertificateManager ¶
type HostCertificateManager struct { Common Host *HostSystem }
HostCertificateManager provides helper methods around the HostSystem.ConfigManager.CertificateManager
func NewHostCertificateManager ¶
func NewHostCertificateManager(c *vim25.Client, ref types.ManagedObjectReference, host types.ManagedObjectReference) *HostCertificateManager
NewHostCertificateManager creates a new HostCertificateManager helper
func (HostCertificateManager) CertificateInfo ¶
func (m HostCertificateManager) CertificateInfo(ctx context.Context) (*HostCertificateInfo, error)
CertificateInfo wraps the host CertificateManager certificateInfo property with the HostCertificateInfo helper. The ThumbprintSHA1 field is set to HostSystem.Summary.Config.SslThumbprint if the host system is managed by a vCenter.
func (HostCertificateManager) GenerateCertificateSigningRequest ¶
func (m HostCertificateManager) GenerateCertificateSigningRequest(ctx context.Context, useIPAddressAsCommonName bool) (string, error)
GenerateCertificateSigningRequest requests the host system to generate a certificate-signing request (CSR) for itself. The CSR is then typically provided to a Certificate Authority to sign and issue the SSL certificate for the host system. Use InstallServerCertificate to import this certificate.
func (HostCertificateManager) GenerateCertificateSigningRequestByDn ¶
func (m HostCertificateManager) GenerateCertificateSigningRequestByDn(ctx context.Context, distinguishedName string) (string, error)
GenerateCertificateSigningRequestByDn requests the host system to generate a certificate-signing request (CSR) for itself. Alternative version similar to GenerateCertificateSigningRequest but takes a Distinguished Name (DN) as a parameter.
func (HostCertificateManager) InstallServerCertificate ¶
func (m HostCertificateManager) InstallServerCertificate(ctx context.Context, cert string) error
InstallServerCertificate imports the given SSL certificate to the host system.
func (HostCertificateManager) ListCACertificateRevocationLists ¶
func (m HostCertificateManager) ListCACertificateRevocationLists(ctx context.Context) ([]string, error)
ListCACertificateRevocationLists returns the SSL CRLs of Certificate Authorities that are trusted by the host system.
func (HostCertificateManager) ListCACertificates ¶
func (m HostCertificateManager) ListCACertificates(ctx context.Context) ([]string, error)
ListCACertificates returns the SSL certificates of Certificate Authorities that are trusted by the host system.
func (HostCertificateManager) ReplaceCACertificatesAndCRLs ¶
func (m HostCertificateManager) ReplaceCACertificatesAndCRLs(ctx context.Context, caCert []string, caCrl []string) error
ReplaceCACertificatesAndCRLs replaces the trusted CA certificates and CRL used by the host system. These determine whether the server can verify the identity of an external entity.
type HostConfigManager ¶
type HostConfigManager struct {
Common
}
func NewHostConfigManager ¶
func NewHostConfigManager(c *vim25.Client, ref types.ManagedObjectReference) *HostConfigManager
func (HostConfigManager) AccountManager ¶
func (m HostConfigManager) AccountManager(ctx context.Context) (*HostAccountManager, error)
func (HostConfigManager) CertificateManager ¶
func (m HostConfigManager) CertificateManager(ctx context.Context) (*HostCertificateManager, error)
func (HostConfigManager) DatastoreSystem ¶
func (m HostConfigManager) DatastoreSystem(ctx context.Context) (*HostDatastoreSystem, error)
func (HostConfigManager) DateTimeSystem ¶
func (m HostConfigManager) DateTimeSystem(ctx context.Context) (*HostDateTimeSystem, error)
func (HostConfigManager) FirewallSystem ¶
func (m HostConfigManager) FirewallSystem(ctx context.Context) (*HostFirewallSystem, error)
func (HostConfigManager) NetworkSystem ¶
func (m HostConfigManager) NetworkSystem(ctx context.Context) (*HostNetworkSystem, error)
func (HostConfigManager) OptionManager ¶
func (m HostConfigManager) OptionManager(ctx context.Context) (*OptionManager, error)
Example ¶
package main import ( "context" "fmt" "log" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/view" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/types" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { m := view.NewManager(c) kind := []string{"HostSystem"} v, err := m.CreateContainerView(ctx, c.ServiceContent.RootFolder, kind, true) if err != nil { log.Fatal(err) } refs, err := v.Find(ctx, kind, nil) if err != nil { return err } setting := "" for _, ref := range refs { host := object.NewHostSystem(c, ref) m, err := host.ConfigManager().OptionManager(ctx) if err != nil { return err } opt := []types.BaseOptionValue{&types.OptionValue{ Key: "vcrun", Value: "Config.HostAgent.plugins.hostsvc.esxAdminsGroup", }} err = m.Update(ctx, opt) if err != nil { return err } opt, err = m.Query(ctx, "vcrun") if err != nil { return err } setting = opt[0].GetOptionValue().Value.(string) } fmt.Println(setting) return v.Destroy(ctx) }) }
Output: Config.HostAgent.plugins.hostsvc.esxAdminsGroup
func (HostConfigManager) ServiceSystem ¶
func (m HostConfigManager) ServiceSystem(ctx context.Context) (*HostServiceSystem, error)
func (HostConfigManager) StorageSystem ¶
func (m HostConfigManager) StorageSystem(ctx context.Context) (*HostStorageSystem, error)
func (HostConfigManager) VirtualNicManager ¶
func (m HostConfigManager) VirtualNicManager(ctx context.Context) (*HostVirtualNicManager, error)
func (HostConfigManager) VsanInternalSystem ¶
func (m HostConfigManager) VsanInternalSystem(ctx context.Context) (*HostVsanInternalSystem, error)
func (HostConfigManager) VsanSystem ¶
func (m HostConfigManager) VsanSystem(ctx context.Context) (*HostVsanSystem, error)
type HostDatastoreBrowser ¶
type HostDatastoreBrowser struct {
Common
}
func NewHostDatastoreBrowser ¶
func NewHostDatastoreBrowser(c *vim25.Client, ref types.ManagedObjectReference) *HostDatastoreBrowser
func (HostDatastoreBrowser) SearchDatastore ¶
func (b HostDatastoreBrowser) SearchDatastore(ctx context.Context, datastorePath string, searchSpec *types.HostDatastoreBrowserSearchSpec) (*Task, error)
func (HostDatastoreBrowser) SearchDatastoreSubFolders ¶
func (b HostDatastoreBrowser) SearchDatastoreSubFolders(ctx context.Context, datastorePath string, searchSpec *types.HostDatastoreBrowserSearchSpec) (*Task, error)
type HostDatastoreSystem ¶
type HostDatastoreSystem struct {
Common
}
func NewHostDatastoreSystem ¶
func NewHostDatastoreSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostDatastoreSystem
func (HostDatastoreSystem) CreateLocalDatastore ¶
func (HostDatastoreSystem) CreateNasDatastore ¶
func (s HostDatastoreSystem) CreateNasDatastore(ctx context.Context, spec types.HostNasVolumeSpec) (*Datastore, error)
func (HostDatastoreSystem) CreateVmfsDatastore ¶
func (s HostDatastoreSystem) CreateVmfsDatastore(ctx context.Context, spec types.VmfsDatastoreCreateSpec) (*Datastore, error)
func (HostDatastoreSystem) QueryAvailableDisksForVmfs ¶
func (s HostDatastoreSystem) QueryAvailableDisksForVmfs(ctx context.Context) ([]types.HostScsiDisk, error)
func (HostDatastoreSystem) QueryVmfsDatastoreCreateOptions ¶
func (s HostDatastoreSystem) QueryVmfsDatastoreCreateOptions(ctx context.Context, devicePath string) ([]types.VmfsDatastoreOption, error)
func (HostDatastoreSystem) Remove ¶
func (s HostDatastoreSystem) Remove(ctx context.Context, ds *Datastore) error
func (HostDatastoreSystem) ResignatureUnresolvedVmfsVolumes ¶
type HostDateTimeSystem ¶
type HostDateTimeSystem struct {
Common
}
func NewHostDateTimeSystem ¶
func NewHostDateTimeSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostDateTimeSystem
func (HostDateTimeSystem) UpdateConfig ¶
func (s HostDateTimeSystem) UpdateConfig(ctx context.Context, config types.HostDateTimeConfig) error
type HostFirewallRulesetList ¶
type HostFirewallRulesetList []types.HostFirewallRuleset
HostFirewallRulesetList provides helpers for a slice of types.HostFirewallRuleset
func (HostFirewallRulesetList) ByRule ¶
func (l HostFirewallRulesetList) ByRule(rule types.HostFirewallRule) HostFirewallRulesetList
ByRule returns a HostFirewallRulesetList where Direction, PortType and Protocol are equal and Port is within range
func (HostFirewallRulesetList) Disabled ¶
func (l HostFirewallRulesetList) Disabled() HostFirewallRulesetList
Disabled returns a HostFirewallRulesetList with disabled rules
func (HostFirewallRulesetList) Enabled ¶
func (l HostFirewallRulesetList) Enabled() HostFirewallRulesetList
Enabled returns a HostFirewallRulesetList with enabled rules
func (HostFirewallRulesetList) EnabledByRule ¶
func (l HostFirewallRulesetList) EnabledByRule(rule types.HostFirewallRule, enabled bool) (HostFirewallRulesetList, error)
EnabledByRule returns a HostFirewallRulesetList with Match(rule) applied and filtered via Enabled() if enabled param is true, otherwise filtered via Disabled(). An error is returned if the resulting list is empty.
func (HostFirewallRulesetList) Keys ¶
func (l HostFirewallRulesetList) Keys() []string
Keys returns the HostFirewallRuleset.Key for each ruleset in the list
type HostFirewallSystem ¶
type HostFirewallSystem struct {
Common
}
func NewHostFirewallSystem ¶
func NewHostFirewallSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostFirewallSystem
func (HostFirewallSystem) DisableRuleset ¶
func (s HostFirewallSystem) DisableRuleset(ctx context.Context, id string) error
func (HostFirewallSystem) EnableRuleset ¶
func (s HostFirewallSystem) EnableRuleset(ctx context.Context, id string) error
func (HostFirewallSystem) Info ¶
func (s HostFirewallSystem) Info(ctx context.Context) (*types.HostFirewallInfo, error)
type HostNetworkSystem ¶
type HostNetworkSystem struct {
Common
}
func NewHostNetworkSystem ¶
func NewHostNetworkSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostNetworkSystem
func (HostNetworkSystem) AddPortGroup ¶
func (o HostNetworkSystem) AddPortGroup(ctx context.Context, portgrp types.HostPortGroupSpec) error
AddPortGroup wraps methods.AddPortGroup
func (HostNetworkSystem) AddServiceConsoleVirtualNic ¶
func (o HostNetworkSystem) AddServiceConsoleVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error)
AddServiceConsoleVirtualNic wraps methods.AddServiceConsoleVirtualNic
func (HostNetworkSystem) AddVirtualNic ¶
func (o HostNetworkSystem) AddVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error)
AddVirtualNic wraps methods.AddVirtualNic
func (HostNetworkSystem) AddVirtualSwitch ¶
func (o HostNetworkSystem) AddVirtualSwitch(ctx context.Context, vswitchName string, spec *types.HostVirtualSwitchSpec) error
AddVirtualSwitch wraps methods.AddVirtualSwitch
func (HostNetworkSystem) QueryNetworkHint ¶
func (o HostNetworkSystem) QueryNetworkHint(ctx context.Context, device []string) ([]types.PhysicalNicHintInfo, error)
QueryNetworkHint wraps methods.QueryNetworkHint
func (HostNetworkSystem) RefreshNetworkSystem ¶
func (o HostNetworkSystem) RefreshNetworkSystem(ctx context.Context) error
RefreshNetworkSystem wraps methods.RefreshNetworkSystem
func (HostNetworkSystem) RemovePortGroup ¶
func (o HostNetworkSystem) RemovePortGroup(ctx context.Context, pgName string) error
RemovePortGroup wraps methods.RemovePortGroup
func (HostNetworkSystem) RemoveServiceConsoleVirtualNic ¶
func (o HostNetworkSystem) RemoveServiceConsoleVirtualNic(ctx context.Context, device string) error
RemoveServiceConsoleVirtualNic wraps methods.RemoveServiceConsoleVirtualNic
func (HostNetworkSystem) RemoveVirtualNic ¶
func (o HostNetworkSystem) RemoveVirtualNic(ctx context.Context, device string) error
RemoveVirtualNic wraps methods.RemoveVirtualNic
func (HostNetworkSystem) RemoveVirtualSwitch ¶
func (o HostNetworkSystem) RemoveVirtualSwitch(ctx context.Context, vswitchName string) error
RemoveVirtualSwitch wraps methods.RemoveVirtualSwitch
func (HostNetworkSystem) RestartServiceConsoleVirtualNic ¶
func (o HostNetworkSystem) RestartServiceConsoleVirtualNic(ctx context.Context, device string) error
RestartServiceConsoleVirtualNic wraps methods.RestartServiceConsoleVirtualNic
func (HostNetworkSystem) UpdateConsoleIpRouteConfig ¶
func (o HostNetworkSystem) UpdateConsoleIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error
UpdateConsoleIpRouteConfig wraps methods.UpdateConsoleIpRouteConfig
func (HostNetworkSystem) UpdateDnsConfig ¶
func (o HostNetworkSystem) UpdateDnsConfig(ctx context.Context, config types.BaseHostDnsConfig) error
UpdateDnsConfig wraps methods.UpdateDnsConfig
func (HostNetworkSystem) UpdateIpRouteConfig ¶
func (o HostNetworkSystem) UpdateIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error
UpdateIpRouteConfig wraps methods.UpdateIpRouteConfig
func (HostNetworkSystem) UpdateIpRouteTableConfig ¶
func (o HostNetworkSystem) UpdateIpRouteTableConfig(ctx context.Context, config types.HostIpRouteTableConfig) error
UpdateIpRouteTableConfig wraps methods.UpdateIpRouteTableConfig
func (HostNetworkSystem) UpdateNetworkConfig ¶
func (o HostNetworkSystem) UpdateNetworkConfig(ctx context.Context, config types.HostNetworkConfig, changeMode string) (*types.HostNetworkConfigResult, error)
UpdateNetworkConfig wraps methods.UpdateNetworkConfig
func (HostNetworkSystem) UpdatePhysicalNicLinkSpeed ¶
func (o HostNetworkSystem) UpdatePhysicalNicLinkSpeed(ctx context.Context, device string, linkSpeed *types.PhysicalNicLinkInfo) error
UpdatePhysicalNicLinkSpeed wraps methods.UpdatePhysicalNicLinkSpeed
func (HostNetworkSystem) UpdatePortGroup ¶
func (o HostNetworkSystem) UpdatePortGroup(ctx context.Context, pgName string, portgrp types.HostPortGroupSpec) error
UpdatePortGroup wraps methods.UpdatePortGroup
func (HostNetworkSystem) UpdateServiceConsoleVirtualNic ¶
func (o HostNetworkSystem) UpdateServiceConsoleVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error
UpdateServiceConsoleVirtualNic wraps methods.UpdateServiceConsoleVirtualNic
func (HostNetworkSystem) UpdateVirtualNic ¶
func (o HostNetworkSystem) UpdateVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error
UpdateVirtualNic wraps methods.UpdateVirtualNic
func (HostNetworkSystem) UpdateVirtualSwitch ¶
func (o HostNetworkSystem) UpdateVirtualSwitch(ctx context.Context, vswitchName string, spec types.HostVirtualSwitchSpec) error
UpdateVirtualSwitch wraps methods.UpdateVirtualSwitch
type HostServiceSystem ¶
type HostServiceSystem struct {
Common
}
func NewHostServiceSystem ¶
func NewHostServiceSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostServiceSystem
func (HostServiceSystem) Restart ¶
func (s HostServiceSystem) Restart(ctx context.Context, id string) error
func (HostServiceSystem) Service ¶
func (s HostServiceSystem) Service(ctx context.Context) ([]types.HostService, error)
func (HostServiceSystem) Start ¶
func (s HostServiceSystem) Start(ctx context.Context, id string) error
func (HostServiceSystem) Stop ¶
func (s HostServiceSystem) Stop(ctx context.Context, id string) error
func (HostServiceSystem) UpdatePolicy ¶
type HostStorageSystem ¶
type HostStorageSystem struct {
Common
}
func NewHostStorageSystem ¶
func NewHostStorageSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostStorageSystem
func (HostStorageSystem) AttachScsiLun ¶
func (s HostStorageSystem) AttachScsiLun(ctx context.Context, uuid string) error
func (HostStorageSystem) ComputeDiskPartitionInfo ¶
func (s HostStorageSystem) ComputeDiskPartitionInfo(ctx context.Context, devicePath string, layout types.HostDiskPartitionLayout) (*types.HostDiskPartitionInfo, error)
func (HostStorageSystem) MarkAsLocal ¶
func (HostStorageSystem) MarkAsNonLocal ¶
func (HostStorageSystem) MarkAsNonSsd ¶
func (HostStorageSystem) QueryUnresolvedVmfsVolumes ¶
func (s HostStorageSystem) QueryUnresolvedVmfsVolumes(ctx context.Context) ([]types.HostUnresolvedVmfsVolume, error)
func (HostStorageSystem) RescanAllHba ¶
func (s HostStorageSystem) RescanAllHba(ctx context.Context) error
func (HostStorageSystem) RescanVmfs ¶
func (s HostStorageSystem) RescanVmfs(ctx context.Context) error
func (HostStorageSystem) RetrieveDiskPartitionInfo ¶
func (s HostStorageSystem) RetrieveDiskPartitionInfo(ctx context.Context, devicePath string) (*types.HostDiskPartitionInfo, error)
func (HostStorageSystem) UnmountVmfsVolume ¶
func (s HostStorageSystem) UnmountVmfsVolume(ctx context.Context, vmfsUuid string) error
func (HostStorageSystem) UpdateDiskPartitionInfo ¶
func (s HostStorageSystem) UpdateDiskPartitionInfo(ctx context.Context, devicePath string, spec types.HostDiskPartitionSpec) error
type HostSystem ¶
type HostSystem struct {
Common
}
func NewHostSystem ¶
func NewHostSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostSystem
func (HostSystem) ConfigManager ¶
func (h HostSystem) ConfigManager() *HostConfigManager
func (HostSystem) Disconnect ¶
func (h HostSystem) Disconnect(ctx context.Context) (*Task, error)
func (HostSystem) EnterMaintenanceMode ¶
func (h HostSystem) EnterMaintenanceMode(ctx context.Context, timeout int32, evacuate bool, spec *types.HostMaintenanceSpec) (*Task, error)
func (HostSystem) ExitMaintenanceMode ¶
func (HostSystem) ManagementIPs ¶
func (HostSystem) Reconnect ¶
func (h HostSystem) Reconnect(ctx context.Context, cnxSpec *types.HostConnectSpec, reconnectSpec *types.HostSystemReconnectSpec) (*Task, error)
func (HostSystem) ResourcePool ¶
func (h HostSystem) ResourcePool(ctx context.Context) (*ResourcePool, error)
type HostVirtualNicManager ¶
type HostVirtualNicManager struct { Common Host *HostSystem }
func NewHostVirtualNicManager ¶
func NewHostVirtualNicManager(c *vim25.Client, ref types.ManagedObjectReference, host types.ManagedObjectReference) *HostVirtualNicManager
func (HostVirtualNicManager) DeselectVnic ¶
func (HostVirtualNicManager) Info ¶
func (m HostVirtualNicManager) Info(ctx context.Context) (*types.HostVirtualNicManagerInfo, error)
func (HostVirtualNicManager) SelectVnic ¶
type HostVsanInternalSystem ¶
type HostVsanInternalSystem struct {
Common
}
func NewHostVsanInternalSystem ¶
func NewHostVsanInternalSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostVsanInternalSystem
func (HostVsanInternalSystem) DeleteVsanObjects ¶
func (m HostVsanInternalSystem) DeleteVsanObjects(ctx context.Context, uuids []string, force *bool) ([]types.HostVsanInternalSystemDeleteVsanObjectsResult, error)
DeleteVsanObjects is internal and intended for troubleshooting/debugging only. WARNING: This API can be slow because we do IOs to all the objects. DOM won't allow access to objects which have lost quorum. Such objects can be deleted with the optional "force" flag. These objects may however re-appear with quorum if the absent components come back (network partition gets resolved, etc.)
func (HostVsanInternalSystem) GetVsanObjExtAttrs ¶
func (m HostVsanInternalSystem) GetVsanObjExtAttrs(ctx context.Context, uuids []string) (map[string]VsanObjExtAttrs, error)
GetVsanObjExtAttrs is internal and intended for troubleshooting/debugging situations in the field. WARNING: This API can be slow because we do IOs (reads) to all the objects.
func (HostVsanInternalSystem) QueryVsanObjectUuidsByFilter ¶
func (m HostVsanInternalSystem) QueryVsanObjectUuidsByFilter(ctx context.Context, uuids []string, limit int32, version int32) ([]string, error)
QueryVsanObjectUuidsByFilter returns vSAN DOM object uuids by filter.
type HostVsanSystem ¶
type HostVsanSystem struct {
Common
}
func NewHostVsanSystem ¶
func NewHostVsanSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostVsanSystem
func (HostVsanSystem) Update ¶
func (s HostVsanSystem) Update(ctx context.Context, config types.VsanHostConfigInfo) (*Task, error)
type Network ¶
type Network struct {
Common
}
func NewNetwork ¶
func NewNetwork(c *vim25.Client, ref types.ManagedObjectReference) *Network
func (Network) EthernetCardBackingInfo ¶
func (n Network) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error)
EthernetCardBackingInfo returns the VirtualDeviceBackingInfo for this Network
func (Network) GetInventoryPath ¶
type NetworkReference ¶
type NetworkReference interface { Reference GetInventoryPath() string EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error) }
The NetworkReference interface is implemented by managed objects which can be used as the backing for a VirtualEthernetCard.
type OpaqueNetwork ¶
type OpaqueNetwork struct {
Common
}
func NewOpaqueNetwork ¶
func NewOpaqueNetwork(c *vim25.Client, ref types.ManagedObjectReference) *OpaqueNetwork
func (OpaqueNetwork) EthernetCardBackingInfo ¶
func (n OpaqueNetwork) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error)
EthernetCardBackingInfo returns the VirtualDeviceBackingInfo for this Network
func (OpaqueNetwork) GetInventoryPath ¶
func (n OpaqueNetwork) GetInventoryPath() string
func (OpaqueNetwork) Summary ¶
func (n OpaqueNetwork) Summary(ctx context.Context) (*types.OpaqueNetworkSummary, error)
Summary returns the mo.OpaqueNetwork.Summary property
type OptionManager ¶
type OptionManager struct {
Common
}
func NewOptionManager ¶
func NewOptionManager(c *vim25.Client, ref types.ManagedObjectReference) *OptionManager
func (OptionManager) Query ¶
func (m OptionManager) Query(ctx context.Context, name string) ([]types.BaseOptionValue, error)
func (OptionManager) Update ¶
func (m OptionManager) Update(ctx context.Context, value []types.BaseOptionValue) error
type Reference ¶
type Reference interface {
Reference() types.ManagedObjectReference
}
func NewReference ¶
func NewReference(c *vim25.Client, e types.ManagedObjectReference) Reference
type ResourcePool ¶
type ResourcePool struct {
Common
}
func NewResourcePool ¶
func NewResourcePool(c *vim25.Client, ref types.ManagedObjectReference) *ResourcePool
func (ResourcePool) Create ¶
func (p ResourcePool) Create(ctx context.Context, name string, spec types.ResourceConfigSpec) (*ResourcePool, error)
func (ResourcePool) CreateVApp ¶
func (p ResourcePool) CreateVApp(ctx context.Context, name string, resSpec types.ResourceConfigSpec, configSpec types.VAppConfigSpec, folder *Folder) (*VirtualApp, error)
func (ResourcePool) DestroyChildren ¶
func (p ResourcePool) DestroyChildren(ctx context.Context) error
func (ResourcePool) ImportVApp ¶
func (p ResourcePool) ImportVApp(ctx context.Context, spec types.BaseImportSpec, folder *Folder, host *HostSystem) (*nfc.Lease, error)
func (ResourcePool) Owner ¶
func (p ResourcePool) Owner(ctx context.Context) (Reference, error)
Owner returns the ResourcePool owner as a ClusterComputeResource or ComputeResource.
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { finder := find.NewFinder(c) for _, name := range []string{"DC0_H0_VM0", "DC0_C0_RP0_VM0"} { vm, err := finder.VirtualMachine(ctx, name) if err != nil { return err } pool, err := vm.ResourcePool(ctx) if err != nil { return err } owner, err := pool.Owner(ctx) if err != nil { return err } fmt.Printf("%s owner is a %T\n", name, owner) } return nil }) }
Output: DC0_H0_VM0 owner is a *object.ComputeResource DC0_C0_RP0_VM0 owner is a *object.ClusterComputeResource
func (ResourcePool) UpdateConfig ¶
func (p ResourcePool) UpdateConfig(ctx context.Context, name string, config *types.ResourceConfigSpec) error
type SearchIndex ¶
type SearchIndex struct {
Common
}
func NewSearchIndex ¶
func NewSearchIndex(c *vim25.Client) *SearchIndex
func (SearchIndex) FindAllByDnsName ¶
func (s SearchIndex) FindAllByDnsName(ctx context.Context, dc *Datacenter, dnsName string, vmSearch bool) ([]Reference, error)
FindAllByDnsName finds all virtual machines or hosts by DNS name.
func (SearchIndex) FindAllByIp ¶
func (s SearchIndex) FindAllByIp(ctx context.Context, dc *Datacenter, ip string, vmSearch bool) ([]Reference, error)
FindAllByIp finds all virtual machines or hosts by IP address.
func (SearchIndex) FindAllByUuid ¶
func (s SearchIndex) FindAllByUuid(ctx context.Context, dc *Datacenter, uuid string, vmSearch bool, instanceUuid *bool) ([]Reference, error)
FindAllByUuid finds all virtual machines or hosts by UUID.
func (SearchIndex) FindByDatastorePath ¶
func (s SearchIndex) FindByDatastorePath(ctx context.Context, dc *Datacenter, path string) (Reference, error)
FindByDatastorePath finds a virtual machine by its location on a datastore.
func (SearchIndex) FindByDnsName ¶
func (s SearchIndex) FindByDnsName(ctx context.Context, dc *Datacenter, dnsName string, vmSearch bool) (Reference, error)
FindByDnsName finds a virtual machine or host by DNS name.
func (SearchIndex) FindByInventoryPath ¶
FindByInventoryPath finds a managed entity based on its location in the inventory.
func (SearchIndex) FindByIp ¶
func (s SearchIndex) FindByIp(ctx context.Context, dc *Datacenter, ip string, vmSearch bool) (Reference, error)
FindByIp finds a virtual machine or host by IP address.
func (SearchIndex) FindByUuid ¶
func (s SearchIndex) FindByUuid(ctx context.Context, dc *Datacenter, uuid string, vmSearch bool, instanceUuid *bool) (Reference, error)
FindByUuid finds a virtual machine or host by UUID.
type StoragePod ¶
type StoragePod struct {
*Folder
}
func NewStoragePod ¶
func NewStoragePod(c *vim25.Client, ref types.ManagedObjectReference) *StoragePod
type StorageResourceManager ¶
type StorageResourceManager struct {
Common
}
func NewStorageResourceManager ¶
func NewStorageResourceManager(c *vim25.Client) *StorageResourceManager
func (StorageResourceManager) ApplyStorageDrsRecommendation ¶
func (StorageResourceManager) ApplyStorageDrsRecommendationToPod ¶
func (sr StorageResourceManager) ApplyStorageDrsRecommendationToPod(ctx context.Context, pod *StoragePod, key string) (*Task, error)
func (StorageResourceManager) CancelStorageDrsRecommendation ¶
func (sr StorageResourceManager) CancelStorageDrsRecommendation(ctx context.Context, key []string) error
func (StorageResourceManager) ConfigureDatastoreIORM ¶
func (sr StorageResourceManager) ConfigureDatastoreIORM(ctx context.Context, datastore *Datastore, spec types.StorageIORMConfigSpec, key string) (*Task, error)
func (StorageResourceManager) ConfigureStorageDrsForPod ¶
func (sr StorageResourceManager) ConfigureStorageDrsForPod(ctx context.Context, pod *StoragePod, spec types.StorageDrsConfigSpec, modify bool) (*Task, error)
func (StorageResourceManager) QueryDatastorePerformanceSummary ¶
func (sr StorageResourceManager) QueryDatastorePerformanceSummary(ctx context.Context, datastore *Datastore) ([]types.StoragePerformanceSummary, error)
func (StorageResourceManager) QueryIORMConfigOption ¶
func (sr StorageResourceManager) QueryIORMConfigOption(ctx context.Context, host *HostSystem) (*types.StorageIORMConfigOption, error)
func (StorageResourceManager) RecommendDatastores ¶
func (sr StorageResourceManager) RecommendDatastores(ctx context.Context, storageSpec types.StoragePlacementSpec) (*types.StoragePlacementResult, error)
func (StorageResourceManager) RefreshStorageDrsRecommendation ¶
func (sr StorageResourceManager) RefreshStorageDrsRecommendation(ctx context.Context, pod *StoragePod) error
type Task ¶
type Task struct {
Common
}
Task is a convenience wrapper around task.Task that keeps a reference to the client that was used to create it. This allows users to call the Wait() function with only a context parameter, instead of a context parameter, a soap.RoundTripper, and reference to the root property collector.
func (*Task) SetDescription ¶
SetDescription updates task description to describe the current phase of the task.
func (*Task) SetState ¶
func (t *Task) SetState(ctx context.Context, state types.TaskInfoState, result types.AnyType, fault *types.LocalizedMethodFault) error
SetState sets task state and optionally sets results or fault, as appropriate for state.
func (*Task) UpdateProgress ¶
UpdateProgress Sets percentage done for this task and recalculates overall percentage done. If a percentDone value of less than zero or greater than 100 is specified, a value of zero or 100 respectively is used.
type TenantManager ¶
type TenantManager struct {
Common
}
func NewTenantManager ¶
func NewTenantManager(c *vim25.Client) *TenantManager
func (TenantManager) MarkServiceProviderEntities ¶
func (t TenantManager) MarkServiceProviderEntities(ctx context.Context, entities []types.ManagedObjectReference) error
func (TenantManager) RetrieveServiceProviderEntities ¶
func (t TenantManager) RetrieveServiceProviderEntities(ctx context.Context) ([]types.ManagedObjectReference, error)
func (TenantManager) UnmarkServiceProviderEntities ¶
func (t TenantManager) UnmarkServiceProviderEntities(ctx context.Context, entities []types.ManagedObjectReference) error
type VirtualApp ¶
type VirtualApp struct {
*ResourcePool
}
func NewVirtualApp ¶
func NewVirtualApp(c *vim25.Client, ref types.ManagedObjectReference) *VirtualApp
func (VirtualApp) Clone ¶
func (p VirtualApp) Clone(ctx context.Context, name string, target types.ManagedObjectReference, spec types.VAppCloneSpec) (*Task, error)
func (VirtualApp) CreateChildVM ¶
func (p VirtualApp) CreateChildVM(ctx context.Context, config types.VirtualMachineConfigSpec, host *HostSystem) (*Task, error)
func (VirtualApp) UpdateConfig ¶
func (p VirtualApp) UpdateConfig(ctx context.Context, spec types.VAppConfigSpec) error
type VirtualDeviceList ¶
type VirtualDeviceList []types.BaseVirtualDevice
VirtualDeviceList provides helper methods for working with a list of virtual devices.
func EthernetCardTypes ¶
func EthernetCardTypes() VirtualDeviceList
EthernetCardTypes are used for adding a new ethernet card to a VM.
func SCSIControllerTypes ¶
func SCSIControllerTypes() VirtualDeviceList
SCSIControllerTypes are used for adding a new SCSI controller to a VM.
func (VirtualDeviceList) AssignController ¶
func (l VirtualDeviceList) AssignController(device types.BaseVirtualDevice, c types.BaseVirtualController)
AssignController assigns a device to a controller.
func (VirtualDeviceList) BootOrder ¶
func (l VirtualDeviceList) BootOrder(order []string) []types.BaseVirtualMachineBootOptionsBootableDevice
BootOrder returns a list of devices which can be used to set boot order via VirtualMachine.SetBootOptions. The order can be any of "ethernet", "cdrom", "floppy" or "disk" or by specific device name. A value of "-" will clear the existing boot order on the VC/ESX side.
func (VirtualDeviceList) ChildDisk ¶
func (l VirtualDeviceList) ChildDisk(parent *types.VirtualDisk) *types.VirtualDisk
ChildDisk creates a new VirtualDisk device, linked to the given parent disk, which can be added to a VM.
func (VirtualDeviceList) ConfigSpec ¶
func (l VirtualDeviceList) ConfigSpec(op types.VirtualDeviceConfigSpecOperation) ([]types.BaseVirtualDeviceConfigSpec, error)
ConfigSpec creates a virtual machine configuration spec for the specified operation, for the list of devices in the device list.
func (VirtualDeviceList) Connect ¶
func (l VirtualDeviceList) Connect(device types.BaseVirtualDevice) error
Connect changes the device to connected, returns an error if the device is not connectable.
func (VirtualDeviceList) ConnectSerialPort ¶
func (l VirtualDeviceList) ConnectSerialPort(device *types.VirtualSerialPort, uri string, client bool, proxyuri string) *types.VirtualSerialPort
ConnectSerialPort connects a serial port to a server or client uri.
func (VirtualDeviceList) CreateCdrom ¶
func (l VirtualDeviceList) CreateCdrom(c *types.VirtualIDEController) (*types.VirtualCdrom, error)
CreateCdrom creates a new VirtualCdrom device which can be added to a VM.
func (VirtualDeviceList) CreateDisk ¶
func (l VirtualDeviceList) CreateDisk(c types.BaseVirtualController, ds types.ManagedObjectReference, name string) *types.VirtualDisk
CreateDisk creates a new VirtualDisk device which can be added to a VM.
func (VirtualDeviceList) CreateEthernetCard ¶
func (l VirtualDeviceList) CreateEthernetCard(name string, backing types.BaseVirtualDeviceBackingInfo) (types.BaseVirtualDevice, error)
CreateEthernetCard creates a new VirtualEthernetCard of the given name name and initialized with the given backing.
func (VirtualDeviceList) CreateFloppy ¶
func (l VirtualDeviceList) CreateFloppy() (*types.VirtualFloppy, error)
CreateFloppy creates a new VirtualFloppy device which can be added to a VM.
func (VirtualDeviceList) CreateIDEController ¶
func (l VirtualDeviceList) CreateIDEController() (types.BaseVirtualDevice, error)
CreateIDEController creates a new IDE controller.
func (VirtualDeviceList) CreateNVMEController ¶
func (l VirtualDeviceList) CreateNVMEController() (types.BaseVirtualDevice, error)
CreateNVMEController creates a new NVMWE controller.
func (VirtualDeviceList) CreateSCSIController ¶
func (l VirtualDeviceList) CreateSCSIController(name string) (types.BaseVirtualDevice, error)
CreateSCSIController creates a new SCSI controller of type name if given, otherwise defaults to lsilogic.
func (VirtualDeviceList) CreateSerialPort ¶
func (l VirtualDeviceList) CreateSerialPort() (*types.VirtualSerialPort, error)
CreateSerialPort creates a new VirtualSerialPort device which can be added to a VM.
func (VirtualDeviceList) Disconnect ¶
func (l VirtualDeviceList) Disconnect(device types.BaseVirtualDevice) error
Disconnect changes the device to disconnected, returns an error if the device is not connectable.
func (VirtualDeviceList) DisconnectSerialPort ¶
func (l VirtualDeviceList) DisconnectSerialPort(device *types.VirtualSerialPort) *types.VirtualSerialPort
DisconnectSerialPort disconnects the serial port backing.
func (VirtualDeviceList) EjectImg ¶
func (l VirtualDeviceList) EjectImg(device *types.VirtualFloppy) *types.VirtualFloppy
EjectImg removes the img file based backing and replaces with the default floppy backing.
func (VirtualDeviceList) EjectIso ¶
func (l VirtualDeviceList) EjectIso(device *types.VirtualCdrom) *types.VirtualCdrom
EjectIso removes the iso file based backing and replaces with the default cdrom backing.
func (VirtualDeviceList) Find ¶
func (l VirtualDeviceList) Find(name string) types.BaseVirtualDevice
Find returns the device matching the given name.
func (VirtualDeviceList) FindByKey ¶
func (l VirtualDeviceList) FindByKey(key int32) types.BaseVirtualDevice
FindByKey returns the device matching the given key.
func (VirtualDeviceList) FindCdrom ¶
func (l VirtualDeviceList) FindCdrom(name string) (*types.VirtualCdrom, error)
FindCdrom finds a cdrom device with the given name, defaulting to the first cdrom device if any.
func (VirtualDeviceList) FindDiskController ¶
func (l VirtualDeviceList) FindDiskController(name string) (types.BaseVirtualController, error)
FindDiskController will find an existing ide or scsi disk controller.
func (VirtualDeviceList) FindFloppy ¶
func (l VirtualDeviceList) FindFloppy(name string) (*types.VirtualFloppy, error)
FindFloppy finds a floppy device with the given name, defaulting to the first floppy device if any.
func (VirtualDeviceList) FindIDEController ¶
func (l VirtualDeviceList) FindIDEController(name string) (*types.VirtualIDEController, error)
FindIDEController will find the named IDE controller if given, otherwise will pick an available controller. An error is returned if the named controller is not found or not an IDE controller. Or, if name is not given and no available controller can be found.
func (VirtualDeviceList) FindNVMEController ¶
func (l VirtualDeviceList) FindNVMEController(name string) (*types.VirtualNVMEController, error)
FindNVMEController will find the named NVME controller if given, otherwise will pick an available controller. An error is returned if the named controller is not found or not an NVME controller. Or, if name is not given and no available controller can be found.
func (VirtualDeviceList) FindSCSIController ¶
func (l VirtualDeviceList) FindSCSIController(name string) (*types.VirtualSCSIController, error)
FindSCSIController will find the named SCSI controller if given, otherwise will pick an available controller. An error is returned if the named controller is not found or not an SCSI controller. Or, if name is not given and no available controller can be found.
func (VirtualDeviceList) FindSerialPort ¶
func (l VirtualDeviceList) FindSerialPort(name string) (*types.VirtualSerialPort, error)
FindSerialPort finds a serial port device with the given name, defaulting to the first serial port device if any.
func (VirtualDeviceList) InsertImg ¶
func (l VirtualDeviceList) InsertImg(device *types.VirtualFloppy, img string) *types.VirtualFloppy
InsertImg changes the floppy device backing to use the given img file.
func (VirtualDeviceList) InsertIso ¶
func (l VirtualDeviceList) InsertIso(device *types.VirtualCdrom, iso string) *types.VirtualCdrom
InsertIso changes the cdrom device backing to use the given iso file.
func (VirtualDeviceList) Name ¶
func (l VirtualDeviceList) Name(device types.BaseVirtualDevice) string
Name returns a stable, human-readable name for the given device
func (VirtualDeviceList) NewKey ¶
func (l VirtualDeviceList) NewKey() int32
NewKey returns the key to use for adding a new device to the device list. The device list we're working with here may not be complete (e.g. when we're only adding new devices), so any positive keys could conflict with device keys that are already in use. To avoid this type of conflict, we can use negative keys here, which will be resolved to positive keys by vSphere as the reconfiguration is done.
func (VirtualDeviceList) PickController ¶
func (l VirtualDeviceList) PickController(kind types.BaseVirtualController) types.BaseVirtualController
PickController returns a controller of the given type(s). If no controllers are found or have no available slots, then nil is returned.
func (VirtualDeviceList) PrimaryMacAddress ¶
func (l VirtualDeviceList) PrimaryMacAddress() string
PrimaryMacAddress returns the MacAddress field of the primary VirtualEthernetCard
func (VirtualDeviceList) Select ¶
func (l VirtualDeviceList) Select(f func(device types.BaseVirtualDevice) bool) VirtualDeviceList
Select returns a new list containing all elements of the list for which the given func returns true.
func (VirtualDeviceList) SelectBootOrder ¶
func (l VirtualDeviceList) SelectBootOrder(order []types.BaseVirtualMachineBootOptionsBootableDevice) VirtualDeviceList
SelectBootOrder returns an ordered list of devices matching the given bootable device order
func (VirtualDeviceList) SelectByBackingInfo ¶
func (l VirtualDeviceList) SelectByBackingInfo(backing types.BaseVirtualDeviceBackingInfo) VirtualDeviceList
SelectByBackingInfo returns a new list with devices matching the given backing info. If the value of backing is nil, any device with a backing of the same type will be returned.
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/types" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { finder := find.NewFinder(c) vm, err := finder.VirtualMachine(ctx, "DC0_H0_VM0") if err != nil { return err } backing := &types.VirtualPCIPassthroughVmiopBackingInfo{ Vgpu: "grid_v100-4q", } gpu := &types.VirtualPCIPassthrough{ VirtualDevice: types.VirtualDevice{Backing: backing}, } err = vm.AddDevice(ctx, gpu) // add a GPU to this VM if err != nil { return err } device, err := vm.Device(ctx) // get the VM's virtual device list if err != nil { return err } // find the device with the given backing info gpus := device.SelectByBackingInfo(backing) name := gpus[0].(*types.VirtualPCIPassthrough).Backing.(*types.VirtualPCIPassthroughVmiopBackingInfo).Vgpu fmt.Println(name) // example alternative to using SelectByBackingInfo for the use-case above: for i := range device { switch d := device[i].(type) { case *types.VirtualPCIPassthrough: switch b := d.Backing.(type) { case *types.VirtualPCIPassthroughVmiopBackingInfo: if b.Vgpu == backing.Vgpu { fmt.Println(b.Vgpu) } } } } return nil }) }
Output: grid_v100-4q grid_v100-4q
func (VirtualDeviceList) SelectByType ¶
func (l VirtualDeviceList) SelectByType(deviceType types.BaseVirtualDevice) VirtualDeviceList
SelectByType returns a new list with devices that are equal to or extend the given type.
func (VirtualDeviceList) Type ¶
func (l VirtualDeviceList) Type(device types.BaseVirtualDevice) string
Type returns a human-readable name for the given device
func (VirtualDeviceList) TypeName ¶
func (l VirtualDeviceList) TypeName(device types.BaseVirtualDevice) string
TypeName returns the vmodl type name of the device
type VirtualDiskInfo ¶
type VirtualDiskManager ¶
type VirtualDiskManager struct {
Common
}
func NewVirtualDiskManager ¶
func NewVirtualDiskManager(c *vim25.Client) *VirtualDiskManager
func (VirtualDiskManager) CopyVirtualDisk ¶
func (m VirtualDiskManager) CopyVirtualDisk( ctx context.Context, sourceName string, sourceDatacenter *Datacenter, destName string, destDatacenter *Datacenter, destSpec *types.VirtualDiskSpec, force bool) (*Task, error)
CopyVirtualDisk copies a virtual disk, performing conversions as specified in the spec.
func (VirtualDiskManager) CreateChildDisk ¶
func (m VirtualDiskManager) CreateChildDisk(ctx context.Context, parent string, pdc *Datacenter, name string, dc *Datacenter, linked bool) (*Task, error)
func (VirtualDiskManager) CreateVirtualDisk ¶
func (m VirtualDiskManager) CreateVirtualDisk( ctx context.Context, name string, datacenter *Datacenter, spec types.BaseVirtualDiskSpec) (*Task, error)
CreateVirtualDisk creates a new virtual disk.
func (VirtualDiskManager) DeleteVirtualDisk ¶
func (m VirtualDiskManager) DeleteVirtualDisk(ctx context.Context, name string, dc *Datacenter) (*Task, error)
DeleteVirtualDisk deletes a virtual disk.
func (VirtualDiskManager) InflateVirtualDisk ¶
func (m VirtualDiskManager) InflateVirtualDisk(ctx context.Context, name string, dc *Datacenter) (*Task, error)
InflateVirtualDisk inflates a virtual disk.
func (VirtualDiskManager) MoveVirtualDisk ¶
func (m VirtualDiskManager) MoveVirtualDisk( ctx context.Context, sourceName string, sourceDatacenter *Datacenter, destName string, destDatacenter *Datacenter, force bool) (*Task, error)
MoveVirtualDisk moves a virtual disk.
func (VirtualDiskManager) QueryVirtualDiskInfo ¶
func (m VirtualDiskManager) QueryVirtualDiskInfo(ctx context.Context, name string, dc *Datacenter, includeParents bool) ([]VirtualDiskInfo, error)
func (VirtualDiskManager) QueryVirtualDiskUuid ¶
func (m VirtualDiskManager) QueryVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter) (string, error)
Queries virtual disk uuid
func (VirtualDiskManager) SetVirtualDiskUuid ¶
func (m VirtualDiskManager) SetVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter, uuid string) error
func (VirtualDiskManager) ShrinkVirtualDisk ¶
func (m VirtualDiskManager) ShrinkVirtualDisk(ctx context.Context, name string, dc *Datacenter, copy *bool) (*Task, error)
ShrinkVirtualDisk shrinks a virtual disk.
type VirtualMachine ¶
type VirtualMachine struct {
Common
}
Example (ResourcePoolOwner) ¶
Find a VirtualMachine's Cluster
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { obj, err := find.NewFinder(c).VirtualMachine(ctx, "DC0_C0_RP0_VM0") if err != nil { return err } pool, err := obj.ResourcePool(ctx) if err != nil { return err } // ResourcePool owner will be a ComputeResource or ClusterComputeResource cluster, err := pool.Owner(ctx) if err != nil { return err } fmt.Printf("%s", cluster.Reference().Type) return nil }) }
Output: ClusterComputeResource
func NewVirtualMachine ¶
func NewVirtualMachine(c *vim25.Client, ref types.ManagedObjectReference) *VirtualMachine
func (VirtualMachine) AcquireTicket ¶
func (v VirtualMachine) AcquireTicket(ctx context.Context, kind string) (*types.VirtualMachineTicket, error)
func (VirtualMachine) AddDevice ¶
func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
AddDevice adds the given devices to the VirtualMachine
func (VirtualMachine) Answer ¶
func (v VirtualMachine) Answer(ctx context.Context, id, answer string) error
Answer answers a pending question.
func (VirtualMachine) AttachDisk ¶
func (v VirtualMachine) AttachDisk(ctx context.Context, id string, datastore *Datastore, controllerKey int32, unitNumber int32) error
AttachDisk attaches the given disk to the VirtualMachine
func (VirtualMachine) BootOptions ¶
func (v VirtualMachine) BootOptions(ctx context.Context) (*types.VirtualMachineBootOptions, error)
BootOptions returns the VirtualMachine's config.bootOptions property.
func (VirtualMachine) Clone ¶
func (v VirtualMachine) Clone(ctx context.Context, folder *Folder, name string, config types.VirtualMachineCloneSpec) (*Task, error)
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/types" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { finder := find.NewFinder(c) dc, err := finder.Datacenter(ctx, "DC0") if err != nil { return err } finder.SetDatacenter(dc) vm, err := finder.VirtualMachine(ctx, "DC0_H0_VM0") if err != nil { return err } folders, err := dc.Folders(ctx) if err != nil { return err } spec := types.VirtualMachineCloneSpec{ PowerOn: false, } task, err := vm.Clone(ctx, folders.VmFolder, "example-clone", spec) if err != nil { return err } info, err := task.WaitForResult(ctx) if err != nil { return err } clone := object.NewVirtualMachine(c, info.Result.(types.ManagedObjectReference)) name, err := clone.ObjectName(ctx) if err != nil { return err } fmt.Println(name) return nil }) }
Output: example-clone
func (VirtualMachine) CreateSnapshot ¶
func (v VirtualMachine) CreateSnapshot(ctx context.Context, name string, description string, memory bool, quiesce bool) (*Task, error)
CreateSnapshot creates a new snapshot of a virtual machine.
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/mo" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { vm, err := find.NewFinder(c).VirtualMachine(ctx, "DC0_H0_VM0") if err != nil { return err } task, err := vm.CreateSnapshot(ctx, "backup", "Backup", false, false) if err != nil { return err } if err = task.Wait(ctx); err != nil { return err } id, err := vm.FindSnapshot(ctx, "backup") if err != nil { return err } var snapshot mo.VirtualMachineSnapshot err = vm.Properties(ctx, *id, []string{"config.hardware.device"}, &snapshot) if err != nil { return err } fmt.Printf("%d devices", len(snapshot.Config.Hardware.Device)) return nil }) }
Output: 13 devices
func (VirtualMachine) Customize ¶
func (v VirtualMachine) Customize(ctx context.Context, spec types.CustomizationSpec) (*Task, error)
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/types" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { vm, err := find.NewFinder(c).VirtualMachine(ctx, "DC0_H0_VM0") if err != nil { return err } task, err := vm.PowerOff(ctx) if err != nil { return err } if err = task.Wait(ctx); err != nil { return err } spec := types.CustomizationSpec{ NicSettingMap: []types.CustomizationAdapterMapping{ types.CustomizationAdapterMapping{ Adapter: types.CustomizationIPSettings{ Ip: &types.CustomizationFixedIp{ IpAddress: "192.168.1.100", }, SubnetMask: "255.255.255.0", Gateway: []string{"192.168.1.1"}, DnsServerList: []string{"192.168.1.1"}, DnsDomain: "ad.domain", }, }, }, Identity: &types.CustomizationLinuxPrep{ HostName: &types.CustomizationFixedName{ Name: "hostname", }, Domain: "ad.domain", TimeZone: "Etc/UTC", HwClockUTC: types.NewBool(true), }, GlobalIPSettings: types.CustomizationGlobalIPSettings{ DnsSuffixList: []string{"ad.domain"}, DnsServerList: []string{"192.168.1.1"}, }, } task, err = vm.Customize(ctx, spec) if err != nil { return err } if err = task.Wait(ctx); err != nil { return err } task, err = vm.PowerOn(ctx) if err != nil { return err } if err = task.Wait(ctx); err != nil { return err } ip, err := vm.WaitForIP(ctx) if err != nil { return err } fmt.Println(ip) return nil }) }
Output: 192.168.1.100
func (VirtualMachine) DetachDisk ¶
func (v VirtualMachine) DetachDisk(ctx context.Context, id string) error
DetachDisk detaches the given disk from the VirtualMachine
func (VirtualMachine) Device ¶
func (v VirtualMachine) Device(ctx context.Context) (VirtualDeviceList, error)
Device returns the VirtualMachine's config.hardware.device property.
func (VirtualMachine) EditDevice ¶
func (v VirtualMachine) EditDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
EditDevice edits the given (existing) devices on the VirtualMachine
func (*VirtualMachine) ExportSnapshot ¶
func (v *VirtualMachine) ExportSnapshot(ctx context.Context, snapshot *types.ManagedObjectReference) (*nfc.Lease, error)
ExportSnapshot exports all VMDK-files up to (but not including) a specified snapshot. This is useful when exporting a running VM.
func (VirtualMachine) FindSnapshot ¶
func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (*types.ManagedObjectReference, error)
FindSnapshot supports snapshot lookup by name, where name can be: 1) snapshot ManagedObjectReference.Value (unique) 2) snapshot name (may not be unique) 3) snapshot tree path (may not be unique)
func (VirtualMachine) HostSystem ¶
func (v VirtualMachine) HostSystem(ctx context.Context) (*HostSystem, error)
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { vm, err := find.NewFinder(c).VirtualMachine(ctx, "DC0_H0_VM0") if err != nil { return err } host, err := vm.HostSystem(ctx) if err != nil { return err } name, err := host.ObjectName(ctx) if err != nil { return err } fmt.Println(name) return nil }) }
Output: DC0_H0
func (VirtualMachine) InstantClone ¶
func (v VirtualMachine) InstantClone(ctx context.Context, config types.VirtualMachineInstantCloneSpec) (*Task, error)
func (VirtualMachine) IsTemplate ¶
func (v VirtualMachine) IsTemplate(ctx context.Context) (bool, error)
func (VirtualMachine) IsToolsRunning ¶
func (v VirtualMachine) IsToolsRunning(ctx context.Context) (bool, error)
IsToolsRunning returns true if VMware Tools is currently running in the guest OS, and false otherwise.
func (VirtualMachine) MarkAsTemplate ¶
func (v VirtualMachine) MarkAsTemplate(ctx context.Context) error
func (VirtualMachine) MarkAsVirtualMachine ¶
func (v VirtualMachine) MarkAsVirtualMachine(ctx context.Context, pool ResourcePool, host *HostSystem) error
func (VirtualMachine) Migrate ¶
func (v VirtualMachine) Migrate(ctx context.Context, pool *ResourcePool, host *HostSystem, priority types.VirtualMachineMovePriority, state types.VirtualMachinePowerState) (*Task, error)
func (VirtualMachine) MountToolsInstaller ¶
func (v VirtualMachine) MountToolsInstaller(ctx context.Context) error
func (VirtualMachine) PowerOff ¶
func (v VirtualMachine) PowerOff(ctx context.Context) (*Task, error)
func (VirtualMachine) PowerState ¶
func (v VirtualMachine) PowerState(ctx context.Context) (types.VirtualMachinePowerState, error)
func (VirtualMachine) PutUsbScanCodes ¶
func (v VirtualMachine) PutUsbScanCodes(ctx context.Context, spec types.UsbScanCodeSpec) (int32, error)
func (VirtualMachine) QueryChangedDiskAreas ¶
func (v VirtualMachine) QueryChangedDiskAreas(ctx context.Context, baseSnapshot, curSnapshot *types.ManagedObjectReference, disk *types.VirtualDisk, offset int64) (types.DiskChangeInfo, error)
func (VirtualMachine) QueryConfigTarget ¶
func (v VirtualMachine) QueryConfigTarget(ctx context.Context) (*types.ConfigTarget, error)
QueryEnvironmentBrowser is a helper to get the environmentBrowser property.
func (VirtualMachine) RebootGuest ¶
func (v VirtualMachine) RebootGuest(ctx context.Context) error
func (VirtualMachine) Reconfigure ¶
func (v VirtualMachine) Reconfigure(ctx context.Context, config types.VirtualMachineConfigSpec) (*Task, error)
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/types" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { vm, err := find.NewFinder(c).VirtualMachine(ctx, "DC0_H0_VM0") if err != nil { return err } spec := types.VirtualMachineConfigSpec{Annotation: "example reconfig"} task, err := vm.Reconfigure(ctx, spec) if err != nil { return err } err = task.Wait(ctx) if err != nil { return err } var obj mo.VirtualMachine err = vm.Properties(ctx, vm.Reference(), []string{"config.annotation"}, &obj) if err != nil { return err } fmt.Println(obj.Config.Annotation) return nil }) }
Output: example reconfig
func (VirtualMachine) RefreshStorageInfo ¶
func (v VirtualMachine) RefreshStorageInfo(ctx context.Context) error
func (VirtualMachine) Relocate ¶
func (v VirtualMachine) Relocate(ctx context.Context, config types.VirtualMachineRelocateSpec, priority types.VirtualMachineMovePriority) (*Task, error)
func (VirtualMachine) RemoveAllSnapshot ¶
RemoveAllSnapshot removes all snapshots of a virtual machine
func (VirtualMachine) RemoveDevice ¶
func (v VirtualMachine) RemoveDevice(ctx context.Context, keepFiles bool, device ...types.BaseVirtualDevice) error
RemoveDevice removes the given devices on the VirtualMachine
func (VirtualMachine) RemoveSnapshot ¶
func (v VirtualMachine) RemoveSnapshot(ctx context.Context, name string, removeChildren bool, consolidate *bool) (*Task, error)
RemoveSnapshot removes a named snapshot
func (VirtualMachine) ResourcePool ¶
func (v VirtualMachine) ResourcePool(ctx context.Context) (*ResourcePool, error)
Example ¶
package main import ( "context" "fmt" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/simulator" "github.com/vmware/govmomi/vim25" ) func main() { simulator.Run(func(ctx context.Context, c *vim25.Client) error { finder := find.NewFinder(c) vm, err := finder.VirtualMachine(ctx, "DC0_C0_RP0_VM0") if err != nil { return err } pool, err := vm.ResourcePool(ctx) if err != nil { return err } name, err := pool.ObjectName(ctx) if err != nil { return err } fmt.Println(name) // The InventoryPath field not populated unless Finder.ResourcePool() or // Finder.ResourcePoolList() was used. But we can populate it explicity. pool.InventoryPath, err = find.InventoryPath(ctx, c, pool.Reference()) if err != nil { return err } fmt.Println(pool.InventoryPath) return nil }) }
Output: Resources /DC0/host/DC0_C0/Resources
func (VirtualMachine) RevertToCurrentSnapshot ¶
func (v VirtualMachine) RevertToCurrentSnapshot(ctx context.Context, suppressPowerOn bool) (*Task, error)
RevertToCurrentSnapshot reverts to the current snapshot
func (VirtualMachine) RevertToSnapshot ¶
func (v VirtualMachine) RevertToSnapshot(ctx context.Context, name string, suppressPowerOn bool) (*Task, error)
RevertToSnapshot reverts to a named snapshot
func (VirtualMachine) SetBootOptions ¶
func (v VirtualMachine) SetBootOptions(ctx context.Context, options *types.VirtualMachineBootOptions) error
SetBootOptions reconfigures the VirtualMachine with the given options.
func (VirtualMachine) ShutdownGuest ¶
func (v VirtualMachine) ShutdownGuest(ctx context.Context) error
func (VirtualMachine) StandbyGuest ¶
func (v VirtualMachine) StandbyGuest(ctx context.Context) error
func (VirtualMachine) UUID ¶
func (v VirtualMachine) UUID(ctx context.Context) string
UUID is a helper to get the UUID of the VirtualMachine managed object. This method returns an empty string if an error occurs when retrieving UUID from the VirtualMachine object.
func (VirtualMachine) UnmountToolsInstaller ¶
func (v VirtualMachine) UnmountToolsInstaller(ctx context.Context) error
func (VirtualMachine) Unregister ¶
func (v VirtualMachine) Unregister(ctx context.Context) error
func (VirtualMachine) UpgradeTools ¶
func (VirtualMachine) WaitForIP ¶
WaitForIP waits for the VM guest.ipAddress property to report an IP address. Waits for an IPv4 address if the v4 param is true.
func (VirtualMachine) WaitForNetIP ¶
func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...string) (map[string][]string, error)
WaitForNetIP waits for the VM guest.net property to report an IP address for all VM NICs. Only consider IPv4 addresses if the v4 param is true. By default, wait for all NICs to get an IP address, unless 1 or more device is given. A device can be specified by the MAC address or the device name, e.g. "ethernet-0". Returns a map with MAC address as the key and IP address list as the value.
func (VirtualMachine) WaitForPowerState ¶
func (v VirtualMachine) WaitForPowerState(ctx context.Context, state types.VirtualMachinePowerState) error
Wait for the VirtualMachine to change to the desired power state.
type VmwareDistributedVirtualSwitch ¶
type VmwareDistributedVirtualSwitch struct {
DistributedVirtualSwitch
}
func (VmwareDistributedVirtualSwitch) GetInventoryPath ¶
func (s VmwareDistributedVirtualSwitch) GetInventoryPath() string
type VsanObjExtAttrs ¶
type VsanObjExtAttrs struct { Type string `json:"Object type"` Class string `json:"Object class"` Size string `json:"Object size"` Path string `json:"Object path"` Name string `json:"User friendly name"` }
func (*VsanObjExtAttrs) DatastorePath ¶
func (a *VsanObjExtAttrs) DatastorePath(dir string) string
Source Files ¶
- authorization_manager.go
- authorization_manager_internal.go
- cluster_compute_resource.go
- common.go
- compute_resource.go
- custom_fields_manager.go
- customization_spec_manager.go
- datacenter.go
- datastore.go
- datastore_file.go
- datastore_file_manager.go
- datastore_path.go
- diagnostic_log.go
- diagnostic_manager.go
- distributed_virtual_portgroup.go
- distributed_virtual_switch.go
- extension_manager.go
- file_manager.go
- folder.go
- host_account_manager.go
- host_certificate_info.go
- host_certificate_manager.go
- host_config_manager.go
- host_datastore_browser.go
- host_datastore_system.go
- host_date_time_system.go
- host_firewall_system.go
- host_network_system.go
- host_service_system.go
- host_storage_system.go
- host_system.go
- host_virtual_nic_manager.go
- host_vsan_internal_system.go
- host_vsan_system.go
- namespace_manager.go
- network.go
- network_reference.go
- opaque_network.go
- option_manager.go
- resource_pool.go
- search_index.go
- storage_pod.go
- storage_resource_manager.go
- task.go
- tenant_manager.go
- types.go
- virtual_app.go
- virtual_device_list.go
- virtual_disk_manager.go
- virtual_disk_manager_internal.go
- virtual_machine.go
- vmware_distributed_virtual_switch.go