library

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 37

Documentation

Index

Examples

Constants

View Source
const (
	ItemTypeISO  = "iso"
	ItemTypeOVF  = "ovf"
	ItemTypeVMTX = "vm-template"
)
View Source
const (
	OvfDefaultSecurityPolicy = "OVF default policy"
)

Variables

This section is empty.

Functions

func ReadManifest

func ReadManifest(m io.Reader) (map[string]*Checksum, error)

ReadManifest converts an ovf manifest to a map of file name -> Checksum.

Types

type Checksum

type Checksum struct {
	Algorithm string `json:"algorithm,omitempty"`
	Checksum  string `json:"checksum"`
}

Checksum provides checksum information on library item files.

type ContentSecurityPoliciesInfo added in v0.30.0

type ContentSecurityPoliciesInfo struct {
	// ItemTypeRules are rules governing the policy.
	ItemTypeRules map[string]string `json:"item_type_rules"`
	// Name is a human-readable identifier identifying the policy.
	Name string `json:"name"`
	// Policy is the unique identifier for a policy.
	Policy string `json:"policy"`
}

ContentSecurityPoliciesInfo contains information on security policies that can be used to describe security for content library items.

type DownloadFile

type DownloadFile struct {
	BytesTransferred int64                    `json:"bytes_transferred"`
	Checksum         *Checksum                `json:"checksum_info,omitempty"`
	DownloadEndpoint *TransferEndpoint        `json:"download_endpoint,omitempty"`
	ErrorMessage     *rest.LocalizableMessage `json:"error_message,omitempty"`
	Name             string                   `json:"name"`
	Size             int64                    `json:"size,omitempty"`
	Status           string                   `json:"status"`
}

DownloadFile is the specification for the downloadsession operations file:add, file:get, and file:list.

type File

type File struct {
	Cached   *bool     `json:"cached,omitempty"`
	Checksum *Checksum `json:"checksum_info,omitempty"`
	Name     string    `json:"name,omitempty"`
	Size     *int64    `json:"size,omitempty"`
	Version  string    `json:"version,omitempty"`
}

File provides methods to get information on library item files.

type Find

type Find struct {
	Name string `json:"name,omitempty"`
	Type string `json:"type,omitempty"`
}

Find is the search criteria for finding libraries.

type FindItem

type FindItem struct {
	Cached    *bool  `json:"cached,omitempty"`
	LibraryID string `json:"library_id,omitempty"`
	Name      string `json:"name,omitempty"`
	SourceID  string `json:"source_id,omitempty"`
	Type      string `json:"type,omitempty"`
}

FindItem is the search criteria for finding library items.

type Item

type Item struct {
	Cached           bool       `json:"cached,omitempty"`
	ContentVersion   string     `json:"content_version,omitempty"`
	CreationTime     *time.Time `json:"creation_time,omitempty"`
	Description      *string    `json:"description,omitempty"`
	ID               string     `json:"id,omitempty"`
	LastModifiedTime *time.Time `json:"last_modified_time,omitempty"`
	LastSyncTime     *time.Time `json:"last_sync_time,omitempty"`
	LibraryID        string     `json:"library_id,omitempty"`
	MetadataVersion  string     `json:"metadata_version,omitempty"`
	Name             string     `json:"name,omitempty"`
	Size             int64      `json:"size,omitempty"`
	SourceID         string     `json:"source_id,omitempty"`
	Type             string     `json:"type,omitempty"`
	Version          string     `json:"version,omitempty"`

	SecurityCompliance      *bool                        `json:"security_compliance,omitempty"`
	CertificateVerification *ItemCertificateVerification `json:"certificate_verification_info,omitempty"`
}

Item provides methods to create, read, update, delete, and enumerate library items.

func (*Item) Patch

func (i *Item) Patch(src *Item)

Patch merges updates from the given src.

type ItemCertificateVerification added in v0.30.0

type ItemCertificateVerification struct {
	Status    string   `json:"status"`
	CertChain []string `json:"cert_chain,omitempty"`
}

