go.mod: bump images to v0.26.0

This is mainly needed in order to get the RHEL 9 SAP Azure images.
This commit is contained in:
Ondřej Budai 2023-12-21 19:47:16 +01:00 committed by Tom Gundersen
parent d5483ccfb0
commit 807f249146
232 changed files with 32705 additions and 3663 deletions

View file

@ -619,6 +619,18 @@ func init() {
types.Add("CnsSnapshotNotFoundFault", reflect.TypeOf((*CnsSnapshotNotFoundFault)(nil)).Elem())
}
type CnsSnapshotCreatedFault struct {
CnsFault
VolumeId CnsVolumeId `xml:"volumeId"`
SnapshotId CnsSnapshotId `xml:"snapshotId"`
Datastore types.ManagedObjectReference `xml:"datastore"`
}
func init() {
types.Add("CnsSnapshotCreatedFault", reflect.TypeOf((*CnsSnapshotCreatedFault)(nil)).Elem())
}
type CnsConfigureVolumeACLs CnsConfigureVolumeACLsRequestType
func init() {

View file

@ -21,5 +21,5 @@ const (
ClientName = "govmomi"
// ClientVersion is the version of this SDK
ClientVersion = "0.33.0"
ClientVersion = "0.34.1"
)

View file

@ -68,6 +68,31 @@ func NewDatastore(c *vim25.Client, ref types.ManagedObjectReference) *Datastore
}
}
// FindInventoryPath sets InventoryPath and DatacenterPath,
// needed by NewURL() to compose an upload/download endpoint URL
func (d *Datastore) FindInventoryPath(ctx context.Context) error {
entities, err := mo.Ancestors(ctx, d.c, d.c.ServiceContent.PropertyCollector, d.r)
if err != nil {
return err
}
val := "/"
for _, entity := range entities {
if entity.Parent == nil {
continue // root folder
}
val = path.Join(val, entity.Name)
if entity.Self.Type == "Datacenter" {
d.DatacenterPath = val
}
}
d.InventoryPath = val
return nil
}
func (d Datastore) Path(path string) string {
var p DatastorePath
if p.FromString(path) {
@ -101,11 +126,6 @@ func (d Datastore) NewURL(path string) *url.URL {
}
}
// URL is deprecated, use NewURL instead.
func (d Datastore) URL(ctx context.Context, dc *Datacenter, path string) (*url.URL, error) {
return d.NewURL(path), nil
}
func (d Datastore) Browser(ctx context.Context) (*HostDatastoreBrowser, error) {
var do mo.Datastore
@ -186,6 +206,10 @@ func (d Datastore) HostContext(ctx context.Context, host *HostSystem) context.Co
// 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.
func (d Datastore) ServiceTicket(ctx context.Context, path string, method string) (*url.URL, *http.Cookie, error) {
if d.InventoryPath == "" {
_ = d.FindInventoryPath(ctx)
}
u := d.NewURL(path)
host, ok := ctx.Value(datastoreServiceTicketHostKey{}).(*HostSystem)

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2018 VMware, Inc. All Rights Reserved.
Copyright (c) 2019-2023 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -34,6 +34,13 @@ type TransferEndpoint struct {
SSLCertificateThumbprint string `json:"ssl_certificate_thumbprint,omitempty"`
}
type ProbeResult struct {
Status string `json:"status"`
SSLThumbprint string `json:"ssl_thumbprint,omitempty"`
SSLCertificate string `json:"ssl_certificate,omitempty"`
ErrorMessages []rest.LocalizableMessage `json:"error_messages,omitempty"`
}
// UpdateFile is the specification for the updatesession
// operations file:add, file:get, and file:list.
type UpdateFile struct {
@ -48,6 +55,19 @@ type UpdateFile struct {
UploadEndpoint *TransferEndpoint `json:"upload_endpoint,omitempty"`
}
// FileValidationError contains the validation error of a file in the update session
type FileValidationError struct {
Name string `json:"name"`
ErrorMessage rest.LocalizableMessage `json:"error_message"`
}
// UpdateFileValidation contains the result of validating the files in the update session
type UpdateFileValidation struct {
HasErrors bool `json:"has_errors"`
MissingFiles []string `json:"missing_files,omitempty"`
InvalidFiles []FileValidationError `json:"invalid_files,omitempty"`
}
// AddLibraryItemFile adds a file
func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, updateFile UpdateFile) (*UpdateFile, error) {
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("add")
@ -66,29 +86,31 @@ func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, upda
}
// AddLibraryItemFileFromURI adds a file from a remote URI.
func (c *Manager) AddLibraryItemFileFromURI(
ctx context.Context,
sessionID, fileName, uri string) (*UpdateFile, error) {
n, fingerprint, err := c.getContentLengthAndFingerprint(ctx, uri)
if err != nil {
return nil, err
func (c *Manager) AddLibraryItemFileFromURI(ctx context.Context, sessionID, name, uri string) (*UpdateFile, error) {
source := &TransferEndpoint{
URI: uri,
}
info, err := c.AddLibraryItemFile(ctx, sessionID, UpdateFile{
Name: fileName,
SourceType: "PULL",
Size: n,
SourceEndpoint: &TransferEndpoint{
URI: uri,
SSLCertificateThumbprint: fingerprint,
},
})
if err != nil {
return nil, err
file := UpdateFile{
Name: name,
SourceType: "PULL",
SourceEndpoint: source,
}
return info, c.CompleteLibraryItemUpdateSession(ctx, sessionID)
if res, err := c.Head(uri); err == nil {
file.Size = res.ContentLength
if res.TLS != nil {
source.SSLCertificateThumbprint = soap.ThumbprintSHA1(res.TLS.PeerCertificates[0])
}
} else {
res, err := c.ProbeTransferEndpoint(ctx, *source)
if err != nil {
return nil, err
}
source.SSLCertificateThumbprint = res.SSLThumbprint
}
return c.AddLibraryItemFile(ctx, sessionID, file)
}
// GetLibraryItemUpdateSessionFile retrieves information about a specific file
@ -102,25 +124,36 @@ func (c *Manager) GetLibraryItemUpdateSessionFile(ctx context.Context, sessionID
return &res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
}
// getContentLengthAndFingerprint gets the number of bytes returned
// by the URI as well as the SHA1 fingerprint of the peer certificate
// if the URI's scheme is https.
func (c *Manager) getContentLengthAndFingerprint(
ctx context.Context, uri string) (int64, string, error) {
resp, err := c.Head(uri)
if err != nil {
return 0, "", err
}
if resp.TLS == nil || len(resp.TLS.PeerCertificates) == 0 {
return resp.ContentLength, "", nil
}
fingerprint := c.Thumbprint(resp.Request.URL.Host)
if fingerprint == "" {
if c.DefaultTransport().TLSClientConfig.InsecureSkipVerify {
fingerprint = soap.ThumbprintSHA1(resp.TLS.PeerCertificates[0])
}
}
return resp.ContentLength, fingerprint, nil
// ListLibraryItemUpdateSessionFile lists all files in the library item associated with the update session
func (c *Manager) ListLibraryItemUpdateSessionFile(ctx context.Context, sessionID string) ([]UpdateFile, error) {
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithParam("update_session_id", sessionID)
var res []UpdateFile
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
}
// ValidateLibraryItemUpdateSessionFile validates all files in the library item associated with the update session
func (c *Manager) ValidateLibraryItemUpdateSessionFile(ctx context.Context, sessionID string) (*UpdateFileValidation, error) {
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("validate")
var res UpdateFileValidation
return &res, c.Do(ctx, url.Request(http.MethodPost), &res)
}
// RemoveLibraryItemUpdateSessionFile requests a file to be removed. The file will only be effectively removed when the update session is completed.
func (c *Manager) RemoveLibraryItemUpdateSessionFile(ctx context.Context, sessionID string, fileName string) error {
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("remove")
spec := struct {
Name string `json:"file_name"`
}{fileName}
return c.Do(ctx, url.Request(http.MethodPost, spec), nil)
}
func (c *Manager) ProbeTransferEndpoint(ctx context.Context, endpoint TransferEndpoint) (*ProbeResult, error) {
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithAction("probe")
spec := struct {
SourceEndpoint TransferEndpoint `json:"source_endpoint"`
}{endpoint}
var res ProbeResult
return &res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
}
// ReadManifest converts an ovf manifest to a map of file name -> Checksum.

View file

@ -155,6 +155,14 @@ func (e *statusError) Error() string {
return fmt.Sprintf("%s %s: %s", e.res.Request.Method, e.res.Request.URL, e.res.Status)
}
func IsStatusError(err error, code int) bool {
statusErr, ok := err.(*statusError)
if !ok || statusErr == nil || statusErr.res == nil {
return false
}
return statusErr.res.StatusCode == code
}
// RawResponse may be used with the Do method as the resBody argument in order
// to capture the raw response data.
type RawResponse struct {