mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-22 17:35:12 +00:00
- Updated vmware/govmomi godep (Needs for vsan support)
- Fix unmount for vsanDatastore - Add support for vsan datastore
This commit is contained in:
42
vendor/github.com/vmware/govmomi/object/common.go
generated
vendored
42
vendor/github.com/vmware/govmomi/object/common.go
generated
vendored
@@ -19,10 +19,12 @@ package object
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
@@ -33,12 +35,20 @@ var (
|
||||
|
||||
// Common contains the fields and functions common to all objects.
|
||||
type Common struct {
|
||||
InventoryPath string
|
||||
|
||||
c *vim25.Client
|
||||
r types.ManagedObjectReference
|
||||
}
|
||||
|
||||
func (c Common) String() string {
|
||||
return fmt.Sprintf("%v", c.Reference())
|
||||
ref := fmt.Sprintf("%v", c.Reference())
|
||||
|
||||
if c.InventoryPath == "" {
|
||||
return ref
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s @ %s", ref, c.InventoryPath)
|
||||
}
|
||||
|
||||
func NewCommon(c *vim25.Client, r types.ManagedObjectReference) Common {
|
||||
@@ -53,6 +63,36 @@ func (c Common) Client() *vim25.Client {
|
||||
return c.c
|
||||
}
|
||||
|
||||
// Name returns the base name of the InventoryPath field
|
||||
func (c Common) Name() string {
|
||||
if c.InventoryPath == "" {
|
||||
return ""
|
||||
}
|
||||
return path.Base(c.InventoryPath)
|
||||
}
|
||||
|
||||
func (c *Common) SetInventoryPath(p string) {
|
||||
c.InventoryPath = p
|
||||
}
|
||||
|
||||
// ObjectName returns the base name of the InventoryPath field if set,
|
||||
// otherwise fetches the mo.ManagedEntity.Name field via the property collector.
|
||||
func (c Common) ObjectName(ctx context.Context) (string, error) {
|
||||
var o mo.ManagedEntity
|
||||
|
||||
name := c.Name()
|
||||
if name != "" {
|
||||
return name, nil
|
||||
}
|
||||
|
||||
err := c.Properties(ctx, c.Reference(), []string{"name"}, &o)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return o.Name, nil
|
||||
}
|
||||
|
||||
func (c Common) Properties(ctx context.Context, r types.ManagedObjectReference, ps []string, dst interface{}) error {
|
||||
return property.DefaultCollector(c.c).RetrieveOne(ctx, r, ps, dst)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user