ItemCertificateVerification contains the certificate verification status and item's signing certificate

type Library

type Library struct {
	CreationTime          *time.Time        `json:"creation_time,omitempty"`
	Description           *string           `json:"description,omitempty"`
	ID                    string            `json:"id,omitempty"`
	LastModifiedTime      *time.Time        `json:"last_modified_time,omitempty"`
	LastSyncTime          *time.Time        `json:"last_sync_time,omitempty"`
	Name                  string            `json:"name,omitempty"`
	Storage               []StorageBackings `json:"storage_backings,omitempty"`
	Type                  string            `json:"type,omitempty"`
	Version               string            `json:"version,omitempty"`
	Subscription          *Subscription     `json:"subscription_info,omitempty"`
	Publication           *Publication      `json:"publish_info,omitempty"`
	SecurityPolicyID      string            `json:"security_policy_id,omitempty"`
	UnsetSecurityPolicyID bool              `json:"unset_security_policy_id,omitempty"`
}

Library provides methods to create, read, update, delete, and enumerate libraries.

func (*Library) Patch

func (l *Library) Patch(src *Library)

Patch merges updates from the given src.

type Manager

type Manager struct {
	*rest.Client
}

Manager extends rest.Client, adding content library related methods.

func NewManager

func NewManager(client *rest.Client) *Manager

NewManager creates a new Manager instance with the given client.

func (*Manager) AddLibraryItemFile

func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, updateFile UpdateFile) (*UpdateFile, error)

AddLibraryItemFile adds a file

func (*Manager) AddLibraryItemFileFromURI

func (c *Manager) AddLibraryItemFileFromURI(
	ctx context.Context,
	sessionID, fileName, uri string) (*UpdateFile, error)

AddLibraryItemFileFromURI adds a file from a remote URI.

func (*Manager) CancelLibraryItemDownloadSession

func (c *Manager) CancelLibraryItemDownloadSession(ctx context.Context, id string) error

CancelLibraryItemDownloadSession cancels an download session

func (*Manager) CancelLibraryItemUpdateSession

func (c *Manager) CancelLibraryItemUpdateSession(ctx context.Context, id string) error

CancelLibraryItemUpdateSession cancels an update session

func (*Manager) CompleteLibraryItemUpdateSession

func (c *Manager) CompleteLibraryItemUpdateSession(ctx context.Context, id string) error

CompleteLibraryItemUpdateSession completes an update session

func (*Manager) CopyLibraryItem added in v0.23.0

func (c *Manager) CopyLibraryItem(ctx context.Context, src *Item, dst Item) (string, error)

CopyLibraryItem copies a library item

func (*Manager) CreateLibrary

func (c *Manager) CreateLibrary(ctx context.Context, library Library) (string, error)

CreateLibrary creates a new library with the given Type, Name, Description, and CategoryID.

Example
package main

