Documentation ¶
Index ¶
- Constants
- func DatastoreFolderFromObject(client *govmomi.Client, obj interface{}, relative string) (*object.Folder, error)
- func FromAbsolutePath(client *govmomi.Client, path string) (*object.Folder, error)
- func FromID(client *govmomi.Client, id string) (*object.Folder, error)
- func FromPath(c *govmomi.Client, p string, ft VSphereFolderType, dc *object.Datacenter) (*object.Folder, error)
- func HasChildren(f *object.Folder) (bool, error)
- func HostFolderFromObject(client *govmomi.Client, obj interface{}, relative string) (*object.Folder, error)
- func MoveObjectTo(ref types.ManagedObjectReference, folder *object.Folder) error
- func NormalizePath(v interface{}) string
- func ParentFromPath(c *govmomi.Client, p string, ft VSphereFolderType, dc *object.Datacenter) (*object.Folder, error)
- func PathIsEmpty(path string) bool
- func Properties(folder *object.Folder) (*mo.Folder, error)
- func VirtualMachineFolderFromObject(client *govmomi.Client, obj interface{}, relative string) (*object.Folder, error)
- type RootPathParticle
- func (p RootPathParticle) Delimiter() string
- func (p RootPathParticle) NewRootFromPath(inventoryPath string, newParticle RootPathParticle) (string, error)
- func (p RootPathParticle) PathFromDatacenter(dc *object.Datacenter, relative string) string
- func (p RootPathParticle) PathFromNewRoot(inventoryPath string, newParticle RootPathParticle, relative string) (string, error)
- func (p RootPathParticle) RootFromDatacenter(dc *object.Datacenter) string
- func (p RootPathParticle) SplitDatacenter(inventoryPath string) (string, error)
- func (p RootPathParticle) SplitRelative(inventoryPath string) (string, error)
- func (p RootPathParticle) SplitRelativeFolder(inventoryPath string) (string, error)
- func (p RootPathParticle) String() string
- type VSphereFolderType
Constants ¶
const ( VSphereFolderTypeVM = VSphereFolderType("vm") VSphereFolderTypeNetwork = VSphereFolderType("network") VSphereFolderTypeHost = VSphereFolderType("host") VSphereFolderTypeDatastore = VSphereFolderType("datastore") // VSphereFolderTypeDatacenter is a special folder type - it does not get a // root path particle generated for it as it is an integral part of the path // generation process, but is defined so that it can be properly referenced // and used in validation. VSphereFolderTypeDatacenter = VSphereFolderType("datacenter") )
The following are constants for the 5 vSphere folder types - these are used to help determine base paths and also to validate folder types in the vsphere_folder resource.
const ( // RootPathParticleVM provides root path parsing functionality for VM paths. RootPathParticleVM = RootPathParticle(VSphereFolderTypeVM) // RootPathParticleNetwork provides root path parsing functionality for // network paths. RootPathParticleNetwork = RootPathParticle(VSphereFolderTypeNetwork) // RootPathParticleHost provides root path parsing functionality for host and // cluster paths. RootPathParticleHost = RootPathParticle(VSphereFolderTypeHost) // RootPathParticleDatastore provides root path parsing functionality for // datastore paths. RootPathParticleDatastore = RootPathParticle(VSphereFolderTypeDatastore) )
Variables ¶
This section is empty.
Functions ¶
func DatastoreFolderFromObject ¶
func DatastoreFolderFromObject(client *govmomi.Client, obj interface{}, relative string) (*object.Folder, error)
DatastoreFolderFromObject returns an *object.Folder from a given object, and relative datastore folder path. If no such folder is found, of if it is not a datastore folder, an appropriate error will be returned.
func FromAbsolutePath ¶
FromAbsolutePath returns an *object.Folder from a given absolute path. If no such folder is found, an appropriate error will be returned.
func FromPath ¶
func FromPath(c *govmomi.Client, p string, ft VSphereFolderType, dc *object.Datacenter) (*object.Folder, error)
FromPath takes a relative folder path, an object type, and an optional supplied datacenter, and returns the respective *object.Folder if it exists.
The datacenter supplied in dc cannot be nil if the folder type supplied by ft is something else other than VSphereFolderTypeDatacenter.
func HasChildren ¶
HasChildren checks to see if a folder has any child items and returns true if that is the case. This is useful when checking to see if a folder is safe to delete - destroying a folder in vSphere destroys *all* children if at all possible (including removing virtual machines), so extra verification is necessary to prevent accidental removal.
func HostFolderFromObject ¶ added in v1.5.0
func HostFolderFromObject(client *govmomi.Client, obj interface{}, relative string) (*object.Folder, error)
HostFolderFromObject returns an *object.Folder from a given object, and relative host folder path. If no such folder is found, or if it is not a host folder, an appropriate error will be returned.
func MoveObjectTo ¶
func MoveObjectTo(ref types.ManagedObjectReference, folder *object.Folder) error
MoveObjectTo moves a object by reference into a folder.
func NormalizePath ¶
func NormalizePath(v interface{}) string
NormalizePath is a SchemaStateFunc that normalizes a folder path.
func ParentFromPath ¶
func ParentFromPath(c *govmomi.Client, p string, ft VSphereFolderType, dc *object.Datacenter) (*object.Folder, error)
ParentFromPath takes a relative object path (usually a folder), an object type, and an optional supplied datacenter, and returns the parent *object.Folder if it exists.
The datacenter supplied in dc cannot be nil if the folder type supplied by ft is something else other than VSphereFolderTypeDatacenter.
func PathIsEmpty ¶
PathIsEmpty checks a folder path to see if it's "empty" (ie: would resolve to the root inventory path for a given type in a datacenter - "" or "/").
func Properties ¶
Properties is a convenience method that wraps fetching the Folder MO from its higher-level object.
func VirtualMachineFolderFromObject ¶
func VirtualMachineFolderFromObject(client *govmomi.Client, obj interface{}, relative string) (*object.Folder, error)
VirtualMachineFolderFromObject returns an *object.Folder from a given object, and relative datastore folder path. If no such folder is found, or if it is not a VM folder, an appropriate error will be returned.
Types ¶
type RootPathParticle ¶
type RootPathParticle VSphereFolderType
RootPathParticle is the section of a vSphere inventory path that denotes a specific kind of inventory item.
func (RootPathParticle) Delimiter ¶
func (p RootPathParticle) Delimiter() string
Delimiter returns the path delimiter for the particle, which is basically just a particle with a leading slash.
func (RootPathParticle) NewRootFromPath ¶
func (p RootPathParticle) NewRootFromPath(inventoryPath string, newParticle RootPathParticle) (string, error)
NewRootFromPath takes the datacenter path for a specific entity, and then appends the new particle supplied.
func (RootPathParticle) PathFromDatacenter ¶
func (p RootPathParticle) PathFromDatacenter(dc *object.Datacenter, relative string) string
PathFromDatacenter returns the combined result of RootFromDatacenter plus a relative path for a given particle and datacenter object.
func (RootPathParticle) PathFromNewRoot ¶
func (p RootPathParticle) PathFromNewRoot(inventoryPath string, newParticle RootPathParticle, relative string) (string, error)
PathFromNewRoot takes the datacenter path for a specific entity, and then appends the new particle supplied with the new relative path.
As an example, consider a supplied host path "/dc1/host/cluster1/esxi1", and a supplied datastore folder relative path of "/foo/bar". This function will split off the datacenter section of the path (/dc1) and combine it with the datastore folder with the proper delimiter. The resulting path will be "/dc1/datastore/foo/bar".
func (RootPathParticle) RootFromDatacenter ¶
func (p RootPathParticle) RootFromDatacenter(dc *object.Datacenter) string
RootFromDatacenter returns the root path for the particle from the given datacenter's inventory path.
func (RootPathParticle) SplitDatacenter ¶
func (p RootPathParticle) SplitDatacenter(inventoryPath string) (string, error)
SplitDatacenter is a convenience method that splits out the datacenter path from the supplied path for the particle.
func (RootPathParticle) SplitRelative ¶
func (p RootPathParticle) SplitRelative(inventoryPath string) (string, error)
SplitRelative is a convenience method that splits out the relative path from the supplied path for the particle.
func (RootPathParticle) SplitRelativeFolder ¶
func (p RootPathParticle) SplitRelativeFolder(inventoryPath string) (string, error)
SplitRelativeFolder is a convenience method that returns the parent folder for the result of SplitRelative on the supplied path.
This is generally useful to get the folder for a managed entity, versus getting a full relative path. If you want that, use SplitRelative instead.
func (RootPathParticle) String ¶
func (p RootPathParticle) String() string
String implements Stringer for RootPathParticle.
type VSphereFolderType ¶
type VSphereFolderType string
VSphereFolderType is an enumeration type for vSphere folder types.