vsphere

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MPL-2.0 Imports: 62 Imported by: 3

Documentation

Index

Constants

View Source
const TAG_NAMESPACE = "http://www.vmware.com/storage/tag"
View Source
const TAG_PLACEMENT = "Tag based placement"

Variables

View Source
var (
	// ErrNoSuchKeyFound is an error primarily thrown by the Read method of the resource.
	// The error doesn't display the key itself for security reasons.
	ErrNoSuchKeyFound = errors.New("The key was not found")
	// ErrKeyCannotBeDeleted is an error which occurs when a key that is used by VMs is
	// being removed
	ErrKeyCannotBeDeleted = errors.New("The key wasn't deleted")
)

Functions

func BaseVMKernelSchema added in v1.21.0

func BaseVMKernelSchema() map[string]*schema.Schema

VmKernelSchema returns the schema required to represent a vNIC adapter on an ESX Host. We make this public so we can pull this from the host resource as well.

func DecodeError added in v0.2.0

func DecodeError(info types.LicenseManagerLicenseInfo) error

DecodeError tries to find a specific error which occurs when an invalid key is passed to the server

func Provider

func Provider() terraform.ResourceProvider

Provider returns a terraform.ResourceProvider.

func UpdateLabel added in v0.2.0

func UpdateLabel(ctx context.Context, m *license.Manager, licenseKey string, key string, val string) error

UpdateLabel provides a wrapper around the UpdateLabel data objects

Types

type Config

type Config struct {
	InsecureFlag    bool
	Debug           bool
	Persist         bool
	User            string
	Password        string
	VSphereServer   string
	DebugPath       string
	DebugPathRun    string
	VimSessionPath  string
	RestSessionPath string
	KeepAlive       int
}

Config holds the provider configuration, and delivers a populated VSphereClient based off the contained settings.

func NewConfig added in v1.4.0

func NewConfig(d *schema.ResourceData) (*Config, error)

NewConfig returns a new Config from a supplied ResourceData.

func (*Config) Client

func (c *Config) Client() (*VSphereClient, error)

Client returns a new client for accessing VMWare vSphere.

func (*Config) EnableDebug

func (c *Config) EnableDebug() error

EnableDebug turns on govmomi API operation logging, if appropriate settings are set on the provider.

func (*Config) LoadAndVerifyRestSession added in v1.21.0

func (c *Config) LoadAndVerifyRestSession(client *govmomi.Client) (*rest.Client, bool, error)

func (*Config) LoadVimClient added in v1.4.0

func (c *Config) LoadVimClient() (*govmomi.Client, error)

LoadVimClient loads a saved vSphere SOAP API session from disk, previously saved by SaveVimClient, checking it for validity before returning it. A nil client means that the session is no longer valid and should be created from scratch.

Note the logic in this function has been largely adapted from govc and is designed to be compatible with it - if a session has already been saved with govc, Terraform will attempt to use that session first.

func (*Config) SaveRestClient added in v1.4.0

func (c *Config) SaveRestClient(client *rest.Client, s *cache.Session) error

func (*Config) SaveVimClient added in v1.4.0

func (c *Config) SaveVimClient(client *govmomi.Client) error

SaveVimClient saves a client to the supplied path. This facilitates re-use of the session at a later date.

Note the logic in this function has been largely adapted from govc and is designed to be compatible with it.

func (*Config) SavedRestSessionOrNew added in v1.4.0

func (c *Config) SavedRestSessionOrNew(s *cache.Session) (*rest.Client, error)

func (*Config) SavedVimSessionOrNew added in v1.4.0

func (c *Config) SavedVimSessionOrNew(u *url.URL) (*govmomi.Client, error)

SavedVimSessionOrNew either loads a saved SOAP session from disk, or creates a new one.

type HostAccessManager added in v1.21.0

type HostAccessManager struct {
	object.Common
}

func NewHostAccessManager added in v1.21.0

func NewHostAccessManager(c *vim25.Client, ref types.ManagedObjectReference) *HostAccessManager

func (HostAccessManager) ChangeLockdownMode added in v1.21.0

func (h HostAccessManager) ChangeLockdownMode(ctx context.Context, mode types.HostLockdownMode) error

type VSphereClient added in v0.4.0

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

VSphereClient is the client connection manager for the vSphere provider. It holds the connections to the various API endpoints we need to interface with, such as the VMODL API through govmomi, and the REST SDK through alternate libraries.

func (*VSphereClient) TagsManager added in v1.21.0

func (c *VSphereClient) TagsManager() (*tags.Manager, error)

TagsManager returns the embedded tags manager used for tags, after determining if the REST connection is eligible:

* The connection information in vimClient is valid vCenter connection * The provider has a connection to the CIS REST client. This is true if restClient != nil.

This function should be used whenever possible to return the client from the provider meta variable for use, to determine if it can be used at all.

The nil value that is returned on an unsupported connection can be considered stable behavior for read purposes on resources that need to be able to read tags if they are present. You can use the snippet below in a Read call to determine if tags are supported on this connection, and if they are, read them from the object and save them in the resource:

if tm, _ := meta.(*VSphereClient).TagsManager(); tm != nil {
  if err := readTagsForResource(restClient, obj, d); err != nil {
    return err
  }
}

Source Files

Jump to

Keyboard shortcuts

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