import (
	"context"
	"fmt"

	"github.com/vmware/govmomi/find"
	"github.com/vmware/govmomi/simulator"
	"github.com/vmware/govmomi/vapi/library"
	"github.com/vmware/govmomi/vapi/rest"
	"github.com/vmware/govmomi/vim25"

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

func main() {
	simulator.Run(func(ctx context.Context, vc *vim25.Client) error {
		c := rest.NewClient(vc)

		err := c.Login(ctx, simulator.DefaultLogin)
		if err != nil {
			return err
		}

		ds, err := find.NewFinder(vc).DefaultDatastore(ctx)
		if err != nil {
			return err
		}

		m := library.NewManager(c)

		id, err := m.CreateLibrary(ctx, library.Library{
			Name: "example",
			Type: "LOCAL",
			Storage: []library.StorageBackings{{
				DatastoreID: ds.Reference().Value,
				Type:        "DATASTORE",
			}},
		})
		if err != nil {
			return err
		}

		l, err := m.GetLibraryByID(ctx, id)
		if err != nil {
			return err
		}

		fmt.Println("created library", l.Name)
		return nil
	})
}
Output:

created library example

func (*Manager) CreateLibraryItem

func (c *Manager) CreateLibraryItem(ctx context.Context, item Item) (string, error)

CreateLibraryItem creates a new library item

func (*Manager) CreateLibraryItemDownloadSession

func (c *Manager) CreateLibraryItemDownloadSession(ctx context.Context, session Session) (string, error)

CreateLibraryItemDownloadSession creates a new library item

func (*Manager) CreateLibraryItemUpdateSession

func (c *Manager) CreateLibraryItemUpdateSession(ctx context.Context, session Session) (string, error)

CreateLibraryItemUpdateSession creates a new library item

func (*Manager) CreateSubscriber added in v0.23.0

func (c *Manager) CreateSubscriber(ctx context.Context, library *Library, s SubscriberLibrary) (string, error)

CreateSubscriber creates a subscription of the published library.

func (*Manager) CreateTrustedCertificate added in v0.30.0

func (c *Manager) CreateTrustedCertificate(ctx context.Context, cert string) error

CreateTrustedCertificate adds a certificate to content library trust store

func (*Manager) DefaultOvfSecurityPolicy added in v0.30.0

func (c *Manager) DefaultOvfSecurityPolicy(ctx context.Context) (string, error)

func (*Manager) DeleteLibrary

func (c *Manager) DeleteLibrary(ctx context.Context, library *Library) error

DeleteLibrary deletes an existing library.

func (*Manager) DeleteLibraryItem

func (c *Manager) DeleteLibraryItem(ctx context.Context, item *Item) error

DeleteLibraryItem deletes an existing library item.

func (*Manager) DeleteLibraryItemDownloadSession

func (c *Manager) DeleteLibraryItemDownloadSession(ctx context.Context, id string) error

DeleteLibraryItemDownloadSession deletes an download session

func (*Manager) DeleteLibraryItemUpdateSession

func (c *Manager) DeleteLibraryItemUpdateSession(ctx context.Context, id string) error

DeleteLibraryItemUpdateSession deletes an update session

func (*Manager) DeleteSubscriber added in v0.23.0

func (c *Manager) DeleteSubscriber(ctx context.Context, library *Library, subscriber string) error

DeleteSubscriber deletes the specified subscription of the published library. The subscribed library associated with the subscription will not be deleted.

func (*Manager) DeleteTrustedCertificate added in v0.30.0

func (c *Manager) DeleteTrustedCertificate(ctx context.Context, id string) error

DeleteTrustedCertificate deletes the trusted certificate from content library's trust store for the given id

func (*Manager) FailLibraryItemDownloadSession

func (c *Manager) FailLibraryItemDownloadSession(ctx context.Context, id string) error

FailLibraryItemDownloadSession fails an download session

func (*Manager) FailLibraryItemUpdateSession

func (c *Manager) FailLibraryItemUpdateSession(ctx context.Context, id string) error

FailLibraryItemUpdateSession fails an update session

func (*Manager) FindLibrary

func (c *Manager) FindLibrary(ctx context.Context, search Find) ([]string, error)

FindLibrary returns one or more libraries that match the provided search criteria.

The provided name is case-insensitive.

Either the name or type of library may be set to empty values in order to search for all libraries, all libraries with a specific name, regardless of type, or all libraries of a specified type.

func (*Manager) FindLibraryItems

func (c *Manager) FindLibraryItems(
	ctx context.Context, search FindItem) ([]string, error)

FindLibraryItems returns the IDs of all the library items that match the search criteria.

func (*Manager) GetLibraries

func (c *Manager) GetLibraries(ctx context.Context) ([]Library, error)

GetLibraries returns a list of all content library details in the system.

func (*Manager) GetLibraryByID

func (c *Manager) GetLibraryByID(ctx context.Context, id string) (*Library, error)

GetLibraryByID returns information on a library for the given ID.

func (*Manager) GetLibraryByName

func (c *Manager) GetLibraryByName(ctx context.Context, name string) (*Library, error)

GetLibraryByName returns information on a library for the given name.

func (*Manager) GetLibraryItem

func (c *Manager) GetLibraryItem(ctx context.Context, id string) (*Item, error)

GetLibraryItem returns information on a library item for the given ID.

func (*Manager) GetLibraryItemDownloadSession

func (c *Manager) GetLibraryItemDownloadSession(ctx context.Context, id string) (*Session, error)

GetLibraryItemDownloadSession gets the download session information with status

func (*Manager) GetLibraryItemDownloadSessionFile

func (c *Manager) GetLibraryItemDownloadSessionFile(ctx context.Context, sessionID string, name string) (*DownloadFile, error)

GetLibraryItemDownloadSessionFile retrieves information about a specific file that is a part of an download session.

func (*Manager) GetLibraryItemFile

func (c *Manager) GetLibraryItemFile(ctx context.Context, id, fileName string) (*File, error)

GetLibraryItemFile returns a file with the provided name for a library item.

func (*Manager) GetLibraryItemUpdateSession

func (c *Manager) GetLibraryItemUpdateSession(ctx context.Context, id string) (*Session, error)

GetLibraryItemUpdateSession gets the update session information with status

func (*Manager) GetLibraryItemUpdateSessionFile

func (c *Manager) GetLibraryItemUpdateSessionFile(ctx context.Context, sessionID string, fileName string) (*UpdateFile, error)

GetLibraryItemUpdateSessionFile retrieves information about a specific file that is a part of an update session.

func (*Manager) GetLibraryItems

func (c *Manager) GetLibraryItems(ctx context.Context, libraryID string) ([]Item, error)

GetLibraryItems returns a list of all the library items for the specified library.

func (*Manager) GetSubscriber added in v0.23.0

func (c *Manager) GetSubscriber(ctx context.Context, library *Library, subscriber string) (*Subscriber, error)

GetSubscriber returns information about the specified subscriber of the published library.

func (*Manager) GetTrustedCertificate added in v0.30.0

func (c *Manager) GetTrustedCertificate(ctx context.Context, id string) (*TrustedCertificate, error)

GetTrustedCertificate retrieves a trusted certificate for a given certificate id

func (*Manager) KeepAliveLibraryItemDownloadSession

func (c *Manager) KeepAliveLibraryItemDownloadSession(ctx context.Context, id string) error

KeepAliveLibraryItemDownloadSession keeps an inactive download session alive.

func (*Manager) KeepAliveLibraryItemUpdateSession

func (c *Manager) KeepAliveLibraryItemUpdateSession(ctx context.Context, id string) error

KeepAliveLibraryItemUpdateSession keeps an inactive update session alive.

func (*Manager) ListLibraries

func (c *Manager) ListLibraries(ctx context.Context) ([]string, error)

ListLibraries returns a list of all content library IDs in the system.

func (*Manager) ListLibraryItemDownloadSession

func (c *Manager) ListLibraryItemDownloadSession(ctx context.Context) ([]string, error)

ListLibraryItemDownloadSession gets the list of download sessions

func (*Manager) ListLibraryItemDownloadSessionFile

func (c *Manager) ListLibraryItemDownloadSessionFile(ctx context.Context, sessionID string) ([]DownloadFile, error)

ListLibraryItemDownloadSessionFile retrieves information about a specific file that is a part of an download session.

func (*Manager) ListLibraryItemFiles

func (c *Manager) ListLibraryItemFiles(ctx context.Context, id string) ([]File, error)

ListLibraryItemFiles returns a list of all the files for a library item.

func (*Manager) ListLibraryItemUpdateSession

func (c *Manager) ListLibraryItemUpdateSession(ctx context.Context) ([]string, error)

ListLibraryItemUpdateSession gets the list of update sessions

func (*Manager) ListLibraryItems

func (c *Manager) ListLibraryItems(ctx context.Context, id string) ([]string, error)

ListLibraryItems returns a list of all items in a content library.

func (*Manager) ListSecurityPolicies added in v0.30.0

func (c *Manager) ListSecurityPolicies(ctx context.Context) ([]ContentSecurityPoliciesInfo, error)

ListSecurityPolicies lists security policies

func (*Manager) ListSubscribers added in v0.23.0

func (c *Manager) ListSubscribers(ctx context.Context, library *Library) ([]SubscriberSummary, error)

ListSubscribers lists the subscriptions of the published library.

func (*Manager) ListTrustedCertificates added in v0.30.0

func (c *Manager) ListTrustedCertificates(ctx context.Context) ([]TrustedCertificateSummary, error)

ListTrustedCertificates retrieves all content library's trusted certificates

func (*Manager) PrepareLibraryItemDownloadSessionFile

func (c *Manager) PrepareLibraryItemDownloadSessionFile(ctx context.Context, sessionID string, name string) (*DownloadFile, error)

PrepareLibraryItemDownloadSessionFile retrieves information about a specific file that is a part of an download session.

func (*Manager) PublishLibrary added in v0.23.0

func (c *Manager) PublishLibrary(ctx context.Context, library *Library, subscriptions []string) error

PublishLibrary publishes the library to specified subscriptions. If no subscriptions are specified, then publishes the library to all subscriptions.

func (*Manager) PublishLibraryItem added in v0.23.0

func (c *Manager) PublishLibraryItem(ctx context.Context, item *Item, force bool, subscriptions []string) error

PublishLibraryItem publishes a library item to specified subscriptions. If no subscriptions are specified, then publishes the library item to all subscriptions.

func (*Manager) SyncLibrary added in v0.22.0

func (c *Manager) SyncLibrary(ctx context.Context, library *Library) error

SyncLibrary syncs a subscribed library.

func (*Manager) SyncLibraryItem added in v0.22.0

func (c *Manager) SyncLibraryItem(ctx context.Context, item *Item, force bool) error

SyncLibraryItem syncs a subscribed library item

func (*Manager) UpdateLibrary added in v0.25.0

func (c *Manager) UpdateLibrary(ctx context.Context, l *Library) error

UpdateLibrary can update one or both of the tag Description and Name fields.

func (*Manager) UpdateLibraryItem added in v0.26.1

func (c *Manager) UpdateLibraryItem(ctx context.Context, item *Item) error

UpdateLibraryItem can update one or both of the item Description and Name fields.

func (*Manager) WaitOnLibraryItemUpdateSession

func (c *Manager) WaitOnLibraryItemUpdateSession(
	ctx context.Context, sessionID string,
	interval time.Duration, intervalCallback func()) error

WaitOnLibraryItemUpdateSession blocks until the update session is no longer in the ACTIVE state.

type Placement added in v0.23.0

type Placement struct {
	ResourcePool string `json:"resource_pool,omitempty"`
	Host         string `json:"host,omitempty"`
	Folder       string `json:"folder,omitempty"`
	Cluster      string `json:"cluster,omitempty"`
	Network      string `json:"network,omitempty"`
}

Placement information used to place a virtual machine template

type Publication added in v0.23.0

type Publication struct {
	AuthenticationMethod string `json:"authentication_method"`
	UserName             string `json:"user_name,omitempty"`
	Password             string `json:"password,omitempty"`
	CurrentPassword      string `json:"current_password,omitempty"`
	PersistJSON          *bool  `json:"persist_json_enabled,omitempty"`
	Published            *bool  `json:"published,omitempty"`
	PublishURL           string `json:"publish_url,omitempty"`
}

Publication info

type Session

type Session struct {
	ClientProgress            int64                    `json:"client_progress,omitempty"`
	ErrorMessage              *rest.LocalizableMessage `json:"error_message,omitempty"`
	ExpirationTime            *time.Time               `json:"expiration_time,omitempty"`
	ID                        string                   `json:"id,omitempty"`
	LibraryItemContentVersion string                   `json:"library_item_content_version,omitempty"`
	LibraryItemID             string                   `json:"library_item_id,omitempty"`
	State                     string                   `json:"state,omitempty"`
}

Session is used to create an initial update or download session

type StorageBackings

type StorageBackings struct {
	DatastoreID string `json:"datastore_id,omitempty"`
	Type        string `json:"type,omitempty"`
}

StorageBackings for Content Libraries

type Subscriber added in v0.23.0

type Subscriber struct {
	LibraryID       string     `json:"subscribed_library"`
	LibraryName     string     `json:"subscribed_library_name"`
	LibraryLocation string     `json:"subscribed_library_location"`
	Placement       *Placement `json:"subscribed_library_placement,omitempty"`
	Vcenter         *Vcenter   `json:"subscribed_library_vcenter,omitempty"`
}

Subscriber contains the detailed info for a library subscriber.

type SubscriberLibrary added in v0.23.0

type SubscriberLibrary struct {
	Target    string     `json:"target"`
	LibraryID string     `json:"subscribed_library,omitempty"`
	Location  string     `json:"location"`
	Vcenter   *Vcenter   `json:"vcenter,omitempty"`
	Placement *Placement `json:"placement,omitempty"`
}

SubscriberLibrary is the specification for a subscribed library to be associated with a subscription.

type SubscriberSummary added in v0.23.0

type SubscriberSummary struct {
	LibraryID              string `json:"subscribed_library"`
	LibraryName            string `json:"subscribed_library_name"`
	SubscriptionID         string `json:"subscription"`
	LibraryVcenterHostname string `json:"subscribed_library_vcenter_hostname,omitempty"`
}

SubscriberSummary as returned by ListSubscribers

type Subscription added in v0.22.0

type Subscription struct {
	AuthenticationMethod string `json:"authentication_method"`
	AutomaticSyncEnabled *bool  `json:"automatic_sync_enabled,omitempty"`
	OnDemand             *bool  `json:"on_demand,omitempty"`
	Password             string `json:"password,omitempty"`
	SslThumbprint        string `json:"ssl_thumbprint,omitempty"`
	SubscriptionURL      string `json:"subscription_url,omitempty"`
	UserName             string `json:"user_name,omitempty"`
}

Subscription info

type TransferEndpoint

type TransferEndpoint struct {
	URI                      string `json:"uri,omitempty"`
	SSLCertificateThumbprint string `json:"ssl_certificate_thumbprint,omitempty"`
}

TransferEndpoint provides information on the source of a library item file.

type TrustedCertificate added in v0.30.0

type TrustedCertificate struct {
	Text string `json:"cert_text"`
}

TrustedCertificate contains a trusted certificate in Base64 encoded PEM format

type TrustedCertificateSummary added in v0.30.0

type TrustedCertificateSummary struct {
	TrustedCertificate
	ID string `json:"certificate"`
}

TrustedCertificateSummary contains a trusted certificate in Base64 encoded PEM format and its id

type UpdateFile

type UpdateFile struct {
	BytesTransferred int64                    `json:"bytes_transferred,omitempty"`
	Checksum         *Checksum                `json:"checksum_info,omitempty"`
	ErrorMessage     *rest.LocalizableMessage `json:"error_message,omitempty"`
	Name             string                   `json:"name"`
	Size             int64                    `json:"size,omitempty"`
	SourceEndpoint   *TransferEndpoint        `json:"source_endpoint,omitempty"`
	SourceType       string                   `json:"source_type"`
	Status           string                   `json:"status,omitempty"`
	UploadEndpoint   *TransferEndpoint        `json:"upload_endpoint,omitempty"`
}

UpdateFile is the specification for the updatesession operations file:add, file:get, and file:list.

type Vcenter added in v0.23.0

type Vcenter struct {
	Hostname   string `json:"hostname"`
	Port       int    `json:"https_port,omitempty"`
	ServerGUID string `json:"server_guid"`
}

Vcenter contains information about the vCenter Server instance where a subscribed library associated with a subscription exists.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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