Documentation
¶
Index ¶
- func CheckInHost(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) (*object.HostSystem, error)
- func CheckOutHost(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) (*object.HostSystem, error)
- func CheckOutSelectedHost(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) error
- func ConfigureImage(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) error
- func CopyImage(ctx context.Context, source ImageSource, destination ImageDestination, ...) error
- func DatastoreMoveImage(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) error
- func IsHostCheckedOut(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) (bool, error)
- func ListImages(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) ([]*object.VirtualMachine, error)
- func MigrateImage(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) error
- func MoveImage(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) error
- func RestoreBackup(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) error
- func SelectAvailableHost(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) (*object.HostSystem, error)
- func SnapshotImage(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, ...) error
- type ImageDestination
- type ImageSource
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckInHost ¶
func CheckOutHost ¶
func CheckOutSelectedHost ¶
func ConfigureImage ¶
func CopyImage ¶
func CopyImage(ctx context.Context, source ImageSource, destination ImageDestination, s progress.Sinker) error
Example ¶
package main
import (
"context"
"net/url"
vsphereimages "github.com/travis-ci/vsphere-images"
)
func main() {
vSphereSourceURL, _ := url.Parse("https://admin@password:vsphere1.example.com/sdk")
vSphereDestinationURL, _ := url.Parse("https://admin@password:vsphere2.example.com/sdk")
source := vsphereimages.ImageSource{
VSphereEndpoint: vSphereSourceURL,
VMPath: "/dc01/vm/base vms/foo",
}
destination := vsphereimages.ImageDestination{
VSphereEndpoint: vSphereDestinationURL,
FolderPath: "/dc02/vm/base vms/",
DatastorePath: "/dc02/datastore/main-datastore",
ResourcePoolPath: "/dc02/host/main-pool",
HostPath: "/dc02/host/main-pool/host01",
VMName: "foo",
}
vsphereimages.CopyImage(context.TODO(), source, destination, nil)
}
Output:
func DatastoreMoveImage ¶
func IsHostCheckedOut ¶
func ListImages ¶
func ListImages(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, folderPath string) ([]*object.VirtualMachine, error)
ListImages returns a list of all of the virtual machines in a folder.
func MigrateImage ¶
func RestoreBackup ¶
func RestoreBackup(ctx context.Context, vSphereEndpoint *url.URL, vSphereInsecureSkipVerify bool, sourceImagePath string, destinationFolderPath string, defaultDatastorePath string, defaultResourcePool string, s progress.Sinker) error
RestoreBackup clones a backed up VM image into its original location within the same datacenter.
The VM will be cloned initialially with its name suffixed with "-restoring" in the destination folder. Once the clone is complete, the cloned VM will receive a new base snapshot. If there is an existing VM at the destination path, it will be renamed with a "-old" suffix. Finally, the restored VM will be renamed to match its original name.
func SelectAvailableHost ¶
Types ¶
type ImageDestination ¶
type ImageDestination struct {
// VSphereEndpoint is the URL to the vSphere API, including the
// credentials. Usually this is something like
// `https://user@password:your-vsphere-host/sdk`.
VSphereEndpoint *url.URL
// VSphereInsecureSkipVerify controls whether the server's certificate
// chain and hostname should be verified. If VSphereInsecureSkipVerify is
// true, any certificate presented by the server and any host name in that
// certificate will be accepted. See also
// crypto/tls.Config.InsecureSkipVerify.
VSphereInsecureSkipVerify bool
// VSphereSHA1Fingerprint is the SHA-1 fingerprint of the vSphere API
// endpoint. It should be formatted as a series of :-separated uppercase
// hexadecimal numbers. If the string is empty, the ImageCopier will
// attempt to connect to the endpoint and use that fingerprint.
VSphereSHA1Fingerprint string
// FolderPath is the inventory path to the folder in the destination
// vCenter to copy the VM to. Folder inventory paths usually look something
// like `/your-datacenter/vm/folder-name`.
FolderPath string
// DatastorePath is the inventory path to the datastore in the destination
// vCenter to copy the VM to. Datastore inventory paths usually look
// something like `/your-datacenter/datastore/datastore-name`.
DatastorePath string
// ResourcePoolPath is the inventory path to the resource pool in the
// destination vCenter to copy the VM to. Resource pool paths usually look
// something like `/your-datacenter/host/pool-name`.
ResourcePoolPath string
// HostPath is the inventory path to the host in the destination vCenter to
// copy the VM to. Note that this host should be a part of the resource
// pool in ResourcePoolPath. Host inventory paths for hosts in a resource
// pool usually look something like
// `/your-datacenter/host/pool-name/host-name`.
HostPath string
// NetworkPath is the inventory path to the network (dvSwitch, dvPortGroup,
// etc.) to connect the copied VM to. Network inventory paths usually look
// something like `/your-datacenter/network/name-of-portgroup`.
NetworkPath string
// VMName is the name to give to the destination VM.
VMName string
}
type ImageSource ¶
type ImageSource struct {
// VSphereEndpoint is the URL to the vSphere API, including the
// credentials. Usually this is something like
// `https://user@password:your-vsphere-host/sdk`.
VSphereEndpoint *url.URL
// VSphereInsecureSkipVerify controls whether the server's certificate
// chain and hostname should be verified. If VSphereInsecureSkipVerify is
// true, any certificate presented by the server and any host name in that
// certificate will be accepted. See also
// crypto/tls.Config.InsecureSkipVerify.
VSphereInsecureSkipVerify bool
// VMPath is the inventory path to the source VM. This is usually something
// like `/your-datacenter/vm/folder-name/vm-name`.
VMPath string
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.