go.mod: update osbuild/images to v0.69.0

This commit is contained in:
Achilleas Koutsou 2024-07-02 14:42:15 +02:00
parent 1cc90c6a0b
commit 8ac80e8abc
611 changed files with 28281 additions and 32629 deletions

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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,
@ -20,9 +20,12 @@ import (
"context"
"flag"
"fmt"
"net/url"
"os"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vapi/library"
"github.com/vmware/govmomi/vapi/library/finder"
"github.com/vmware/govmomi/vim25/types"
)
@ -148,3 +151,59 @@ func (f *DatastoreFlag) Stat(ctx context.Context, file string) (types.BaseFileIn
return ds.Stat(ctx, file)
}
func (f *DatastoreFlag) libraryPath(ctx context.Context, p string) (string, error) {
vc, err := f.Client()
if err != nil {
return "", err
}
rc, err := f.RestClient()
if err != nil {
return "", err
}
m := library.NewManager(rc)
r, err := finder.NewFinder(m).Find(ctx, p)
if err != nil {
return "", err
}
if len(r) != 1 {
return "", fmt.Errorf("%s: %d found", p, len(r))
}
return finder.NewPathFinder(m, vc).Path(ctx, r[0])
}
// FileBacking converts the given file path for use as VirtualDeviceFileBackingInfo.FileName.
func (f *DatastoreFlag) FileBacking(ctx context.Context, file string, stat bool) (string, error) {
u, err := url.Parse(file)
if err != nil {
return "", err
}
switch u.Scheme {
case "library":
return f.libraryPath(ctx, u.Path)
case "ds":
// datastore url, e.g. ds:///vmfs/volumes/$uuid/...
return file, nil
}
var p object.DatastorePath
if p.FromString(file) {
// datastore is specified
return file, nil
}
if stat {
// Verify ISO exists
if _, err := f.Stat(ctx, file); err != nil {
return "", err
}
}
return f.DatastorePath(file)
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2024 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.
@ -31,28 +31,11 @@ import (
)
var (
allDiskProvisioningOptions = []string{
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeFlat),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeMonolithicSparse),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeMonolithicFlat),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeTwoGbMaxExtentSparse),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeTwoGbMaxExtentFlat),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeThin),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeThick),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeSeSparse),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeEagerZeroedThick),
string(types.OvfCreateImportSpecParamsDiskProvisioningTypeSparse),
}
allIPAllocationPolicyOptions = []string{
string(types.VAppIPAssignmentInfoIpAllocationPolicyDhcpPolicy),
string(types.VAppIPAssignmentInfoIpAllocationPolicyTransientPolicy),
string(types.VAppIPAssignmentInfoIpAllocationPolicyFixedPolicy),
string(types.VAppIPAssignmentInfoIpAllocationPolicyFixedAllocatedPolicy),
}
allIPProtocolOptions = []string{
string(types.VAppIPAssignmentInfoProtocolsIPv4),
string(types.VAppIPAssignmentInfoProtocolsIPv6),
}
allDiskProvisioningOptions = types.OvfCreateImportSpecParamsDiskProvisioningType("").Strings()
allIPAllocationPolicyOptions = types.VAppIPAssignmentInfoIpAllocationPolicy("").Strings()
allIPProtocolOptions = types.VAppIPAssignmentInfoProtocols("").Strings()
)
type spec struct {

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2015-2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2024 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,
@ -84,11 +84,7 @@ func init() {
cli.Register("vm.change", &change{})
}
var latencyLevels = []string{
string(types.LatencySensitivitySensitivityLevelLow),
string(types.LatencySensitivitySensitivityLevelNormal),
string(types.LatencySensitivitySensitivityLevelHigh),
}
var latencyLevels = types.LatencySensitivitySensitivityLevel("").Strings()
// setLatency validates latency level if set
func (cmd *change) setLatency() error {
@ -106,11 +102,7 @@ func (cmd *change) setLatency() error {
return fmt.Errorf("latency must be one of: %s", strings.Join(latencyLevels, "|"))
}
var hwUpgradePolicies = []string{
string(types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicyOnSoftPowerOff),
string(types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicyNever),
string(types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicyAlways),
}
var hwUpgradePolicies = types.ScheduledHardwareUpgradeInfoHardwareUpgradePolicy("").Strings()
// setHwUpgradePolicy validates hwUpgradePolicy if set
func (cmd *change) setHwUpgradePolicy() error {

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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,
@ -20,8 +20,11 @@ import (
"context"
"flag"
"fmt"
"io"
"strings"
"text/tabwriter"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/object"
@ -33,10 +36,8 @@ import (
)
var (
FirmwareTypes = []string{
string(types.GuestOsDescriptorFirmwareTypeBios),
string(types.GuestOsDescriptorFirmwareTypeEfi),
}
FirmwareTypes = types.GuestOsDescriptorFirmwareType("").Strings()
FirmwareUsage = fmt.Sprintf("Firmware type [%s]", strings.Join(FirmwareTypes, "|"))
)
@ -62,10 +63,11 @@ type create struct {
annotation string
firmware string
version string
place bool
profile string
iso string
isoDatastoreFlag *flags.DatastoreFlag
isoDatastore *object.Datastore
disk string
diskDatastoreFlag *flags.DatastoreFlag
@ -125,8 +127,11 @@ func (cmd *create) Register(ctx context.Context, f *flag.FlagSet) {
f.BoolVar(&cmd.force, "force", false, "Create VM if vmx already exists")
f.StringVar(&cmd.controller, "disk.controller", "scsi", "Disk controller type")
f.StringVar(&cmd.annotation, "annotation", "", "VM description")
f.StringVar(&cmd.firmware, "firmware", FirmwareTypes[0], FirmwareUsage)
f.StringVar(&cmd.profile, "profile", "", "Storage profile name or ID")
if cli.ShowUnreleased() {
f.BoolVar(&cmd.place, "place", false, "Place VM without creating")
}
esxiVersions := types.GetESXiVersions()
esxiVersionStrings := make([]string, len(esxiVersions))
@ -197,6 +202,7 @@ https://code.vmware.com/apis/358/vsphere/doc/vim.vm.GuestOsDescriptor.GuestOsIde
Examples:
govc vm.create -on=false vm-name
govc vm.create -iso library:/boot/linux/ubuntu.iso vm-name # Content Library ISO
govc vm.create -cluster cluster1 vm-name # use compute cluster placement
govc vm.create -datastore-cluster dscluster vm-name # use datastore cluster placement
govc vm.create -m 2048 -c 2 -g freebsd64Guest -net.adapter vmxnet3 -disk.controller pvscsi vm-name`
@ -269,15 +275,11 @@ func (cmd *create) Run(ctx context.Context, f *flag.FlagSet) error {
// Verify ISO exists
if cmd.iso != "" {
_, err = cmd.isoDatastoreFlag.Stat(ctx, cmd.iso)
if err != nil {
return err
}
cmd.isoDatastore, err = cmd.isoDatastoreFlag.Datastore()
iso, err := cmd.isoDatastoreFlag.FileBacking(ctx, cmd.iso, true)
if err != nil {
return err
}
cmd.iso = iso
}
// Verify disk exists
@ -305,7 +307,9 @@ func (cmd *create) Run(ctx context.Context, f *flag.FlagSet) error {
if err != nil {
return err
}
if cmd.place {
return nil
}
info, err := task.WaitForResult(ctx, nil)
if err != nil {
return err
@ -328,6 +332,61 @@ func (cmd *create) Run(ctx context.Context, f *flag.FlagSet) error {
return nil
}
type place struct {
Spec types.PlacementSpec `json:"spec"`
Recommendations []types.ClusterRecommendation `json:"recommendations"`
ctx context.Context
cmd *create
}
func (p *place) Dump() interface{} {
return p.Recommendations
}
func (p *place) action(w io.Writer, r types.ClusterRecommendation, a *types.PlacementAction) error {
spec := a.RelocateSpec
if spec == nil {
return nil
}
fields := []struct {
name string
moid *types.ManagedObjectReference
}{
{"Target", r.Target},
{" Folder", spec.Folder},
{" Datastore", spec.Datastore},
{" Pool", spec.Pool},
{" Host", spec.Host},
}
for _, f := range fields {
if f.moid == nil {
continue
}
path, err := find.InventoryPath(p.ctx, p.cmd.Client, *f.moid)
if err != nil {
return err
}
fmt.Fprintf(w, "%s:\t%s\n", f.name, path)
}
return nil
}
func (p *place) Write(w io.Writer) error {
tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)
for _, r := range p.Recommendations {
for _, a := range r.Action {
p.action(tw, r, a.(*types.PlacementAction))
}
}
return tw.Flush()
}
func (cmd *create) createVM(ctx context.Context) (*object.Task, error) {
var devices object.VirtualDeviceList
var err error
@ -352,6 +411,24 @@ func (cmd *create) createVM(ctx context.Context) (*object.Task, error) {
Version: cmd.version,
}
if cmd.profile != "" {
c, err := cmd.PbmClient()
if err != nil {
return nil, err
}
m, err := c.ProfileMap(ctx)
if err != nil {
return nil, err
}
p, ok := m.Name[cmd.profile]
if !ok {
return nil, fmt.Errorf("profile %q not found", cmd.profile)
}
spec.VmProfile = []types.BaseVirtualMachineProfileSpec{&types.VirtualMachineDefinedProfileSpec{
ProfileId: p.GetPbmProfile().ProfileId.UniqueId,
}}
}
devices, err = cmd.addStorage(nil)
if err != nil {
return nil, err
@ -390,6 +467,9 @@ func (cmd *create) createVM(ctx context.Context) (*object.Task, error) {
}
recs := result.Recommendations
if cmd.place {
return nil, cmd.WriteResult(&place{pspec, recs, ctx, cmd})
}
if len(recs) == 0 {
return nil, fmt.Errorf("no cluster recommendations")
}
@ -507,7 +587,7 @@ func (cmd *create) addStorage(devices object.VirtualDeviceList) (object.VirtualD
return nil, err
}
cdrom = devices.InsertIso(cdrom, cmd.isoDatastore.Path(cmd.iso))
cdrom = devices.InsertIso(cdrom, cmd.iso)
devices = append(devices, cdrom)
}

View file

@ -45,6 +45,8 @@ type customize struct {
dnsserver flags.StringList
dnssuffix flags.StringList
kind string
username string
org string
}
func init() {
@ -75,6 +77,8 @@ func (cmd *customize) Register(ctx context.Context, f *flag.FlagSet) {
f.Var(&cmd.dnssuffix, "dns-suffix", "DNS suffix list")
cmd.dnssuffix = nil
f.StringVar(&cmd.kind, "type", "Linux", "Customization type if spec NAME is not specified (Linux|Windows)")
f.StringVar(&cmd.username, "username", "", "Windows only : full name of the end user in firstname lastname format")
f.StringVar(&cmd.org, "org", "", "Windows only : name of the org that owns the VM")
}
func (cmd *customize) Usage() string {
@ -211,12 +215,12 @@ func (cmd *customize) Run(ctx context.Context, f *flag.FlagSet) error {
sysprep, isWindows := spec.Identity.(*types.CustomizationSysprep)
linprep, _ := spec.Identity.(*types.CustomizationLinuxPrep)
if cmd.domain != "" {
if isWindows {
sysprep.Identification.JoinDomain = cmd.domain
} else {
linprep.Domain = cmd.domain
}
if isWindows {
sysprep.Identification.JoinDomain = cmd.domain
sysprep.UserData.FullName = cmd.username
sysprep.UserData.OrgName = cmd.org
} else {
linprep.Domain = cmd.domain
}
if len(cmd.dnsserver) != 0 {

View file

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

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2016-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2016-2024 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.
@ -21,6 +21,8 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/pem"
"errors"
"fmt"
"io"
"net/url"
@ -66,6 +68,18 @@ func (info *HostCertificateInfo) FromCertificate(cert *x509.Certificate) *HostCe
return info
}
func (info *HostCertificateInfo) FromPEM(cert []byte) (*HostCertificateInfo, error) {
block, _ := pem.Decode(cert)
if block == nil {
return nil, errors.New("failed to pem.Decode cert")
}
x, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, err
}
return info.FromCertificate(x), nil
}
// FromURL connects to the given URL.Host via tls.Dial with the given tls.Config and populates the HostCertificateInfo
// via tls.ConnectionState. If the certificate was verified with the given tls.Config, the Err field will be nil.
// Otherwise, Err will be set to the x509.UnknownAuthorityError or x509.HostnameError.

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
Copyright (c) 2016-2024 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,
@ -23,6 +23,7 @@ import (
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
@ -117,7 +118,13 @@ func (m HostCertificateManager) InstallServerCertificate(ctx context.Context, ce
Req: &types.Refresh{This: m.Reference()},
}
return m.Client().RoundTrip(ctx, &body, &body)
err = m.Client().RoundTrip(ctx, &body, &body)
if err != nil && soap.IsSoapFault(err) {
if _, ok := soap.ToSoapFault(err).VimFault().(types.MethodNotFound); ok {
return nil
}
}
return err
}
// ListCACertificateRevocationLists returns the SSL CRLs of Certificate Authorities that are trusted by the host system.

View file

@ -0,0 +1,206 @@
/*
Copyright (c) 2024-2024 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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package object
import (
"fmt"
"reflect"
"github.com/vmware/govmomi/vim25/types"
)
// OptionValueList simplifies manipulation of properties that are arrays of
// types.BaseOptionValue, such as ExtraConfig.
type OptionValueList []types.BaseOptionValue
// OptionValueListFromMap returns a new OptionValueList object from the provided
// map.
func OptionValueListFromMap[T any](in map[string]T) OptionValueList {
if len(in) == 0 {
return nil
}
var (
i int
out = make(OptionValueList, len(in))
)
for k, v := range in {
out[i] = &types.OptionValue{Key: k, Value: v}
i++
}
return out
}
// Get returns the value if exists, otherwise nil is returned. The second return
// value is a flag indicating whether the value exists or nil was the actual
// value.
func (ov OptionValueList) Get(key string) (any, bool) {
if ov == nil {
return nil, false
}
for i := range ov {
if optVal := ov[i].GetOptionValue(); optVal != nil {
if optVal.Key == key {
return optVal.Value, true
}
}
}
return nil, false
}
// GetString returns the value as a string if the value exists.
func (ov OptionValueList) GetString(key string) (string, bool) {
if ov == nil {
return "", false
}
for i := range ov {
if optVal := ov[i].GetOptionValue(); optVal != nil {
if optVal.Key == key {
return getOptionValueAsString(optVal.Value), true
}
}
}
return "", false
}
// Additions returns a diff that includes only the elements from the provided
// list that do not already exist.
func (ov OptionValueList) Additions(in ...types.BaseOptionValue) OptionValueList {
return ov.diff(in, true)
}
// Diff returns a diff that includes the elements from the provided list that do
// not already exist or have different values.
func (ov OptionValueList) Diff(in ...types.BaseOptionValue) OptionValueList {
return ov.diff(in, false)
}
func (ov OptionValueList) diff(in OptionValueList, addOnly bool) OptionValueList {
if ov == nil && in == nil {
return nil
}
var (
out OptionValueList
leftOptVals = ov.Map()
)
for i := range in {
if rightOptVal := in[i].GetOptionValue(); rightOptVal != nil {
k, v := rightOptVal.Key, rightOptVal.Value
if ov == nil {
out = append(out, &types.OptionValue{Key: k, Value: v})
} else if leftOptVal, ok := leftOptVals[k]; !ok {
out = append(out, &types.OptionValue{Key: k, Value: v})
} else if !addOnly && v != leftOptVal {
out = append(out, &types.OptionValue{Key: k, Value: v})
}
}
}
if len(out) == 0 {
return nil
}
return out
}
// Join combines this list with the provided one and returns the result, joining
// the two lists on their shared keys.
// Please note, Join(left, right) means the values from right will be appended
// to left, without overwriting any values that have shared keys. To overwrite
// the shared keys in left from right, use Join(right, left) instead.
func (ov OptionValueList) Join(in ...types.BaseOptionValue) OptionValueList {
var (
out OptionValueList
outKeys map[string]struct{}
)
// Init the out slice from the left side.
if len(ov) > 0 {
outKeys = map[string]struct{}{}
for i := range ov {
if optVal := ov[i].GetOptionValue(); optVal != nil {
kv := &types.OptionValue{Key: optVal.Key, Value: optVal.Value}
out = append(out, kv)
outKeys[optVal.Key] = struct{}{}
}
}
}
// Join the values from the right side.
for i := range in {
if rightOptVal := in[i].GetOptionValue(); rightOptVal != nil {
k, v := rightOptVal.Key, rightOptVal.Value
if _, ok := outKeys[k]; !ok {
out = append(out, &types.OptionValue{Key: k, Value: v})
}
}
}
if len(out) == 0 {
return nil
}
return out
}
// Map returns the list of option values as a map. A nil value is returned if
// the list is empty.
func (ov OptionValueList) Map() map[string]any {
if len(ov) == 0 {
return nil
}
out := map[string]any{}
for i := range ov {
if optVal := ov[i].GetOptionValue(); optVal != nil {
out[optVal.Key] = optVal.Value
}
}
if len(out) == 0 {
return nil
}
return out
}
// StringMap returns the list of option values as a map where the values are
// strings. A nil value is returned if the list is empty.
func (ov OptionValueList) StringMap() map[string]string {
if len(ov) == 0 {
return nil
}
out := map[string]string{}
for i := range ov {
if optVal := ov[i].GetOptionValue(); optVal != nil {
out[optVal.Key] = getOptionValueAsString(optVal.Value)
}
}
if len(out) == 0 {
return nil
}
return out
}
func getOptionValueAsString(val any) string {
switch tval := val.(type) {
case string:
return tval
default:
if rv := reflect.ValueOf(val); rv.Kind() == reflect.Pointer {
if rv.IsNil() {
return ""
}
return fmt.Sprintf("%v", rv.Elem().Interface())
}
return fmt.Sprintf("%v", tval)
}
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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.

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2017-2024 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,
@ -17,11 +17,17 @@ limitations under the License.
package pbm
import (
"context"
"fmt"
"strconv"
"strings"
"github.com/vmware/govmomi/pbm/types"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/view"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/mo"
vim "github.com/vmware/govmomi/vim25/types"
)
// A struct to capture pbm create spec details.
@ -146,3 +152,100 @@ func verifyPropertyValueIsBoolean(propertyValue string, dataType string) (bool,
}
return val, nil
}
// ProfileMap contains a map of storage profiles by name.
type ProfileMap struct {
Name map[string]types.BasePbmProfile
Profile []types.BasePbmProfile
}
// ProfileMap builds a map of storage profiles by name.
func (c *Client) ProfileMap(ctx context.Context, uid ...string) (*ProfileMap, error) {
m := &ProfileMap{Name: make(map[string]types.BasePbmProfile)}
rtype := types.PbmProfileResourceType{
ResourceType: string(types.PbmProfileResourceTypeEnumSTORAGE),
}
category := types.PbmProfileCategoryEnumREQUIREMENT
var ids []types.PbmProfileId
if len(uid) == 0 {
var err error
ids, err = c.QueryProfile(ctx, rtype, string(category))
if err != nil {
return nil, err
}
} else {
ids = make([]types.PbmProfileId, len(uid))
for i, id := range uid {
ids[i].UniqueId = id
}
}
profiles, err := c.RetrieveContent(ctx, ids)
if err != nil {
return nil, err
}
m.Profile = profiles
for _, p := range profiles {
base := p.GetPbmProfile()
m.Name[base.Name] = p
m.Name[base.ProfileId.UniqueId] = p
}
return m, nil
}
// DatastoreMap contains a map of Datastore by name.
type DatastoreMap struct {
Name map[string]string
PlacementHub []types.PbmPlacementHub
}
// DatastoreMap returns a map of Datastore by name.
// The root reference can be a ClusterComputeResource or Folder.
func (c *Client) DatastoreMap(ctx context.Context, vc *vim25.Client, root vim.ManagedObjectReference) (*DatastoreMap, error) {
m := &DatastoreMap{Name: make(map[string]string)}
prop := []string{"name"}
var content []vim.ObjectContent
if root.Type == "ClusterComputeResource" {
pc := property.DefaultCollector(vc)
var cluster mo.ClusterComputeResource
if err := pc.RetrieveOne(ctx, root, []string{"datastore"}, &cluster); err != nil {
return nil, err
}
if err := pc.Retrieve(ctx, cluster.Datastore, prop, &content); err != nil {
return nil, err
}
} else {
kind := []string{"Datastore"}
m := view.NewManager(vc)
v, err := m.CreateContainerView(ctx, root, kind, true)
if err != nil {
return nil, err
}
err = v.Retrieve(ctx, kind, prop, &content)
_ = v.Destroy(ctx)
if err != nil {
return nil, err
}
}
for _, item := range content {
m.PlacementHub = append(m.PlacementHub, types.PbmPlacementHub{
HubType: item.Obj.Type,
HubId: item.Obj.Value,
})
m.Name[item.Obj.Value] = item.PropSet[0].Val.(string)
}
return m, nil
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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.
@ -33,6 +33,18 @@ const (
PbmAssociateAndApplyPolicyStatusPolicyStatusInvalid = PbmAssociateAndApplyPolicyStatusPolicyStatus("invalid")
)
func (e PbmAssociateAndApplyPolicyStatusPolicyStatus) Values() []PbmAssociateAndApplyPolicyStatusPolicyStatus {
return []PbmAssociateAndApplyPolicyStatusPolicyStatus{
PbmAssociateAndApplyPolicyStatusPolicyStatusSuccess,
PbmAssociateAndApplyPolicyStatusPolicyStatusFailed,
PbmAssociateAndApplyPolicyStatusPolicyStatusInvalid,
}
}
func (e PbmAssociateAndApplyPolicyStatusPolicyStatus) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmAssociateAndApplyPolicyStatusPolicyStatus", reflect.TypeOf((*PbmAssociateAndApplyPolicyStatusPolicyStatus)(nil)).Elem())
}
@ -58,6 +70,17 @@ const (
PbmBuiltinGenericTypeVMW_SET = PbmBuiltinGenericType("VMW_SET")
)
func (e PbmBuiltinGenericType) Values() []PbmBuiltinGenericType {
return []PbmBuiltinGenericType{
PbmBuiltinGenericTypeVMW_RANGE,
PbmBuiltinGenericTypeVMW_SET,
}
}
func (e PbmBuiltinGenericType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmBuiltinGenericType", reflect.TypeOf((*PbmBuiltinGenericType)(nil)).Elem())
}
@ -80,9 +103,9 @@ const (
// Unsigned long value.
//
// This datatype supports the following constraint values.
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
PbmBuiltinTypeXSD_LONG = PbmBuiltinType("XSD_LONG")
// Datatype not supported.
PbmBuiltinTypeXSD_SHORT = PbmBuiltinType("XSD_SHORT")
@ -93,9 +116,9 @@ const (
// Integer value.
//
// This datatype supports the following constraint values.
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
PbmBuiltinTypeXSD_INT = PbmBuiltinType("XSD_INT")
// String value.
//
@ -108,9 +131,9 @@ const (
//
// This datatype supports the following
// constraint values.
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
PbmBuiltinTypeXSD_DOUBLE = PbmBuiltinType("XSD_DOUBLE")
// Date and time value.
PbmBuiltinTypeXSD_DATETIME = PbmBuiltinType("XSD_DATETIME")
@ -118,13 +141,32 @@ const (
//
// This datatype supports
// the following constraint values.
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
// - Single value
// - Full or partial range of values (`PbmCapabilityRange`)
// - Discrete set of values (`PbmCapabilityDiscreteSet`)
PbmBuiltinTypeVMW_TIMESPAN = PbmBuiltinType("VMW_TIMESPAN")
PbmBuiltinTypeVMW_POLICY = PbmBuiltinType("VMW_POLICY")
)
func (e PbmBuiltinType) Values() []PbmBuiltinType {
return []PbmBuiltinType{
PbmBuiltinTypeXSD_LONG,
PbmBuiltinTypeXSD_SHORT,
PbmBuiltinTypeXSD_INTEGER,
PbmBuiltinTypeXSD_INT,
PbmBuiltinTypeXSD_STRING,
PbmBuiltinTypeXSD_BOOLEAN,
PbmBuiltinTypeXSD_DOUBLE,
PbmBuiltinTypeXSD_DATETIME,
PbmBuiltinTypeVMW_TIMESPAN,
PbmBuiltinTypeVMW_POLICY,
}
}
func (e PbmBuiltinType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmBuiltinType", reflect.TypeOf((*PbmBuiltinType)(nil)).Elem())
}
@ -139,6 +181,16 @@ const (
PbmCapabilityOperatorNOT = PbmCapabilityOperator("NOT")
)
func (e PbmCapabilityOperator) Values() []PbmCapabilityOperator {
return []PbmCapabilityOperator{
PbmCapabilityOperatorNOT,
}
}
func (e PbmCapabilityOperator) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmCapabilityOperator", reflect.TypeOf((*PbmCapabilityOperator)(nil)).Elem())
}
@ -167,6 +219,22 @@ const (
PbmCapabilityTimeUnitTypeYEARS = PbmCapabilityTimeUnitType("YEARS")
)
func (e PbmCapabilityTimeUnitType) Values() []PbmCapabilityTimeUnitType {
return []PbmCapabilityTimeUnitType{
PbmCapabilityTimeUnitTypeSECONDS,
PbmCapabilityTimeUnitTypeMINUTES,
PbmCapabilityTimeUnitTypeHOURS,
PbmCapabilityTimeUnitTypeDAYS,
PbmCapabilityTimeUnitTypeWEEKS,
PbmCapabilityTimeUnitTypeMONTHS,
PbmCapabilityTimeUnitTypeYEARS,
}
}
func (e PbmCapabilityTimeUnitType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmCapabilityTimeUnitType", reflect.TypeOf((*PbmCapabilityTimeUnitType)(nil)).Elem())
}
@ -188,6 +256,18 @@ const (
PbmComplianceResultComplianceTaskStatusFailed = PbmComplianceResultComplianceTaskStatus("failed")
)
func (e PbmComplianceResultComplianceTaskStatus) Values() []PbmComplianceResultComplianceTaskStatus {
return []PbmComplianceResultComplianceTaskStatus{
PbmComplianceResultComplianceTaskStatusInProgress,
PbmComplianceResultComplianceTaskStatusSuccess,
PbmComplianceResultComplianceTaskStatusFailed,
}
}
func (e PbmComplianceResultComplianceTaskStatus) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmComplianceResultComplianceTaskStatus", reflect.TypeOf((*PbmComplianceResultComplianceTaskStatus)(nil)).Elem())
}
@ -221,6 +301,20 @@ const (
PbmComplianceStatusOutOfDate = PbmComplianceStatus("outOfDate")
)
func (e PbmComplianceStatus) Values() []PbmComplianceStatus {
return []PbmComplianceStatus{
PbmComplianceStatusCompliant,
PbmComplianceStatusNonCompliant,
PbmComplianceStatusUnknown,
PbmComplianceStatusNotApplicable,
PbmComplianceStatusOutOfDate,
}
}
func (e PbmComplianceStatus) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmComplianceStatus", reflect.TypeOf((*PbmComplianceStatus)(nil)).Elem())
}
@ -236,6 +330,17 @@ const (
PbmDebugManagerKeystoreNameTRUSTED_ROOTS = PbmDebugManagerKeystoreName("TRUSTED_ROOTS")
)
func (e PbmDebugManagerKeystoreName) Values() []PbmDebugManagerKeystoreName {
return []PbmDebugManagerKeystoreName{
PbmDebugManagerKeystoreNameSMS,
PbmDebugManagerKeystoreNameTRUSTED_ROOTS,
}
}
func (e PbmDebugManagerKeystoreName) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmDebugManagerKeystoreName", reflect.TypeOf((*PbmDebugManagerKeystoreName)(nil)).Elem())
}
@ -267,6 +372,19 @@ const (
PbmHealthStatusForEntityUnknown = PbmHealthStatusForEntity("unknown")
)
func (e PbmHealthStatusForEntity) Values() []PbmHealthStatusForEntity {
return []PbmHealthStatusForEntity{
PbmHealthStatusForEntityRed,
PbmHealthStatusForEntityYellow,
PbmHealthStatusForEntityGreen,
PbmHealthStatusForEntityUnknown,
}
}
func (e PbmHealthStatusForEntity) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmHealthStatusForEntity", reflect.TypeOf((*PbmHealthStatusForEntity)(nil)).Elem())
}
@ -288,6 +406,22 @@ const (
PbmIofilterInfoFilterTypeDATASTOREIOCONTROL = PbmIofilterInfoFilterType("DATASTOREIOCONTROL")
)
func (e PbmIofilterInfoFilterType) Values() []PbmIofilterInfoFilterType {
return []PbmIofilterInfoFilterType{
PbmIofilterInfoFilterTypeINSPECTION,
PbmIofilterInfoFilterTypeCOMPRESSION,
PbmIofilterInfoFilterTypeENCRYPTION,
PbmIofilterInfoFilterTypeREPLICATION,
PbmIofilterInfoFilterTypeCACHE,
PbmIofilterInfoFilterTypeDATAPROVIDER,
PbmIofilterInfoFilterTypeDATASTOREIOCONTROL,
}
}
func (e PbmIofilterInfoFilterType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmIofilterInfoFilterType", reflect.TypeOf((*PbmIofilterInfoFilterType)(nil)).Elem())
}
@ -305,8 +439,28 @@ const (
PbmLineOfServiceInfoLineOfServiceEnumDATA_PROVIDER = PbmLineOfServiceInfoLineOfServiceEnum("DATA_PROVIDER")
PbmLineOfServiceInfoLineOfServiceEnumDATASTORE_IO_CONTROL = PbmLineOfServiceInfoLineOfServiceEnum("DATASTORE_IO_CONTROL")
PbmLineOfServiceInfoLineOfServiceEnumDATA_PROTECTION = PbmLineOfServiceInfoLineOfServiceEnum("DATA_PROTECTION")
PbmLineOfServiceInfoLineOfServiceEnumSTRETCHED_CLUSTER = PbmLineOfServiceInfoLineOfServiceEnum("STRETCHED_CLUSTER")
)
func (e PbmLineOfServiceInfoLineOfServiceEnum) Values() []PbmLineOfServiceInfoLineOfServiceEnum {
return []PbmLineOfServiceInfoLineOfServiceEnum{
PbmLineOfServiceInfoLineOfServiceEnumINSPECTION,
PbmLineOfServiceInfoLineOfServiceEnumCOMPRESSION,
PbmLineOfServiceInfoLineOfServiceEnumENCRYPTION,
PbmLineOfServiceInfoLineOfServiceEnumREPLICATION,
PbmLineOfServiceInfoLineOfServiceEnumCACHING,
PbmLineOfServiceInfoLineOfServiceEnumPERSISTENCE,
PbmLineOfServiceInfoLineOfServiceEnumDATA_PROVIDER,
PbmLineOfServiceInfoLineOfServiceEnumDATASTORE_IO_CONTROL,
PbmLineOfServiceInfoLineOfServiceEnumDATA_PROTECTION,
PbmLineOfServiceInfoLineOfServiceEnumSTRETCHED_CLUSTER,
}
}
func (e PbmLineOfServiceInfoLineOfServiceEnum) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmLineOfServiceInfoLineOfServiceEnum", reflect.TypeOf((*PbmLineOfServiceInfoLineOfServiceEnum)(nil)).Elem())
}
@ -334,6 +488,23 @@ const (
PbmLoggingConfigurationComponentVmomi = PbmLoggingConfigurationComponent("vmomi")
)
func (e PbmLoggingConfigurationComponent) Values() []PbmLoggingConfigurationComponent {
return []PbmLoggingConfigurationComponent{
PbmLoggingConfigurationComponentPbm,
PbmLoggingConfigurationComponentVslm,
PbmLoggingConfigurationComponentSms,
PbmLoggingConfigurationComponentSpbm,
PbmLoggingConfigurationComponentSps,
PbmLoggingConfigurationComponentHttpclient_header,
PbmLoggingConfigurationComponentHttpclient_content,
PbmLoggingConfigurationComponentVmomi,
}
}
func (e PbmLoggingConfigurationComponent) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmLoggingConfigurationComponent", reflect.TypeOf((*PbmLoggingConfigurationComponent)(nil)).Elem())
}
@ -351,6 +522,18 @@ const (
PbmLoggingConfigurationLogLevelTRACE = PbmLoggingConfigurationLogLevel("TRACE")
)
func (e PbmLoggingConfigurationLogLevel) Values() []PbmLoggingConfigurationLogLevel {
return []PbmLoggingConfigurationLogLevel{
PbmLoggingConfigurationLogLevelINFO,
PbmLoggingConfigurationLogLevelDEBUG,
PbmLoggingConfigurationLogLevelTRACE,
}
}
func (e PbmLoggingConfigurationLogLevel) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmLoggingConfigurationLogLevel", reflect.TypeOf((*PbmLoggingConfigurationLogLevel)(nil)).Elem())
}
@ -384,6 +567,23 @@ const (
PbmObjectTypeUnknown = PbmObjectType("unknown")
)
func (e PbmObjectType) Values() []PbmObjectType {
return []PbmObjectType{
PbmObjectTypeVirtualMachine,
PbmObjectTypeVirtualMachineAndDisks,
PbmObjectTypeVirtualDiskId,
PbmObjectTypeVirtualDiskUUID,
PbmObjectTypeDatastore,
PbmObjectTypeVsanObjectId,
PbmObjectTypeFileShareId,
PbmObjectTypeUnknown,
}
}
func (e PbmObjectType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmObjectType", reflect.TypeOf((*PbmObjectType)(nil)).Elem())
}
@ -405,6 +605,20 @@ const (
PbmOperationCLONE = PbmOperation("CLONE")
)
func (e PbmOperation) Values() []PbmOperation {
return []PbmOperation{
PbmOperationCREATE,
PbmOperationREGISTER,
PbmOperationRECONFIGURE,
PbmOperationMIGRATE,
PbmOperationCLONE,
}
}
func (e PbmOperation) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmOperation", reflect.TypeOf((*PbmOperation)(nil)).Elem())
}
@ -428,6 +642,18 @@ const (
PbmPolicyAssociationVolumeAllocationTypeConserveSpaceWhenPossible = PbmPolicyAssociationVolumeAllocationType("ConserveSpaceWhenPossible")
)
func (e PbmPolicyAssociationVolumeAllocationType) Values() []PbmPolicyAssociationVolumeAllocationType {
return []PbmPolicyAssociationVolumeAllocationType{
PbmPolicyAssociationVolumeAllocationTypeFullyInitialized,
PbmPolicyAssociationVolumeAllocationTypeReserveSpace,
PbmPolicyAssociationVolumeAllocationTypeConserveSpaceWhenPossible,
}
}
func (e PbmPolicyAssociationVolumeAllocationType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmPolicyAssociationVolumeAllocationType", reflect.TypeOf((*PbmPolicyAssociationVolumeAllocationType)(nil)).Elem())
}
@ -459,6 +685,18 @@ const (
PbmProfileCategoryEnumDATA_SERVICE_POLICY = PbmProfileCategoryEnum("DATA_SERVICE_POLICY")
)
func (e PbmProfileCategoryEnum) Values() []PbmProfileCategoryEnum {
return []PbmProfileCategoryEnum{
PbmProfileCategoryEnumREQUIREMENT,
PbmProfileCategoryEnumRESOURCE,
PbmProfileCategoryEnumDATA_SERVICE_POLICY,
}
}
func (e PbmProfileCategoryEnum) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmProfileCategoryEnum", reflect.TypeOf((*PbmProfileCategoryEnum)(nil)).Elem())
}
@ -474,6 +712,16 @@ const (
PbmProfileResourceTypeEnumSTORAGE = PbmProfileResourceTypeEnum("STORAGE")
)
func (e PbmProfileResourceTypeEnum) Values() []PbmProfileResourceTypeEnum {
return []PbmProfileResourceTypeEnum{
PbmProfileResourceTypeEnumSTORAGE,
}
}
func (e PbmProfileResourceTypeEnum) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmProfileResourceTypeEnum", reflect.TypeOf((*PbmProfileResourceTypeEnum)(nil)).Elem())
}
@ -496,6 +744,20 @@ const (
PbmSystemCreatedProfileTypeVsanMaxDefaultProfile = PbmSystemCreatedProfileType("VsanMaxDefaultProfile")
)
func (e PbmSystemCreatedProfileType) Values() []PbmSystemCreatedProfileType {
return []PbmSystemCreatedProfileType{
PbmSystemCreatedProfileTypeVsanDefaultProfile,
PbmSystemCreatedProfileTypeVVolDefaultProfile,
PbmSystemCreatedProfileTypePmemDefaultProfile,
PbmSystemCreatedProfileTypeVmcManagementProfile,
PbmSystemCreatedProfileTypeVsanMaxDefaultProfile,
}
}
func (e PbmSystemCreatedProfileType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmSystemCreatedProfileType", reflect.TypeOf((*PbmSystemCreatedProfileType)(nil)).Elem())
}
@ -515,6 +777,19 @@ const (
PbmVmOperationCLONE = PbmVmOperation("CLONE")
)
func (e PbmVmOperation) Values() []PbmVmOperation {
return []PbmVmOperation{
PbmVmOperationCREATE,
PbmVmOperationRECONFIGURE,
PbmVmOperationMIGRATE,
PbmVmOperationCLONE,
}
}
func (e PbmVmOperation) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmVmOperation", reflect.TypeOf((*PbmVmOperation)(nil)).Elem())
}
@ -535,6 +810,18 @@ const (
PbmVvolTypeSwap = PbmVvolType("Swap")
)
func (e PbmVvolType) Values() []PbmVvolType {
return []PbmVvolType{
PbmVvolTypeConfig,
PbmVvolTypeData,
PbmVvolTypeSwap,
}
}
func (e PbmVvolType) Strings() []string {
return types.EnumValuesAsStrings(e.Values())
}
func init() {
types.Add("pbm:PbmVvolType", reflect.TypeOf((*PbmVvolType)(nil)).Elem())
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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.

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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.
@ -24,6 +24,8 @@ import (
)
// A boxed array of `PbmCapabilityConstraintInstance`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityConstraintInstance struct {
PbmCapabilityConstraintInstance []PbmCapabilityConstraintInstance `xml:"PbmCapabilityConstraintInstance,omitempty" json:"_value"`
}
@ -33,6 +35,8 @@ func init() {
}
// A boxed array of `PbmCapabilityInstance`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityInstance struct {
PbmCapabilityInstance []PbmCapabilityInstance `xml:"PbmCapabilityInstance,omitempty" json:"_value"`
}
@ -42,6 +46,8 @@ func init() {
}
// A boxed array of `PbmCapabilityMetadata`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityMetadata struct {
PbmCapabilityMetadata []PbmCapabilityMetadata `xml:"PbmCapabilityMetadata,omitempty" json:"_value"`
}
@ -51,6 +57,8 @@ func init() {
}
// A boxed array of `PbmCapabilityMetadataPerCategory`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityMetadataPerCategory struct {
PbmCapabilityMetadataPerCategory []PbmCapabilityMetadataPerCategory `xml:"PbmCapabilityMetadataPerCategory,omitempty" json:"_value"`
}
@ -60,6 +68,8 @@ func init() {
}
// A boxed array of `PbmCapabilityPropertyInstance`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityPropertyInstance struct {
PbmCapabilityPropertyInstance []PbmCapabilityPropertyInstance `xml:"PbmCapabilityPropertyInstance,omitempty" json:"_value"`
}
@ -69,6 +79,8 @@ func init() {
}
// A boxed array of `PbmCapabilityPropertyMetadata`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityPropertyMetadata struct {
PbmCapabilityPropertyMetadata []PbmCapabilityPropertyMetadata `xml:"PbmCapabilityPropertyMetadata,omitempty" json:"_value"`
}
@ -78,6 +90,8 @@ func init() {
}
// A boxed array of `PbmCapabilitySchema`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilitySchema struct {
PbmCapabilitySchema []PbmCapabilitySchema `xml:"PbmCapabilitySchema,omitempty" json:"_value"`
}
@ -87,6 +101,8 @@ func init() {
}
// A boxed array of `PbmCapabilitySubProfile`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilitySubProfile struct {
PbmCapabilitySubProfile []PbmCapabilitySubProfile `xml:"PbmCapabilitySubProfile,omitempty" json:"_value"`
}
@ -96,6 +112,8 @@ func init() {
}
// A boxed array of `PbmCapabilityVendorNamespaceInfo`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityVendorNamespaceInfo struct {
PbmCapabilityVendorNamespaceInfo []PbmCapabilityVendorNamespaceInfo `xml:"PbmCapabilityVendorNamespaceInfo,omitempty" json:"_value"`
}
@ -105,6 +123,8 @@ func init() {
}
// A boxed array of `PbmCapabilityVendorResourceTypeInfo`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCapabilityVendorResourceTypeInfo struct {
PbmCapabilityVendorResourceTypeInfo []PbmCapabilityVendorResourceTypeInfo `xml:"PbmCapabilityVendorResourceTypeInfo,omitempty" json:"_value"`
}
@ -114,6 +134,8 @@ func init() {
}
// A boxed array of `PbmCompliancePolicyStatus`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmCompliancePolicyStatus struct {
PbmCompliancePolicyStatus []PbmCompliancePolicyStatus `xml:"PbmCompliancePolicyStatus,omitempty" json:"_value"`
}
@ -123,6 +145,8 @@ func init() {
}
// A boxed array of `PbmComplianceResult`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmComplianceResult struct {
PbmComplianceResult []PbmComplianceResult `xml:"PbmComplianceResult,omitempty" json:"_value"`
}
@ -132,6 +156,8 @@ func init() {
}
// A boxed array of `PbmDatastoreSpaceStatistics`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmDatastoreSpaceStatistics struct {
PbmDatastoreSpaceStatistics []PbmDatastoreSpaceStatistics `xml:"PbmDatastoreSpaceStatistics,omitempty" json:"_value"`
}
@ -141,6 +167,8 @@ func init() {
}
// A boxed array of `PbmDefaultProfileInfo`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmDefaultProfileInfo struct {
PbmDefaultProfileInfo []PbmDefaultProfileInfo `xml:"PbmDefaultProfileInfo,omitempty" json:"_value"`
}
@ -150,6 +178,8 @@ func init() {
}
// A boxed array of `PbmFaultNoPermissionEntityPrivileges`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmFaultNoPermissionEntityPrivileges struct {
PbmFaultNoPermissionEntityPrivileges []PbmFaultNoPermissionEntityPrivileges `xml:"PbmFaultNoPermissionEntityPrivileges,omitempty" json:"_value"`
}
@ -159,6 +189,8 @@ func init() {
}
// A boxed array of `PbmLoggingConfiguration`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmLoggingConfiguration struct {
PbmLoggingConfiguration []PbmLoggingConfiguration `xml:"PbmLoggingConfiguration,omitempty" json:"_value"`
}
@ -168,6 +200,8 @@ func init() {
}
// A boxed array of `PbmPlacementCompatibilityResult`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmPlacementCompatibilityResult struct {
PbmPlacementCompatibilityResult []PbmPlacementCompatibilityResult `xml:"PbmPlacementCompatibilityResult,omitempty" json:"_value"`
}
@ -177,6 +211,8 @@ func init() {
}
// A boxed array of `PbmPlacementHub`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmPlacementHub struct {
PbmPlacementHub []PbmPlacementHub `xml:"PbmPlacementHub,omitempty" json:"_value"`
}
@ -186,6 +222,8 @@ func init() {
}
// A boxed array of `PbmPlacementMatchingResources`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmPlacementMatchingResources struct {
PbmPlacementMatchingResources []BasePbmPlacementMatchingResources `xml:"PbmPlacementMatchingResources,omitempty,typeattr" json:"_value"`
}
@ -195,6 +233,8 @@ func init() {
}
// A boxed array of `PbmPlacementRequirement`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmPlacementRequirement struct {
PbmPlacementRequirement []BasePbmPlacementRequirement `xml:"PbmPlacementRequirement,omitempty,typeattr" json:"_value"`
}
@ -204,6 +244,8 @@ func init() {
}
// A boxed array of `PbmPlacementResourceUtilization`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmPlacementResourceUtilization struct {
PbmPlacementResourceUtilization []PbmPlacementResourceUtilization `xml:"PbmPlacementResourceUtilization,omitempty" json:"_value"`
}
@ -213,6 +255,8 @@ func init() {
}
// A boxed array of `PbmProfile`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmProfile struct {
PbmProfile []BasePbmProfile `xml:"PbmProfile,omitempty,typeattr" json:"_value"`
}
@ -222,6 +266,8 @@ func init() {
}
// A boxed array of `PbmProfileId`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmProfileId struct {
PbmProfileId []PbmProfileId `xml:"PbmProfileId,omitempty" json:"_value"`
}
@ -231,6 +277,8 @@ func init() {
}
// A boxed array of `PbmProfileOperationOutcome`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmProfileOperationOutcome struct {
PbmProfileOperationOutcome []PbmProfileOperationOutcome `xml:"PbmProfileOperationOutcome,omitempty" json:"_value"`
}
@ -240,6 +288,8 @@ func init() {
}
// A boxed array of `PbmProfileResourceType`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmProfileResourceType struct {
PbmProfileResourceType []PbmProfileResourceType `xml:"PbmProfileResourceType,omitempty" json:"_value"`
}
@ -249,6 +299,8 @@ func init() {
}
// A boxed array of `PbmProfileType`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmProfileType struct {
PbmProfileType []PbmProfileType `xml:"PbmProfileType,omitempty" json:"_value"`
}
@ -258,6 +310,8 @@ func init() {
}
// A boxed array of `PbmQueryProfileResult`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmQueryProfileResult struct {
PbmQueryProfileResult []PbmQueryProfileResult `xml:"PbmQueryProfileResult,omitempty" json:"_value"`
}
@ -267,6 +321,8 @@ func init() {
}
// A boxed array of `PbmQueryReplicationGroupResult`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmQueryReplicationGroupResult struct {
PbmQueryReplicationGroupResult []PbmQueryReplicationGroupResult `xml:"PbmQueryReplicationGroupResult,omitempty" json:"_value"`
}
@ -276,6 +332,8 @@ func init() {
}
// A boxed array of `PbmRollupComplianceResult`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmRollupComplianceResult struct {
PbmRollupComplianceResult []PbmRollupComplianceResult `xml:"PbmRollupComplianceResult,omitempty" json:"_value"`
}
@ -285,6 +343,8 @@ func init() {
}
// A boxed array of `PbmServerObjectRef`. To be used in `Any` placeholders.
//
// This structure may be used only with operations rendered under `/pbm`.
type ArrayOfPbmServerObjectRef struct {
PbmServerObjectRef []PbmServerObjectRef `xml:"PbmServerObjectRef,omitempty" json:"_value"`
}
@ -340,6 +400,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmAssignDefaultRequirementProfile`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmAssignDefaultRequirementProfileRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// The profile that needs to be made default profile.
@ -544,6 +606,7 @@ func init() {
types.Add("pbm:PbmCapabilityMetadataPerCategory", reflect.TypeOf((*PbmCapabilityMetadataPerCategory)(nil)).Elem())
}
// This structure may be used only with operations rendered under `/pbm`.
type PbmCapabilityMetadataUniqueId struct {
types.DynamicData
@ -601,23 +664,22 @@ type PbmCapabilityProfile struct {
// The <code>profileCategory</code>
// is a string value that corresponds to one of the
// `PbmProfileCategoryEnum_enum` values.
// - REQUIREMENT profile - Defines the storage constraints applied
// to virtual machine placement. Requirements are defined by
// the user and can be associated with virtual machines and virtual
// disks. During provisioning, you can use a requirements profile
// for compliance and placement checking to support
// selection and configuration of resources.
// - RESOURCE profile - Specifies system-defined storage capabilities.
// You cannot modify a resource profile. You cannot associate a resource
// profile with vSphere entities, use it during provisioning, or target
// entities for resource selection or configuration.
// This type of profile gives the user visibility into the capabilities
// supported by the storage provider.
//
// DATA\_SERVICE\_POLICY - Indicates a data service policy that can
// be embedded into another storage policy. Policies of this type can't
// be assigned to Virtual Machines or Virtual Disks. This policy cannot
// be used for compliance checking.
// - REQUIREMENT profile - Defines the storage constraints applied
// to virtual machine placement. Requirements are defined by
// the user and can be associated with virtual machines and virtual
// disks. During provisioning, you can use a requirements profile
// for compliance and placement checking to support
// selection and configuration of resources.
// - RESOURCE profile - Specifies system-defined storage capabilities.
// You cannot modify a resource profile. You cannot associate a resource
// profile with vSphere entities, use it during provisioning, or target
// entities for resource selection or configuration.
// This type of profile gives the user visibility into the capabilities
// supported by the storage provider.
// - DATA\_SERVICE\_POLICY - Indicates a data service policy that can
// be embedded into another storage policy. Policies of this type can't
// be assigned to Virtual Machines or Virtual Disks. This policy cannot
// be used for compliance checking.
ProfileCategory string `xml:"profileCategory" json:"profileCategory"`
// Type of the target resource to which the capability information applies.
//
@ -764,9 +826,9 @@ type PbmCapabilityPropertyInstance struct {
//
// You must specify the value.
// A property value is one value or a collection of values.
// - A single property value is expressed as a scalar value.
// - A collection of values is expressed as a `PbmCapabilityDiscreteSet`
// or a `PbmCapabilityRange` of values.
// - A single property value is expressed as a scalar value.
// - A collection of values is expressed as a `PbmCapabilityDiscreteSet`
// or a `PbmCapabilityRange` of values.
//
// The datatype of each value must be one of the
// `PbmBuiltinType_enum` datatypes.
@ -799,23 +861,23 @@ type PbmCapabilityPropertyMetadata struct {
// (`PbmCapabilityPropertyInstance*.*PbmCapabilityPropertyInstance.id`).
Id string `xml:"id" json:"id"`
// Property name and description.
// - The <code>summary.label</code> property
// (`PbmExtendedElementDescription.label`)
// contains property 'name' in server locale.
// - The <code>summary.summary</code> property
// (`PbmExtendedElementDescription.summary`)
// contains property 'description' in server locale.
// - The <code>summary.messageCatalogKeyPrefix</code> property
// (`PbmExtendedElementDescription.messageCatalogKeyPrefix`)
// contains unique prefix for this property within given message catalog.
// Prefix format: &lt;capability\_unique\_identifier.&lt;property\_id
// capability\_unique\_identifier -- string representation of
// `PbmCapabilityMetadataUniqueId` which globally identifies given
// capability metadata definition uniquely.
// property\_id -- 'id' of this property `PbmCapabilityPropertyMetadata.id`
// Eg www.emc.com.storage.Recovery.Recovery\_site
// www.emc.com.storage.Recovery.RPO
// www.emc.com.storage.Recovery.RTO
// - The <code>summary.label</code> property
// (`PbmExtendedElementDescription.label`)
// contains property 'name' in server locale.
// - The <code>summary.summary</code> property
// (`PbmExtendedElementDescription.summary`)
// contains property 'description' in server locale.
// - The <code>summary.messageCatalogKeyPrefix</code> property
// (`PbmExtendedElementDescription.messageCatalogKeyPrefix`)
// contains unique prefix for this property within given message catalog.
// Prefix format: &lt;capability\_unique\_identifier&gt;.&lt;property\_id&gt;
// capability\_unique\_identifier -- string representation of
// `PbmCapabilityMetadataUniqueId` which globally identifies given
// capability metadata definition uniquely.
// property\_id -- 'id' of this property `PbmCapabilityPropertyMetadata.id`
// Eg www.emc.com.storage.Recovery.Recovery\_site
// www.emc.com.storage.Recovery.RPO
// www.emc.com.storage.Recovery.RTO
Summary PbmExtendedElementDescription `xml:"summary" json:"summary"`
// Indicates whether incorporating given capability is mandatory during creation of
// profile.
@ -826,11 +888,11 @@ type PbmCapabilityPropertyMetadata struct {
// (`PbmCapabilityPropertyInstance*.*PbmCapabilityPropertyInstance.value`)
// is specified as a builtin datatype and may also specify the interpretation of a
// collection of values of that datatype.
// - `PbmCapabilityPropertyMetadata.type*.*PbmCapabilityTypeInfo.typeName`
// specifies the `PbmBuiltinType_enum`.
// - `PbmCapabilityPropertyMetadata.type*.*PbmCapabilityGenericTypeInfo.genericTypeName`
// indicates how a collection of values of the specified datatype will be interpreted
// (`PbmBuiltinGenericType_enum`).
// - `PbmCapabilityPropertyMetadata.type*.*PbmCapabilityTypeInfo.typeName`
// specifies the `PbmBuiltinType_enum`.
// - `PbmCapabilityPropertyMetadata.type*.*PbmCapabilityGenericTypeInfo.genericTypeName`
// indicates how a collection of values of the specified datatype will be interpreted
// (`PbmBuiltinGenericType_enum`).
Type BasePbmCapabilityTypeInfo `xml:"type,omitempty,typeattr" json:"type,omitempty"`
// Default value, if any, that the property will assume when not
// constrained by requirements.
@ -861,14 +923,14 @@ type PbmCapabilityPropertyMetadata struct {
// different types across capability profiles. This value, if specified,
// specifies the expected kind of constraint used in requirement profiles.
// Considerations for using this information:
// - This is only a hint; any properly formed constraint
// (see `PbmCapabilityPropertyInstance.value`)
// is still valid for a requirement profile.
// - If VMW\_SET is hinted, then a single value matching the property metadata type is
// also an expected form of constraint, as the latter is an allowed convenience
// for expressing a single-member set.
// - If this hint is not specified, then the authoring system may default to a form of
// constraint determined by its own criteria.
// - This is only a hint; any properly formed constraint
// (see `PbmCapabilityPropertyInstance.value`)
// is still valid for a requirement profile.
// - If VMW\_SET is hinted, then a single value matching the property metadata type is
// also an expected form of constraint, as the latter is an allowed convenience
// for expressing a single-member set.
// - If this hint is not specified, then the authoring system may default to a form of
// constraint determined by its own criteria.
RequirementsTypeHint string `xml:"requirementsTypeHint,omitempty" json:"requirementsTypeHint,omitempty"`
}
@ -938,16 +1000,16 @@ type PbmCapabilitySchemaVendorInfo struct {
VendorUuid string `xml:"vendorUuid" json:"vendorUuid"`
// Captures name and description information about the vendor/owner of
// the schema.
// - The <code>summary.label</code> property
// (`PbmExtendedElementDescription.label`)
// contains vendor name information in server locale.
// - The <code>summary.summary</code> property
// (`PbmExtendedElementDescription.summary`)
// contains vendor description string in server locale.
// - The <code>summary.messageCatalogKeyPrefix</code> property
// (`PbmExtendedElementDescription.messageCatalogKeyPrefix`)
// contains unique prefix for the vendor information within given message
// catalog.
// - The <code>summary.label</code> property
// (`PbmExtendedElementDescription.label`)
// contains vendor name information in server locale.
// - The <code>summary.summary</code> property
// (`PbmExtendedElementDescription.summary`)
// contains vendor description string in server locale.
// - The <code>summary.messageCatalogKeyPrefix</code> property
// (`PbmExtendedElementDescription.messageCatalogKeyPrefix`)
// contains unique prefix for the vendor information within given message
// catalog.
Info PbmExtendedElementDescription `xml:"info" json:"info"`
}
@ -1062,6 +1124,7 @@ func init() {
types.Add("pbm:PbmCapabilityTypeInfo", reflect.TypeOf((*PbmCapabilityTypeInfo)(nil)).Elem())
}
// This structure may be used only with operations rendered under `/pbm`.
type PbmCapabilityVendorNamespaceInfo struct {
types.DynamicData
@ -1073,6 +1136,7 @@ func init() {
types.Add("pbm:PbmCapabilityVendorNamespaceInfo", reflect.TypeOf((*PbmCapabilityVendorNamespaceInfo)(nil)).Elem())
}
// This structure may be used only with operations rendered under `/pbm`.
type PbmCapabilityVendorResourceTypeInfo struct {
types.DynamicData
@ -1081,7 +1145,7 @@ type PbmCapabilityVendorResourceTypeInfo struct {
//
// Must match one of the values for enum `PbmProfileResourceTypeEnum_enum`
ResourceType string `xml:"resourceType" json:"resourceType"`
// List of all vendorInfo -- namespaceInfo tuples that are registered for
// List of all vendorInfo &lt;--&gt; namespaceInfo tuples that are registered for
// given resource type
VendorNamespaceInfo []PbmCapabilityVendorNamespaceInfo `xml:"vendorNamespaceInfo" json:"vendorNamespaceInfo"`
}
@ -1097,6 +1161,8 @@ func init() {
}
// The parameters of `PbmPlacementSolver.PbmCheckCompatibility`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmCheckCompatibilityRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Candidate list of hubs, either datastores or storage pods or a
@ -1123,6 +1189,8 @@ func init() {
}
// The parameters of `PbmPlacementSolver.PbmCheckCompatibilityWithSpec`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmCheckCompatibilityWithSpecRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Candidate list of hubs, either datastores or storage pods
@ -1148,6 +1216,8 @@ func init() {
}
// The parameters of `PbmComplianceManager.PbmCheckCompliance`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmCheckComplianceRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// One or more references to storage entities.
@ -1155,16 +1225,16 @@ type PbmCheckComplianceRequestType struct {
// A maximum of 1000 virtual machines and/or virtual disks can be specified
// in a call. The results of calling the checkCompliance API with
// more than a 1000 entities is undefined.
// - If the list of entities also contains datastores, the Server
// will ignore the datastores.
// - If the list contains valid and invalid entities, the Server ignores
// the invalid entities and returns results for the valid entities.
// Invalid entities are entities that are not in the vCenter inventory.
// - If the list contains only datastores, the method throws
// an <code>InvalidArgument</code> fault.
// - If the list contains virtual machines and disks and the entities
// are invalid or have been deleted by the time of the request, the method
// throws an <code>InvalidArgument</code> fault.
// - If the list of entities also contains datastores, the Server
// will ignore the datastores.
// - If the list contains valid and invalid entities, the Server ignores
// the invalid entities and returns results for the valid entities.
// Invalid entities are entities that are not in the vCenter inventory.
// - If the list contains only datastores, the method throws
// an <code>InvalidArgument</code> fault.
// - If the list contains virtual machines and disks and the entities
// are invalid or have been deleted by the time of the request, the method
// throws an <code>InvalidArgument</code> fault.
//
// If an entity does not have an associated storage profile, the entity
// is removed from the list.
@ -1189,6 +1259,8 @@ func init() {
}
// The parameters of `PbmPlacementSolver.PbmCheckRequirements`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmCheckRequirementsRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Candidate list of hubs, either datastores or storage pods
@ -1226,6 +1298,8 @@ func init() {
}
// The parameters of `PbmComplianceManager.PbmCheckRollupCompliance`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmCheckRollupComplianceRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// One or more references to virtual machines.
@ -1394,6 +1468,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmCreate`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmCreateRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Capability-based profile specification.
@ -1527,6 +1603,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmDelete`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmDeleteRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Array of profile identifiers.
@ -1562,6 +1640,7 @@ func init() {
types.Add("pbm:PbmDuplicateNameFault", reflect.TypeOf((*PbmDuplicateNameFault)(nil)).Elem())
}
// This structure may be used only with operations rendered under `/pbm`.
type PbmExtendedElementDescription struct {
types.DynamicData
@ -1580,7 +1659,7 @@ type PbmExtendedElementDescription struct {
// will be provided by #messageArg.
// Both summary and label in ElementDescription will have a corresponding
// entry in the message catalog with the keys
// .summary and .label
// &lt;messageCatalogKeyPrefix&gt;.summary and &lt;messageCatalogKeyPrefix&gt;.label
// respectively.
// ElementDescription.summary and ElementDescription.label will contain
// the strings in server locale.
@ -1644,6 +1723,7 @@ func init() {
types.Add("pbm:PbmFaultNoPermission", reflect.TypeOf((*PbmFaultNoPermission)(nil)).Elem())
}
// This structure may be used only with operations rendered under `/pbm`.
type PbmFaultNoPermissionEntityPrivileges struct {
types.DynamicData
@ -1688,6 +1768,7 @@ func init() {
types.Add("pbm:PbmFaultNotFoundFault", reflect.TypeOf((*PbmFaultNotFoundFault)(nil)).Elem())
}
// This structure may be used only with operations rendered under `/pbm`.
type PbmFaultProfileStorageFault struct {
PbmFault
}
@ -1709,6 +1790,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmFetchCapabilityMetadata`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmFetchCapabilityMetadataRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Type of profile resource. The Server supports the "STORAGE" resource
@ -1738,6 +1821,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmFetchCapabilitySchema`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmFetchCapabilitySchemaRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Unique identifier for the vendor/owner of capability metadata.
@ -1768,19 +1853,21 @@ func init() {
}
// The parameters of `PbmComplianceManager.PbmFetchComplianceResult`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmFetchComplianceResultRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// One or more references to storage entities.
// A maximum of 1000 virtual machines and/or virtual disks can be specified
// in a call. The results of calling the fetchComplianceResult API with
// more than a 1000 entities is undefined.
// - If the list of entities also contains datastores, the Server
// will ignore the datastores.
// - If the list contains valid and invalid entities, the Server ignores
// the invalid entities and returns results for the valid entities.
// Invalid entities are entities that are not in the vCenter inventory.
// - If the list contains only datastores, the method throws
// an <code>InvalidArgument</code> fault.
// - If the list of entities also contains datastores, the Server
// will ignore the datastores.
// - If the list contains valid and invalid entities, the Server ignores
// the invalid entities and returns results for the valid entities.
// Invalid entities are entities that are not in the vCenter inventory.
// - If the list contains only datastores, the method throws
// an <code>InvalidArgument</code> fault.
Entities []PbmServerObjectRef `xml:"entities" json:"entities"`
// Not used. if specified, the Server ignores the value.
// The Server uses the profiles associated with the specified entities.
@ -1839,6 +1926,8 @@ func init() {
}
// The parameters of `PbmComplianceManager.PbmFetchRollupComplianceResult`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmFetchRollupComplianceResultRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// One or more virtual machines.
@ -1863,6 +1952,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmFetchVendorInfo`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmFetchVendorInfoRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Specifies the resource type. The Server supports the STORAGE resource
@ -1886,6 +1977,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmFindApplicableDefaultProfile`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmFindApplicableDefaultProfileRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Datastores for which the default profile is found out. Note that
@ -1965,6 +2058,7 @@ func init() {
types.Add("pbm:PbmLineOfServiceInfo", reflect.TypeOf((*PbmLineOfServiceInfo)(nil)).Elem())
}
// This structure may be used only with operations rendered under `/pbm`.
type PbmLoggingConfiguration struct {
types.DynamicData
@ -2318,6 +2412,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedEntities`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryAssociatedEntitiesRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Storage policy array.
@ -2339,6 +2435,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedEntity`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryAssociatedEntityRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Profile identifier.
@ -2365,6 +2463,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedProfile`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryAssociatedProfileRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Reference to a virtual machine, virtual disk, or datastore.
@ -2386,6 +2486,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedProfiles`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryAssociatedProfilesRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Array of server object references.
@ -2407,6 +2509,8 @@ func init() {
}
// The parameters of `PbmComplianceManager.PbmQueryByRollupComplianceStatus`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryByRollupComplianceStatusRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// `PbmComplianceStatus_enum`
@ -2428,6 +2532,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQueryDefaultRequirementProfile`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryDefaultRequirementProfileRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Placement hub (i.e. datastore).
@ -2449,6 +2555,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQueryDefaultRequirementProfiles`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryDefaultRequirementProfilesRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// The datastores for which the default profiles are requested. For
@ -2472,6 +2580,8 @@ func init() {
}
// The parameters of `PbmPlacementSolver.PbmQueryMatchingHub`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryMatchingHubRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Candidate list of hubs, either datastores or storage pods or a
@ -2497,6 +2607,8 @@ func init() {
}
// The parameters of `PbmPlacementSolver.PbmQueryMatchingHubWithSpec`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryMatchingHubWithSpecRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Candidate list of hubs, either datastores or storage
@ -2522,6 +2634,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQueryProfile`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryProfileRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Type of resource. You can specify only STORAGE.
@ -2593,6 +2707,8 @@ func init() {
}
// The parameters of `PbmReplicationManager.PbmQueryReplicationGroups`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQueryReplicationGroupsRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Array of server object references. Valid types are
@ -2618,6 +2734,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmQuerySpaceStatsForStorageContainer`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmQuerySpaceStatsForStorageContainerRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Entity for which space statistics are being requested i.e datastore.
@ -2643,6 +2761,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmResetDefaultRequirementProfile`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmResetDefaultRequirementProfileRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Profile to reset.
@ -2706,6 +2826,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmRetrieveContent`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmRetrieveContentRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Array of storage profile identifiers.
@ -2767,16 +2889,16 @@ type PbmRollupComplianceResult struct {
//
// The overall compliance status is determined by the following rules, applied in the order
// listed:
// - If all the entities are <code>compliant</code>, the overall status is
// <code>compliant</code>.
// - Else if any entity's status is <code>outOfDate</code>, the overall status is
// <code>outOfDate</code>.
// - Else if any entity's status is <code>nonCompliant</code>, the overall status is
// <code>nonCompliant</code>.
// - Else if any entity's status is <code>unknown</code>, the overall status is
// <code>unknown</code>.
// - Else if any entity's status is <code>notApplicable</code>, the overall status is
// <code>notApplicable</code>.
// - If all the entities are <code>compliant</code>, the overall status is
// <code>compliant</code>.
// - Else if any entity's status is <code>outOfDate</code>, the overall status is
// <code>outOfDate</code>.
// - Else if any entity's status is <code>nonCompliant</code>, the overall status is
// <code>nonCompliant</code>.
// - Else if any entity's status is <code>unknown</code>, the overall status is
// <code>unknown</code>.
// - Else if any entity's status is <code>notApplicable</code>, the overall status is
// <code>notApplicable</code>.
OverallComplianceStatus string `xml:"overallComplianceStatus" json:"overallComplianceStatus"`
// Overall compliance task status of the virtual machine and its virtual
// disks.
@ -2831,7 +2953,6 @@ type PbmServerObjectRef struct {
// The value of <code>key</code> depends
// on the <code>objectType</code>.
//
//
// <table border="1"cellpadding="5">
// <tr><td>`*PbmObjectType**</td><td>*`key value**</td></tr>
// <tr><td>virtualMachine</td><td>_virtual-machine-MOR_</td></tr>
@ -2896,6 +3017,8 @@ func init() {
}
// The parameters of `PbmProfileProfileManager.PbmUpdate`.
//
// This structure may be used only with operations rendered under `/pbm`.
type PbmUpdateRequestType struct {
This types.ManagedObjectReference `xml:"_this" json:"_this"`
// Profile identifier.

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2018-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2018-2024 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.
@ -31,6 +31,7 @@ const (
LibraryItemFileData = "/com/vmware/cis/data"
LibraryItemPath = "/com/vmware/content/library/item"
LibraryItemFilePath = "/com/vmware/content/library/item/file"
LibraryItemStoragePath = "/com/vmware/content/library/item/storage"
LibraryItemUpdateSession = "/com/vmware/content/library/item/update-session"
LibraryItemUpdateSessionFile = "/com/vmware/content/library/item/updatesession/file"
LibraryItemDownloadSession = "/com/vmware/content/library/item/download-session"

View file

@ -0,0 +1,132 @@
/*
Copyright (c) 2024-2024 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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package finder
import (
"context"
"fmt"
"net/url"
"path"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vapi/library"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/types"
)
// PathFinder is used to find the Datastore path of a library.Library, library.Item or library.File.
type PathFinder struct {
m *library.Manager
c *vim25.Client
cache map[string]string
}
// NewPathFinder creates a new PathFinder instance.
func NewPathFinder(m *library.Manager, c *vim25.Client) *PathFinder {
return &PathFinder{
m: m,
c: c,
cache: make(map[string]string),
}
}
// Path returns the absolute datastore path for a Library, Item or File.
// The cache is used by DatastoreName().
func (f *PathFinder) Path(ctx context.Context, r FindResult) (string, error) {
switch l := r.GetResult().(type) {
case library.Library:
id := ""
if len(l.Storage) != 0 {
var err error
id, err = f.datastoreName(ctx, l.Storage[0].DatastoreID)
if err != nil {
return "", err
}
}
return fmt.Sprintf("[%s] contentlib-%s", id, l.ID), nil
case library.Item:
p, err := f.Path(ctx, r.GetParent())
if err != nil {
return "", err
}
return fmt.Sprintf("%s/%s", p, l.ID), nil
case library.File:
return f.getFileItemPath(ctx, r)
default:
return "", fmt.Errorf("unsupported type=%T", l)
}
}
// getFileItemPath returns the absolute datastore path for a library.File
func (f *PathFinder) getFileItemPath(ctx context.Context, r FindResult) (string, error) {
name := r.GetName()
dir, err := f.Path(ctx, r.GetParent())
if err != nil {
return "", err
}
p := path.Join(dir, name)
lib := r.GetParent().GetParent().GetResult().(library.Library)
if len(lib.Storage) == 0 {
return p, nil
}
// storage file name includes a uuid, for example:
// "ubuntu-14.04.6-server-amd64.iso" -> "ubuntu-14.04.6-server-amd64_0653e3f3-b4f4-41fb-9b72-c4102450e3dc.iso"
s, err := f.m.GetLibraryItemStorage(ctx, r.GetParent().GetID(), name)
if err != nil {
return p, err
}
// Currently there can only be 1 storage URI
if len(s) == 0 {
return p, nil
}
uris := s[0].StorageURIs
if len(uris) == 0 {
return p, nil
}
u, err := url.Parse(uris[0])
if err != nil {
return p, err
}
return path.Join(dir, path.Base(u.Path)), nil
}
// datastoreName returns the Datastore.Name for the given id.
func (f *PathFinder) datastoreName(ctx context.Context, id string) (string, error) {
if name, ok := f.cache[id]; ok {
return name, nil
}
obj := types.ManagedObjectReference{
Type: "Datastore",
Value: id,
}
ds := object.NewDatastore(f.c, obj)
name, err := ds.ObjectName(ctx)
if err != nil {
return "", err
}
f.cache[id] = name
return name, nil
}

View file

@ -28,27 +28,28 @@ import (
"github.com/vmware/govmomi/vapi/rest"
)
// StorageBackings for Content Libraries
type StorageBackings struct {
// StorageBacking defines a storage location where content in a library will be stored.
type StorageBacking struct {
DatastoreID string `json:"datastore_id,omitempty"`
Type string `json:"type,omitempty"`
StorageURI string `json:"storage_uri,omitempty"`
}
// Library provides methods to create, read, update, delete, and enumerate libraries.
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"`
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 []StorageBacking `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"`
}
// Subscription info

View file

@ -0,0 +1,53 @@
/*
Copyright (c) 2024-2024 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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package library
import (
"context"
"net/http"
"github.com/vmware/govmomi/vapi/internal"
)
// Storage is an expanded form of library.File that includes details about the
// storage backing for a file in a library item
type Storage struct {
Checksum Checksum `json:"checksum_info,omitempty"`
StorageBacking StorageBacking `json:"storage_backing"`
StorageURIs []string `json:"storage_uris"`
Name string `json:"name"`
Size int64 `json:"size"`
Cached bool `json:"cached"`
Version string `json:"version"`
}
// ListLibraryItemStorage returns a list of all the storage for a library item.
func (c *Manager) ListLibraryItemStorage(ctx context.Context, id string) ([]Storage, error) {
url := c.Resource(internal.LibraryItemStoragePath).WithParam("library_item_id", id)
var res []Storage
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
}
// GetLibraryItemStorage returns the storage for a specific file in a library item.
func (c *Manager) GetLibraryItemStorage(ctx context.Context, id, fileName string) ([]Storage, error) {
url := c.Resource(internal.LibraryItemStoragePath).WithID(id).WithAction("get")
spec := struct {
Name string `json:"file_name"`
}{fileName}
var res []Storage
return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
}

View file

@ -28,7 +28,7 @@ import (
const (
Namespace = "vim25"
Version = "8.0.2.0"
Version = "8.0.3.0"
Path = "/sdk"
)

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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.
@ -2543,6 +2543,26 @@ func CreateCollectorForTasks(ctx context.Context, r soap.RoundTripper, req *type
return resBody.Res, nil
}
type CreateCollectorWithInfoFilterForTasksBody struct {
Req *types.CreateCollectorWithInfoFilterForTasks `xml:"urn:vim25 CreateCollectorWithInfoFilterForTasks,omitempty"`
Res *types.CreateCollectorWithInfoFilterForTasksResponse `xml:"CreateCollectorWithInfoFilterForTasksResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *CreateCollectorWithInfoFilterForTasksBody) Fault() *soap.Fault { return b.Fault_ }
func CreateCollectorWithInfoFilterForTasks(ctx context.Context, r soap.RoundTripper, req *types.CreateCollectorWithInfoFilterForTasks) (*types.CreateCollectorWithInfoFilterForTasksResponse, error) {
var reqBody, resBody CreateCollectorWithInfoFilterForTasksBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type CreateContainerViewBody struct {
Req *types.CreateContainerView `xml:"urn:vim25 CreateContainerView,omitempty"`
Res *types.CreateContainerViewResponse `xml:"CreateContainerViewResponse,omitempty"`
@ -6883,6 +6903,26 @@ func HostProfileResetValidationState(ctx context.Context, r soap.RoundTripper, r
return resBody.Res, nil
}
type HostQueryVirtualDiskUuidBody struct {
Req *types.HostQueryVirtualDiskUuid `xml:"urn:vim25 HostQueryVirtualDiskUuid,omitempty"`
Res *types.HostQueryVirtualDiskUuidResponse `xml:"HostQueryVirtualDiskUuidResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *HostQueryVirtualDiskUuidBody) Fault() *soap.Fault { return b.Fault_ }
func HostQueryVirtualDiskUuid(ctx context.Context, r soap.RoundTripper, req *types.HostQueryVirtualDiskUuid) (*types.HostQueryVirtualDiskUuidResponse, error) {
var reqBody, resBody HostQueryVirtualDiskUuidBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type HostReconcileDatastoreInventory_TaskBody struct {
Req *types.HostReconcileDatastoreInventory_Task `xml:"urn:vim25 HostReconcileDatastoreInventory_Task,omitempty"`
Res *types.HostReconcileDatastoreInventory_TaskResponse `xml:"HostReconcileDatastoreInventory_TaskResponse,omitempty"`
@ -7123,6 +7163,26 @@ func HostSetVStorageObjectControlFlags(ctx context.Context, r soap.RoundTripper,
return resBody.Res, nil
}
type HostSetVirtualDiskUuid_TaskBody struct {
Req *types.HostSetVirtualDiskUuid_Task `xml:"urn:vim25 HostSetVirtualDiskUuid_Task,omitempty"`
Res *types.HostSetVirtualDiskUuid_TaskResponse `xml:"HostSetVirtualDiskUuid_TaskResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *HostSetVirtualDiskUuid_TaskBody) Fault() *soap.Fault { return b.Fault_ }
func HostSetVirtualDiskUuid_Task(ctx context.Context, r soap.RoundTripper, req *types.HostSetVirtualDiskUuid_Task) (*types.HostSetVirtualDiskUuid_TaskResponse, error) {
var reqBody, resBody HostSetVirtualDiskUuid_TaskBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type HostSpecGetUpdatedHostsBody struct {
Req *types.HostSpecGetUpdatedHosts `xml:"urn:vim25 HostSpecGetUpdatedHosts,omitempty"`
Res *types.HostSpecGetUpdatedHostsResponse `xml:"HostSpecGetUpdatedHostsResponse,omitempty"`
@ -8963,6 +9023,26 @@ func MoveVirtualDisk_Task(ctx context.Context, r soap.RoundTripper, req *types.M
return resBody.Res, nil
}
type NotifyAffectedServicesBody struct {
Req *types.NotifyAffectedServices `xml:"urn:vim25 NotifyAffectedServices,omitempty"`
Res *types.NotifyAffectedServicesResponse `xml:"NotifyAffectedServicesResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *NotifyAffectedServicesBody) Fault() *soap.Fault { return b.Fault_ }
func NotifyAffectedServices(ctx context.Context, r soap.RoundTripper, req *types.NotifyAffectedServices) (*types.NotifyAffectedServicesResponse, error) {
var reqBody, resBody NotifyAffectedServicesBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type OpenInventoryViewFolderBody struct {
Req *types.OpenInventoryViewFolder `xml:"urn:vim25 OpenInventoryViewFolder,omitempty"`
Res *types.OpenInventoryViewFolderResponse `xml:"OpenInventoryViewFolderResponse,omitempty"`
@ -9323,6 +9403,26 @@ func PromoteDisks_Task(ctx context.Context, r soap.RoundTripper, req *types.Prom
return resBody.Res, nil
}
type ProvisionServerPrivateKeyBody struct {
Req *types.ProvisionServerPrivateKey `xml:"urn:vim25 ProvisionServerPrivateKey,omitempty"`
Res *types.ProvisionServerPrivateKeyResponse `xml:"ProvisionServerPrivateKeyResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *ProvisionServerPrivateKeyBody) Fault() *soap.Fault { return b.Fault_ }
func ProvisionServerPrivateKey(ctx context.Context, r soap.RoundTripper, req *types.ProvisionServerPrivateKey) (*types.ProvisionServerPrivateKeyResponse, error) {
var reqBody, resBody ProvisionServerPrivateKeyBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type PutUsbScanCodesBody struct {
Req *types.PutUsbScanCodes `xml:"urn:vim25 PutUsbScanCodes,omitempty"`
Res *types.PutUsbScanCodesResponse `xml:"PutUsbScanCodesResponse,omitempty"`
@ -11523,6 +11623,26 @@ func QueryVirtualDiskUuid(ctx context.Context, r soap.RoundTripper, req *types.Q
return resBody.Res, nil
}
type QueryVirtualDiskUuidExBody struct {
Req *types.QueryVirtualDiskUuidEx `xml:"urn:vim25 QueryVirtualDiskUuidEx,omitempty"`
Res *types.QueryVirtualDiskUuidExResponse `xml:"QueryVirtualDiskUuidExResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *QueryVirtualDiskUuidExBody) Fault() *soap.Fault { return b.Fault_ }
func QueryVirtualDiskUuidEx(ctx context.Context, r soap.RoundTripper, req *types.QueryVirtualDiskUuidEx) (*types.QueryVirtualDiskUuidExResponse, error) {
var reqBody, resBody QueryVirtualDiskUuidExBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type QueryVmfsConfigOptionBody struct {
Req *types.QueryVmfsConfigOption `xml:"urn:vim25 QueryVmfsConfigOption,omitempty"`
Res *types.QueryVmfsConfigOptionResponse `xml:"QueryVmfsConfigOptionResponse,omitempty"`
@ -15763,6 +15883,26 @@ func SetVirtualDiskUuid(ctx context.Context, r soap.RoundTripper, req *types.Set
return resBody.Res, nil
}
type SetVirtualDiskUuidEx_TaskBody struct {
Req *types.SetVirtualDiskUuidEx_Task `xml:"urn:vim25 SetVirtualDiskUuidEx_Task,omitempty"`
Res *types.SetVirtualDiskUuidEx_TaskResponse `xml:"SetVirtualDiskUuidEx_TaskResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *SetVirtualDiskUuidEx_TaskBody) Fault() *soap.Fault { return b.Fault_ }
func SetVirtualDiskUuidEx_Task(ctx context.Context, r soap.RoundTripper, req *types.SetVirtualDiskUuidEx_Task) (*types.SetVirtualDiskUuidEx_TaskResponse, error) {
var reqBody, resBody SetVirtualDiskUuidEx_TaskBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type ShrinkVirtualDisk_TaskBody struct {
Req *types.ShrinkVirtualDisk_Task `xml:"urn:vim25 ShrinkVirtualDisk_Task,omitempty"`
Res *types.ShrinkVirtualDisk_TaskResponse `xml:"ShrinkVirtualDisk_TaskResponse,omitempty"`
@ -18943,6 +19083,26 @@ func SetCustomValue(ctx context.Context, r soap.RoundTripper, req *types.SetCust
return resBody.Res, nil
}
type StartDpuFailoverBody struct {
Req *types.StartDpuFailover `xml:"urn:vim25 startDpuFailover,omitempty"`
Res *types.StartDpuFailoverResponse `xml:"startDpuFailoverResponse,omitempty"`
Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func (b *StartDpuFailoverBody) Fault() *soap.Fault { return b.Fault_ }
func StartDpuFailover(ctx context.Context, r soap.RoundTripper, req *types.StartDpuFailover) (*types.StartDpuFailoverResponse, error) {
var reqBody, resBody StartDpuFailoverBody
reqBody.Req = req
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
return nil, err
}
return resBody.Res, nil
}
type UnregisterVApp_TaskBody struct {
Req *types.UnregisterVApp_Task `xml:"urn:vim25 unregisterVApp_Task,omitempty"`
Res *types.UnregisterVApp_TaskResponse `xml:"unregisterVApp_TaskResponse,omitempty"`

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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,
@ -210,7 +210,7 @@ type CustomizationSpecManager struct {
Self types.ManagedObjectReference `json:"self"`
Info []types.CustomizationSpecInfo `json:"info"`
EncryptionKey []byte `json:"encryptionKey"`
EncryptionKey types.ByteSlice `json:"encryptionKey"`
}
func (m CustomizationSpecManager) Reference() types.ManagedObjectReference {

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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,
@ -75,16 +75,19 @@ func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) {
v := reflect.ValueOf(obj)
for _, p := range changes {
rv, ok := t.props[p.Name]
if !ok {
// For now, skip unknown properties allowing PC updates to be triggered
// for partial updates (e.g. extensionList["my.extension"]).
// Ultimately we should support partial updates by assigning the value
// reflectively in assignValue.
continue
var field Field
if !field.FromString(p.Name) {
panic(p.Name + ": invalid property path")
}
assignValue(v, rv, reflect.ValueOf(p.Val))
rv, ok := t.props[field.Path]
if !ok {
panic(field.Path + ": property not found")
}
if field.Key == nil { // Key is only used for notifications
assignValue(v, rv, reflect.ValueOf(p.Val))
}
}
}

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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,
@ -20,6 +20,7 @@ import (
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
"sync"
@ -34,6 +35,9 @@ type typeInfo struct {
// Map property names to field indices.
props map[string][]int
// Use base type for interface indices.
base bool
}
var typeInfoLock sync.RWMutex
@ -62,12 +66,22 @@ func typeInfoForType(tname string) *typeInfo {
return ti
}
func newTypeInfo(typ reflect.Type) *typeInfo {
func baseType(ftyp reflect.Type) reflect.Type {
base := strings.TrimPrefix(ftyp.Name(), "Base")
if kind, ok := types.TypeFunc()(base); ok {
return kind
}
return ftyp
}
func newTypeInfo(typ reflect.Type, base ...bool) *typeInfo {
t := typeInfo{
typ: typ,
props: make(map[string][]int),
}
if len(base) == 1 {
t.base = base[0]
}
t.build(typ, "", []int{})
return &t
@ -155,6 +169,15 @@ func (t *typeInfo) build(typ reflect.Type, fn string, fi []int) {
if ftyp.Kind() == reflect.Struct {
t.build(ftyp, fnc, fic)
}
// Indexed property path may traverse into array element fields.
// When interface, use the base type to index fields.
// For example, BaseVirtualDevice:
// config.hardware.device[4000].deviceInfo.label
if t.base && ftyp.Kind() == reflect.Interface {
base := baseType(ftyp)
t.build(base, fnc, fic)
}
}
}
@ -164,7 +187,14 @@ var nilValue reflect.Value
// slice of field indices. It recurses into the struct until it finds the field
// specified by the indices. It creates new values for pointer types where
// needed.
func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
func assignValue(val reflect.Value, fi []int, pv reflect.Value, field ...string) {
// Indexed property path can only use base types
if val.Kind() == reflect.Interface {
base := baseType(val.Type())
val.Set(reflect.New(base))
val = val.Elem()
}
// Create new value if necessary.
if val.Kind() == reflect.Ptr {
if val.IsNil() {
@ -230,6 +260,43 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
rv.Set(pv)
} else if rt.ConvertibleTo(pt) {
rv.Set(pv.Convert(rt))
} else if rt.Kind() == reflect.Slice {
// Indexed array value
path := field[0]
isInterface := rt.Elem().Kind() == reflect.Interface
if len(path) == 0 {
// Append item (pv) directly to the array, converting to pointer if interface
if isInterface {
npv := reflect.New(pt)
npv.Elem().Set(pv)
pv = npv
pt = pv.Type()
}
} else {
// Construct item to be appended to the array, setting field within to value of pv
var item reflect.Value
if isInterface {
base := baseType(rt.Elem())
item = reflect.New(base)
} else {
item = reflect.New(rt.Elem())
}
field := newTypeInfo(item.Type(), true)
if ix, ok := field.props[path]; ok {
assignValue(item, ix, pv)
}
if rt.Elem().Kind() == reflect.Struct {
pv = item.Elem()
} else {
pv = item
}
pt = pv.Type()
}
rv.Set(reflect.Append(rv, pv))
} else {
panic(fmt.Sprintf("cannot assign %q (%s) to %q (%s)", rt.Name(), rt.Kind(), pt.Name(), pt.Kind()))
}
@ -237,7 +304,7 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
return
}
assignValue(rv, fi, pv)
assignValue(rv, fi, pv, field...)
}
var arrayOfRegexp = regexp.MustCompile("ArrayOf(.*)$")
@ -250,11 +317,14 @@ func (t *typeInfo) LoadFromObjectContent(o types.ObjectContent) (reflect.Value,
assignValue(v, t.self, reflect.ValueOf(o.Obj))
for _, p := range o.PropSet {
rv, ok := t.props[p.Name]
var field Field
field.FromString(p.Name)
rv, ok := t.props[field.Path]
if !ok {
continue
}
assignValue(v, rv, reflect.ValueOf(p.Val))
assignValue(v, rv, reflect.ValueOf(p.Val), field.Item)
}
return v, nil
@ -264,3 +334,70 @@ func IsManagedObjectType(kind string) bool {
_, ok := t[kind]
return ok
}
// Field of a ManagedObject in string form.
type Field struct {
Path string
Key any
Item string
}
func (f *Field) String() string {
if f.Key == nil {
return f.Path
}
var key, item string
switch f.Key.(type) {
case string:
key = fmt.Sprintf("%q", f.Key)
default:
key = fmt.Sprintf("%d", f.Key)
}
if f.Item != "" {
item = "." + f.Item
}
return fmt.Sprintf("%s[%s]%s", f.Path, key, item)
}
func (f *Field) FromString(spec string) bool {
s := strings.SplitN(spec, "[", 2)
f.Path = s[0]
f.Key = nil
f.Item = ""
if len(s) == 1 {
return true
}
parts := strings.SplitN(s[1], "]", 2)
if len(parts) != 2 {
return false
}
ix := strings.Trim(parts[0], `"`)
if ix == parts[0] {
v, err := strconv.ParseInt(ix, 0, 32)
if err != nil {
return false
}
f.Key = int32(v)
} else {
f.Key = ix
}
if parts[1] == "" {
return true
}
if parts[1][0] != '.' {
return false
}
f.Item = parts[1][1:]
return true
}

View file

@ -0,0 +1,67 @@
/*
Copyright (c) 2024-2024 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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
import (
"fmt"
"io"
"math"
"strconv"
"github.com/vmware/govmomi/vim25/xml"
)
// ByteSlice implements vCenter compatibile xml encoding and decoding for a byte slice.
// vCenter encodes each byte of the array in its own xml element, whereas
// Go encodes the entire byte array in a single xml element.
type ByteSlice []byte
// MarshalXML implements xml.Marshaler
func (b ByteSlice) MarshalXML(e *xml.Encoder, field xml.StartElement) error {
start := xml.StartElement{
Name: field.Name,
}
for i := range b {
if err := e.EncodeElement(b[i], start); err != nil {
return err
}
}
return nil
}
// UnmarshalXML implements xml.Unmarshaler
func (b *ByteSlice) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
for {
t, err := d.Token()
if err == io.EOF {
break
}
if c, ok := t.(xml.CharData); ok {
n, err := strconv.ParseInt(string(c), 10, 16)
if err != nil {
return err
}
if n > math.MaxUint8 {
return fmt.Errorf("parsing %q: uint8 overflow", start.Name.Local)
}
*b = append(*b, byte(n))
}
}
return nil
}

View file

@ -0,0 +1,609 @@
/*
Copyright (c) 2024-2024 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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
import (
"fmt"
)
// EnsureDisksHaveControllers ensures that all disks in the provided
// ConfigSpec point to a controller. If no controller exists, LSILogic SCSI
// controllers are added to the ConfigSpec as necessary for the disks.
//
// Please note the following table for the number of controllers of each type
// that are supported as well as how many disks (per controller) each supports:
//
// SATA
// - controllers 4
// - disks 30
//
// SCSI
// - controllers 4
// - disks (non-paravirtual) 16
// - disks (paravirtual, hardware version <14) 16
// - disks (paravirtual, hardware version >=14) 256
//
// NVME
// - controllers 4
// - disks (hardware version <20) 15
// - disks (hardware version >=21) 255
func (cs *VirtualMachineConfigSpec) EnsureDisksHaveControllers(
existingDevices ...BaseVirtualDevice) error {
if cs == nil {
panic("configSpec is nil")
}
var (
disks []*VirtualDisk
newDeviceKey int32
pciController *VirtualPCIController
diskControllers = ensureDiskControllerData{
controllerKeys: map[int32]BaseVirtualController{},
controllerKeysToAttachedDisks: map[int32]int{},
}
)
// Inspect the ConfigSpec
for i := range cs.DeviceChange {
var (
bdc BaseVirtualDeviceConfigSpec
bvd BaseVirtualDevice
dc *VirtualDeviceConfigSpec
d *VirtualDevice
)
if bdc = cs.DeviceChange[i]; bdc == nil {
continue
}
if dc = bdc.GetVirtualDeviceConfigSpec(); dc == nil {
continue
}
if dc.Operation == VirtualDeviceConfigSpecOperationRemove {
// Do not consider devices being removed.
continue
}
bvd = dc.Device
if bvd == nil {
continue
}
if d = bvd.GetVirtualDevice(); d == nil {
continue
}
switch tvd := bvd.(type) {
case *VirtualPCIController:
pciController = tvd
case
// SCSI
*ParaVirtualSCSIController,
*VirtualBusLogicController,
*VirtualLsiLogicController,
*VirtualLsiLogicSASController,
*VirtualSCSIController,
// SATA
*VirtualSATAController,
*VirtualAHCIController,
// NVME
*VirtualNVMEController:
diskControllers.add(bvd)
case *VirtualDisk:
disks = append(disks, tvd)
if controllerKey := d.ControllerKey; controllerKey != 0 {
// If the disk points to a controller key, then increment
// the number of devices attached to that controller.
//
// Please note that at this point it is not yet known if the
// controller key is a *valid* controller.
diskControllers.attach(controllerKey)
}
}
// Keep track of the smallest device key used. Please note, because
// device keys in a ConfigSpec are negative numbers, -200 going to be
// smaller than -1.
if d.Key < newDeviceKey {
newDeviceKey = d.Key
}
}
if len(disks) == 0 {
// If there are no disks, then go ahead and return early.
return nil
}
// Categorize any controllers that already exist.
for i := range existingDevices {
var (
d *VirtualDevice
bvd = existingDevices[i]
)
if bvd == nil {
continue
}
if d = bvd.GetVirtualDevice(); d == nil {
continue
}
switch tvd := bvd.(type) {
case *VirtualPCIController:
pciController = tvd
case
// SCSI
*ParaVirtualSCSIController,
*VirtualBusLogicController,
*VirtualLsiLogicController,
*VirtualLsiLogicSASController,
*VirtualSCSIController,
// SATA
*VirtualSATAController,
*VirtualAHCIController,
// NVME
*VirtualNVMEController:
diskControllers.add(bvd)
case *VirtualDisk:
diskControllers.attach(tvd.ControllerKey)
}
}
// Decrement the newDeviceKey so the next device has a unique key.
newDeviceKey--
if pciController == nil {
// Add a PCI controller if one is not present.
pciController = &VirtualPCIController{
VirtualController: VirtualController{
VirtualDevice: VirtualDevice{
Key: newDeviceKey,
},
},
}
// Decrement the newDeviceKey so the next device has a unique key.
newDeviceKey--
// Add the new PCI controller to the ConfigSpec.
cs.DeviceChange = append(
cs.DeviceChange,
&VirtualDeviceConfigSpec{
Operation: VirtualDeviceConfigSpecOperationAdd,
Device: pciController,
})
}
// Ensure all the recorded controller keys that point to disks are actually
// valid controller keys.
diskControllers.validateAttachments()
for i := range disks {
disk := disks[i]
// If the disk already points to a controller then skip to the next
// disk.
if diskControllers.exists(disk.ControllerKey) {
continue
}
// The disk does not point to a controller, so try to locate one.
if ensureDiskControllerFind(disk, &diskControllers) {
// A controller was located for the disk, so go ahead and skip to
// the next disk.
continue
}
// No controller was located for the disk, so a controller must be
// created.
if err := ensureDiskControllerCreate(
cs,
pciController,
newDeviceKey,
&diskControllers); err != nil {
return err
}
// Point the disk to the new controller.
disk.ControllerKey = newDeviceKey
// Add the controller key to the map that tracks how many disks are
// attached to a given controller.
diskControllers.attach(newDeviceKey)
// Decrement the newDeviceKey so the next device has a unique key.
newDeviceKey--
}
return nil
}
const (
maxSCSIControllers = 4
maxSATAControllers = 4
maxNVMEControllers = 4
maxDisksPerSCSIController = 16
maxDisksPerPVSCSIControllerHWVersion14 = 256 // TODO(akutz)
maxDisksPerSATAController = 30
maxDisksPerNVMEController = 15
maxDisksPerNVMEControllerHWVersion21 = 255 // TODO(akutz)
)
type ensureDiskControllerBusNumbers struct {
zero bool
one bool
two bool
}
func (d ensureDiskControllerBusNumbers) free() int32 {
switch {
case !d.zero:
return 0
case !d.one:
return 1
case !d.two:
return 2
default:
return 3
}
}
func (d *ensureDiskControllerBusNumbers) set(busNumber int32) {
switch busNumber {
case 0:
d.zero = true
case 1:
d.one = true
case 2:
d.two = true
}
}
type ensureDiskControllerData struct {
// TODO(akutz) Use the hardware version when calculating the max disks for
// a given controller type.
// hardwareVersion int
controllerKeys map[int32]BaseVirtualController
controllerKeysToAttachedDisks map[int32]int
// SCSI
scsiBusNumbers ensureDiskControllerBusNumbers
pvSCSIControllerKeys []int32
busLogicSCSIControllerKeys []int32
lsiLogicControllerKeys []int32
lsiLogicSASControllerKeys []int32
scsiControllerKeys []int32
// SATA
sataBusNumbers ensureDiskControllerBusNumbers
sataControllerKeys []int32
ahciControllerKeys []int32
// NVME
nvmeBusNumbers ensureDiskControllerBusNumbers
nvmeControllerKeys []int32
}
func (d ensureDiskControllerData) numSCSIControllers() int {
return len(d.pvSCSIControllerKeys) +
len(d.busLogicSCSIControllerKeys) +
len(d.lsiLogicControllerKeys) +
len(d.lsiLogicSASControllerKeys) +
len(d.scsiControllerKeys)
}
func (d ensureDiskControllerData) numSATAControllers() int {
return len(d.sataControllerKeys) + len(d.ahciControllerKeys)
}
func (d ensureDiskControllerData) numNVMEControllers() int {
return len(d.nvmeControllerKeys)
}
// validateAttachments ensures the attach numbers are correct by removing any
// keys from controllerKeysToAttachedDisks that do not also exist in
// controllerKeys.
func (d ensureDiskControllerData) validateAttachments() {
// Remove any invalid controllers from controllerKeyToNumDiskMap.
for key := range d.controllerKeysToAttachedDisks {
if _, ok := d.controllerKeys[key]; !ok {
delete(d.controllerKeysToAttachedDisks, key)
}
}
}
// exists returns true if a controller with the provided key exists.
func (d ensureDiskControllerData) exists(key int32) bool {
return d.controllerKeys[key] != nil
}
// add records the provided controller in the map that relates keys to
// controllers as well as appends the key to the list of controllers of that
// given type.
func (d *ensureDiskControllerData) add(controller BaseVirtualDevice) {
// Get the controller's device key.
bvc := controller.(BaseVirtualController)
key := bvc.GetVirtualController().Key
busNumber := bvc.GetVirtualController().BusNumber
// Record the controller's device key in the controller key map.
d.controllerKeys[key] = bvc
// Record the controller's device key in the list for that type of
// controller.
switch controller.(type) {
// SCSI
case *ParaVirtualSCSIController:
d.pvSCSIControllerKeys = append(d.pvSCSIControllerKeys, key)
d.scsiBusNumbers.set(busNumber)
case *VirtualBusLogicController:
d.busLogicSCSIControllerKeys = append(d.busLogicSCSIControllerKeys, key)
d.scsiBusNumbers.set(busNumber)
case *VirtualLsiLogicController:
d.lsiLogicControllerKeys = append(d.lsiLogicControllerKeys, key)
d.scsiBusNumbers.set(busNumber)
case *VirtualLsiLogicSASController:
d.lsiLogicSASControllerKeys = append(d.lsiLogicSASControllerKeys, key)
d.scsiBusNumbers.set(busNumber)
case *VirtualSCSIController:
d.scsiControllerKeys = append(d.scsiControllerKeys, key)
d.scsiBusNumbers.set(busNumber)
// SATA
case *VirtualSATAController:
d.sataControllerKeys = append(d.sataControllerKeys, key)
d.sataBusNumbers.set(busNumber)
case *VirtualAHCIController:
d.ahciControllerKeys = append(d.ahciControllerKeys, key)
d.sataBusNumbers.set(busNumber)
// NVME
case *VirtualNVMEController:
d.nvmeControllerKeys = append(d.nvmeControllerKeys, key)
d.nvmeBusNumbers.set(busNumber)
}
}
// attach increments the number of disks attached to the controller identified
// by the provided controller key.
func (d *ensureDiskControllerData) attach(controllerKey int32) {
d.controllerKeysToAttachedDisks[controllerKey]++
}
// hasFreeSlot returns whether or not the controller identified by the provided
// controller key has a free slot to attach a disk.
//
// TODO(akutz) Consider the hardware version when calculating these values.
func (d *ensureDiskControllerData) hasFreeSlot(controllerKey int32) bool {
var maxDisksForType int
switch d.controllerKeys[controllerKey].(type) {
case
// SCSI (paravirtual)
*ParaVirtualSCSIController:
maxDisksForType = maxDisksPerSCSIController
case
// SCSI (non-paravirtual)
*VirtualBusLogicController,
*VirtualLsiLogicController,
*VirtualLsiLogicSASController,
*VirtualSCSIController:
maxDisksForType = maxDisksPerSCSIController
case
// SATA
*VirtualSATAController,
*VirtualAHCIController:
maxDisksForType = maxDisksPerSATAController
case
// NVME
*VirtualNVMEController:
maxDisksForType = maxDisksPerNVMEController
}
return d.controllerKeysToAttachedDisks[controllerKey] < maxDisksForType-1
}
// ensureDiskControllerFind attempts to locate a controller for the provided
// disk.
//
// Please note this function is written to preserve the order in which
// controllers are located by preferring controller types in the order in which
// they are listed in this function. This prevents the following situation:
//
// - A ConfigSpec has three controllers in the following order: PVSCSI-1,
// NVME-1, and PVSCSI-2.
// - The controller PVSCSI-1 is full while NVME-1 and PVSCSI-2 have free
// slots.
// - The *desired* behavior is to look at all, possible PVSCSI controllers
// before moving onto SATA and then finally NVME controllers.
// - If the function iterated over the device list in list-order, then the
// NVME-1 controller would be located first.
// - Instead, this function iterates over each *type* of controller first
// before moving onto the next type.
// - This means that even though NVME-1 has free slots, PVSCSI-2 is checked
// first.
//
// The order of preference is as follows:
//
// * SCSI
// - ParaVirtualSCSIController
// - VirtualBusLogicController
// - VirtualLsiLogicController
// - VirtualLsiLogicSASController
// - VirtualSCSIController
//
// * SATA
// - VirtualSATAController
// - VirtualAHCIController
//
// * NVME
// - VirtualNVMEController
func ensureDiskControllerFind(
disk *VirtualDisk,
diskControllers *ensureDiskControllerData) bool {
return false ||
// SCSI
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.pvSCSIControllerKeys) ||
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.busLogicSCSIControllerKeys) ||
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.lsiLogicControllerKeys) ||
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.lsiLogicSASControllerKeys) ||
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.scsiControllerKeys) ||
// SATA
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.sataControllerKeys) ||
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.ahciControllerKeys) ||
// NVME
ensureDiskControllerFindWith(
disk,
diskControllers,
diskControllers.nvmeControllerKeys)
}
func ensureDiskControllerFindWith(
disk *VirtualDisk,
diskControllers *ensureDiskControllerData,
controllerKeys []int32) bool {
for i := range controllerKeys {
controllerKey := controllerKeys[i]
if diskControllers.hasFreeSlot(controllerKey) {
// If the controller has room for another disk, then use this
// controller for the current disk.
disk.ControllerKey = controllerKey
diskControllers.attach(controllerKey)
return true
}
}
return false
}
func ensureDiskControllerCreate(
configSpec *VirtualMachineConfigSpec,
pciController *VirtualPCIController,
newDeviceKey int32,
diskControllers *ensureDiskControllerData) error {
var controller BaseVirtualDevice
switch {
case diskControllers.numSCSIControllers() < maxSCSIControllers:
// Prefer creating a new SCSI controller.
controller = &ParaVirtualSCSIController{
VirtualSCSIController: VirtualSCSIController{
VirtualController: VirtualController{
VirtualDevice: VirtualDevice{
ControllerKey: pciController.Key,
Key: newDeviceKey,
},
BusNumber: diskControllers.scsiBusNumbers.free(),
},
HotAddRemove: NewBool(true),
SharedBus: VirtualSCSISharingNoSharing,
},
}
case diskControllers.numSATAControllers() < maxSATAControllers:
// If there are no more SCSI controllers, create a SATA
// controller.
controller = &VirtualAHCIController{
VirtualSATAController: VirtualSATAController{
VirtualController: VirtualController{
VirtualDevice: VirtualDevice{
ControllerKey: pciController.Key,
Key: newDeviceKey,
},
BusNumber: diskControllers.sataBusNumbers.free(),
},
},
}
case diskControllers.numNVMEControllers() < maxNVMEControllers:
// If there are no more SATA controllers, create an NVME
// controller.
controller = &VirtualNVMEController{
VirtualController: VirtualController{
VirtualDevice: VirtualDevice{
ControllerKey: pciController.Key,
Key: newDeviceKey,
},
BusNumber: diskControllers.nvmeBusNumbers.free(),
},
SharedBus: string(VirtualNVMEControllerSharingNoSharing),
}
default:
return fmt.Errorf("no controllers available")
}
// Add the new controller to the ConfigSpec.
configSpec.DeviceChange = append(
configSpec.DeviceChange,
&VirtualDeviceConfigSpec{
Operation: VirtualDeviceConfigSpecOperationAdd,
Device: controller,
})
// Record the new controller.
diskControllers.add(controller)
return nil
}

File diff suppressed because it is too large Load diff

View file

@ -25,6 +25,10 @@ import (
// HardwareVersion is a VMX hardware version.
type HardwareVersion uint8
const (
invalidHardwareVersion HardwareVersion = 0
)
const (
VMX3 HardwareVersion = iota + 3
VMX4
@ -59,12 +63,24 @@ const (
MaxValidHardwareVersion = VMX21
)
func (hv HardwareVersion) IsValid() bool {
return hv != vmx5 &&
// IsSupported returns true if the hardware version is known to and supported by
// GoVmomi's generated types.
func (hv HardwareVersion) IsSupported() bool {
return hv.IsValid() &&
hv != vmx5 &&
hv >= MinValidHardwareVersion &&
hv <= MaxValidHardwareVersion
}
// IsValid returns true if the hardware version is not valid.
// Unlike IsSupported, this function returns true as long as the hardware
// version is greater than 0.
// For example, the result of parsing "abc" or "vmx-abc" is an invalid hardware
// version, whereas the result of parsing "vmx-99" is valid, just not supported.
func (hv HardwareVersion) IsValid() bool {
return hv != invalidHardwareVersion
}
func (hv HardwareVersion) String() string {
if hv.IsValid() {
return fmt.Sprintf("vmx-%d", hv)
@ -85,7 +101,10 @@ func (hv *HardwareVersion) UnmarshalText(text []byte) error {
return nil
}
var vmxRe = regexp.MustCompile(`(?i)^vmx-(\d+)$`)
var (
vmxRe = regexp.MustCompile(`(?i)^vmx-(\d+)$`)
vmxNumOnlyRe = regexp.MustCompile(`^(\d+)$`)
)
// MustParseHardwareVersion parses the provided string into a hardware version.
func MustParseHardwareVersion(s string) HardwareVersion {
@ -97,25 +116,35 @@ func MustParseHardwareVersion(s string) HardwareVersion {
}
// ParseHardwareVersion parses the provided string into a hardware version.
// Supported formats include vmx-123 or 123. Please note that the parser will
// only return an error if the supplied version does not match the supported
// formats.
// Once parsed, use the function IsSupported to determine if the hardware
// version falls into the range of versions known to GoVmomi.
func ParseHardwareVersion(s string) (HardwareVersion, error) {
var u uint64
if m := vmxRe.FindStringSubmatch(s); len(m) > 0 {
u, _ = strconv.ParseUint(m[1], 10, 8)
} else {
u, _ = strconv.ParseUint(s, 10, 8)
u, err := strconv.ParseUint(m[1], 10, 8)
if err != nil {
return invalidHardwareVersion, fmt.Errorf(
"failed to parse %s from %q as uint8: %w", m[1], s, err)
}
return HardwareVersion(u), nil
} else if m := vmxNumOnlyRe.FindStringSubmatch(s); len(m) > 0 {
u, err := strconv.ParseUint(m[1], 10, 8)
if err != nil {
return invalidHardwareVersion, fmt.Errorf(
"failed to parse %s as uint8: %w", m[1], err)
}
return HardwareVersion(u), nil
}
v := HardwareVersion(u)
if !v.IsValid() {
return 0, fmt.Errorf("invalid version: %q", s)
}
return v, nil
return invalidHardwareVersion, fmt.Errorf("invalid version: %q", s)
}
var hardwareVersions []HardwareVersion
func init() {
for i := MinValidHardwareVersion; i <= MaxValidHardwareVersion; i++ {
if i.IsValid() {
if i.IsSupported() {
hardwareVersions = append(hardwareVersions, i)
}
}

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2015-2022 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2024 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,
@ -23,6 +23,14 @@ import (
"time"
)
func EnumValuesAsStrings[T ~string](enumValues []T) []string {
stringValues := make([]string, len(enumValues))
for i := range enumValues {
stringValues[i] = string(enumValues[i])
}
return stringValues
}
func NewBool(v bool) *bool {
return &v
}
@ -120,6 +128,7 @@ func (ci VirtualMachineConfigInfo) ToConfigSpec() VirtualMachineConfigSpec {
Flags: &ci.Flags,
ConsolePreferences: ci.ConsolePreferences,
PowerOpInfo: &ci.DefaultPowerOps,
RebootPowerOff: ci.RebootPowerOff,
NumCPUs: ci.Hardware.NumCPU,
VcpuConfig: ci.VcpuConfig,
NumCoresPerSocket: ci.Hardware.NumCoresPerSocket,
@ -129,14 +138,14 @@ func (ci VirtualMachineConfigInfo) ToConfigSpec() VirtualMachineConfigSpec {
CpuHotRemoveEnabled: ci.CpuHotRemoveEnabled,
VirtualICH7MPresent: ci.Hardware.VirtualICH7MPresent,
VirtualSMCPresent: ci.Hardware.VirtualSMCPresent,
DeviceChange: make([]BaseVirtualDeviceConfigSpec, len(ci.Hardware.Device)),
DeviceChange: nil, // See below
CpuAllocation: ci.CpuAllocation,
MemoryAllocation: ci.MemoryAllocation,
LatencySensitivity: ci.LatencySensitivity,
CpuAffinity: ci.CpuAffinity,
MemoryAffinity: ci.MemoryAffinity,
NetworkShaper: ci.NetworkShaper,
CpuFeatureMask: make([]VirtualMachineCpuIdInfoSpec, len(ci.CpuFeatureMask)),
CpuFeatureMask: nil, // See below
ExtraConfig: ci.ExtraConfig,
SwapPlacement: ci.SwapPlacement,
BootOptions: ci.BootOptions,
@ -155,20 +164,21 @@ func (ci VirtualMachineConfigInfo) ToConfigSpec() VirtualMachineConfigSpec {
MigrateEncryption: ci.MigrateEncryption,
FtEncryptionMode: ci.FtEncryptionMode,
SevEnabled: ci.SevEnabled,
PmemFailoverEnabled: ci.PmemFailoverEnabled,
Pmem: ci.Pmem,
NpivWorldWideNameOp: ci.NpivWorldWideNameType,
RebootPowerOff: ci.RebootPowerOff,
MotherboardLayout: ci.Hardware.MotherboardLayout,
ScheduledHardwareUpgradeInfo: ci.ScheduledHardwareUpgradeInfo,
SgxInfo: ci.SgxInfo,
GuestMonitoringModeInfo: ci.GuestMonitoringModeInfo,
PmemFailoverEnabled: ci.PmemFailoverEnabled,
VmxStatsCollectionEnabled: ci.VmxStatsCollectionEnabled,
VmOpNotificationToAppEnabled: ci.VmOpNotificationToAppEnabled,
VmOpNotificationTimeout: ci.VmOpNotificationTimeout,
DeviceSwap: ci.DeviceSwap,
SimultaneousThreads: ci.Hardware.SimultaneousThreads,
Pmem: ci.Pmem,
DeviceGroups: ci.DeviceGroups,
MotherboardLayout: ci.Hardware.MotherboardLayout,
FixedPassthruHotPlugEnabled: ci.FixedPassthruHotPlugEnabled,
MetroFtEnabled: ci.MetroFtEnabled,
MetroFtHostGroup: ci.MetroFtHostGroup,
}
// Unassign the Files field if all of its fields are empty.
@ -210,39 +220,36 @@ func (ci VirtualMachineConfigInfo) ToConfigSpec() VirtualMachineConfigSpec {
cs.PowerOpInfo = nil
}
for i := 0; i < len(cs.CpuFeatureMask); i++ {
cs.CpuFeatureMask[i] = VirtualMachineCpuIdInfoSpec{
ArrayUpdateSpec: ArrayUpdateSpec{
Operation: ArrayUpdateOperationAdd,
},
Info: &HostCpuIdInfo{
// TODO: Does DynamicData need to be copied?
// It is an empty struct...
Level: ci.CpuFeatureMask[i].Level,
Vendor: ci.CpuFeatureMask[i].Vendor,
Eax: ci.CpuFeatureMask[i].Eax,
Ebx: ci.CpuFeatureMask[i].Ebx,
Ecx: ci.CpuFeatureMask[i].Ecx,
Edx: ci.CpuFeatureMask[i].Edx,
},
if l := len(ci.CpuFeatureMask); l > 0 {
cs.CpuFeatureMask = make([]VirtualMachineCpuIdInfoSpec, l)
for i := 0; i < l; i++ {
cs.CpuFeatureMask[i] = VirtualMachineCpuIdInfoSpec{
ArrayUpdateSpec: ArrayUpdateSpec{
Operation: ArrayUpdateOperationAdd,
},
Info: &HostCpuIdInfo{
Level: ci.CpuFeatureMask[i].Level,
Vendor: ci.CpuFeatureMask[i].Vendor,
Eax: ci.CpuFeatureMask[i].Eax,
Ebx: ci.CpuFeatureMask[i].Ebx,
Ecx: ci.CpuFeatureMask[i].Ecx,
Edx: ci.CpuFeatureMask[i].Edx,
},
}
}
}
for i := 0; i < len(cs.DeviceChange); i++ {
cs.DeviceChange[i] = &VirtualDeviceConfigSpec{
// TODO: Does DynamicData need to be copied?
// It is an empty struct...
Operation: VirtualDeviceConfigSpecOperationAdd,
FileOperation: VirtualDeviceConfigSpecFileOperationCreate,
Device: ci.Hardware.Device[i],
// TODO: It is unclear how the profiles associated with the VM or
// its hardware can be reintroduced/persisted in the
// ConfigSpec.
Profile: nil,
// The backing will come from the device.
Backing: nil,
// TODO: Investigate futher.
FilterSpec: nil,
if l := len(ci.Hardware.Device); l > 0 {
cs.DeviceChange = make([]BaseVirtualDeviceConfigSpec, l)
for i := 0; i < l; i++ {
cs.DeviceChange[i] = &VirtualDeviceConfigSpec{
Operation: VirtualDeviceConfigSpecOperationAdd,
FileOperation: VirtualDeviceConfigSpecFileOperationCreate,
Device: ci.Hardware.Device[i],
Profile: nil,
Backing: nil,
FilterSpec: nil,
}
}
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 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.
@ -616,6 +616,28 @@ func init() {
t["BaseDVSFeatureCapability"] = reflect.TypeOf((*DVSFeatureCapability)(nil)).Elem()
}
func (b *DVSFilterSpecConnecteeSpec) GetDVSFilterSpecConnecteeSpec() *DVSFilterSpecConnecteeSpec {
return b
}
type BaseDVSFilterSpecConnecteeSpec interface {
GetDVSFilterSpecConnecteeSpec() *DVSFilterSpecConnecteeSpec
}
func init() {
t["BaseDVSFilterSpecConnecteeSpec"] = reflect.TypeOf((*DVSFilterSpecConnecteeSpec)(nil)).Elem()
}
func (b *DVSFilterSpecVlanSpec) GetDVSFilterSpecVlanSpec() *DVSFilterSpecVlanSpec { return b }
type BaseDVSFilterSpecVlanSpec interface {
GetDVSFilterSpecVlanSpec() *DVSFilterSpecVlanSpec
}
func init() {
t["BaseDVSFilterSpecVlanSpec"] = reflect.TypeOf((*DVSFilterSpecVlanSpec)(nil)).Elem()
}
func (b *DVSHealthCheckCapability) GetDVSHealthCheckCapability() *DVSHealthCheckCapability { return b }
type BaseDVSHealthCheckCapability interface {
@ -1790,6 +1812,16 @@ func init() {
t["BaseIoFilterInfo"] = reflect.TypeOf((*IoFilterInfo)(nil)).Elem()
}
func (b *IoFilterManagerSslTrust) GetIoFilterManagerSslTrust() *IoFilterManagerSslTrust { return b }
type BaseIoFilterManagerSslTrust interface {
GetIoFilterManagerSslTrust() *IoFilterManagerSslTrust
}
func init() {
t["BaseIoFilterManagerSslTrust"] = reflect.TypeOf((*IoFilterManagerSslTrust)(nil)).Elem()
}
func (b *IpAddress) GetIpAddress() *IpAddress { return b }
type BaseIpAddress interface {

File diff suppressed because it is too large Load diff