repo
stringlengths
5
67
sha
stringlengths
40
40
path
stringlengths
4
234
url
stringlengths
85
339
language
stringclasses
6 values
split
stringclasses
3 values
doc
stringlengths
3
51.2k
sign
stringlengths
5
8.01k
problem
stringlengths
13
51.2k
output
stringlengths
0
3.87M
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
simulator/session_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/session_manager.go#L309-L316
go
train
// postEvent wraps EventManager.PostEvent for internal use, with a lock on the EventManager.
func (c *Context) postEvent(events ...types.BaseEvent)
// postEvent wraps EventManager.PostEvent for internal use, with a lock on the EventManager. func (c *Context) postEvent(events ...types.BaseEvent)
{ m := Map.EventManager() c.WithLock(m, func() { for _, event := range events { m.PostEvent(c, &types.PostEvent{EventToPost: event}) } }) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
simulator/session_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/session_manager.go#L325-L332
go
train
// Put wraps Registry.Put, setting the moref value to include the session key.
func (s *Session) Put(item mo.Reference) mo.Reference
// Put wraps Registry.Put, setting the moref value to include the session key. func (s *Session) Put(item mo.Reference) mo.Reference
{ ref := item.Reference() if ref.Value == "" { ref.Value = fmt.Sprintf("session[%s]%s", s.Key, uuid.New()) } s.Registry.setReference(item, ref) return s.Registry.Put(item) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
simulator/session_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/session_manager.go#L335-L361
go
train
// Get wraps Registry.Get, session-izing singleton objects such as SessionManager and the root PropertyCollector.
func (s *Session) Get(ref types.ManagedObjectReference) mo.Reference
// Get wraps Registry.Get, session-izing singleton objects such as SessionManager and the root PropertyCollector. func (s *Session) Get(ref types.ManagedObjectReference) mo.Reference
{ obj := s.Registry.Get(ref) if obj != nil { return obj } // Return a session "view" of certain singleton objects switch ref.Type { case "SessionManager": // Clone SessionManager so the PropertyCollector can properly report CurrentSession m := *Map.SessionManager() m.CurrentSession = &s.UserSession /...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/file_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/file_manager.go#L66-L83
go
train
// DeleteDatastoreFile deletes the specified file or folder from the datastore.
func (f FileManager) DeleteDatastoreFile(ctx context.Context, name string, dc *Datacenter) (*Task, error)
// DeleteDatastoreFile deletes the specified file or folder from the datastore. func (f FileManager) DeleteDatastoreFile(ctx context.Context, name string, dc *Datacenter) (*Task, error)
{ req := types.DeleteDatastoreFile_Task{ This: f.Reference(), Name: name, } if dc != nil { ref := dc.Reference() req.Datacenter = &ref } res, err := methods.DeleteDatastoreFile_Task(ctx, f.c, &req) if err != nil { return nil, err } return NewTask(f.c, res.Returnval), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/file_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/file_manager.go#L86-L100
go
train
// MakeDirectory creates a folder using the specified name.
func (f FileManager) MakeDirectory(ctx context.Context, name string, dc *Datacenter, createParentDirectories bool) error
// MakeDirectory creates a folder using the specified name. func (f FileManager) MakeDirectory(ctx context.Context, name string, dc *Datacenter, createParentDirectories bool) error
{ req := types.MakeDirectory{ This: f.Reference(), Name: name, CreateParentDirectories: types.NewBool(createParentDirectories), } if dc != nil { ref := dc.Reference() req.Datacenter = &ref } _, err := methods.MakeDirectory(ctx, f.c, &req) return err }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
event/manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/event/manager.go#L152-L172
go
train
// EventCategory returns the category for an event, such as "info" or "error" for example.
func (m Manager) EventCategory(ctx context.Context, event types.BaseEvent) (string, error)
// EventCategory returns the category for an event, such as "info" or "error" for example. func (m Manager) EventCategory(ctx context.Context, event types.BaseEvent) (string, error)
{ // Most of the event details are included in the Event.FullFormattedMessage, but the category // is only available via the EventManager description.eventInfo property. The value of this // property is static, so we fetch and once and cache. eventCategory, err := m.eventCategoryMap(ctx) if err != nil { return...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
event/manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/event/manager.go#L175-L189
go
train
// Get the events from the specified object(s) and optionanlly tail the event stream
func (m Manager) Events(ctx context.Context, objects []types.ManagedObjectReference, pageSize int32, tail bool, force bool, f func(types.ManagedObjectReference, []types.BaseEvent) error, kind ...string) error
// Get the events from the specified object(s) and optionanlly tail the event stream func (m Manager) Events(ctx context.Context, objects []types.ManagedObjectReference, pageSize int32, tail bool, force bool, f func(types.ManagedObjectReference, []types.BaseEvent) error, kind ...string) error
{ // TODO: deprecated this method and add one that uses a single config struct, so we can extend further without breaking the method signature. if len(objects) >= m.maxObjects && !force { return fmt.Errorf("maximum number of objects to monitor (%d) exceeded, refine search", m.maxObjects) } proc := newEventProce...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L178-L193
go
train
// errorStatus maps the given error type to a status code
func errorStatus(err error) uint32
// errorStatus maps the given error type to a status code func errorStatus(err error) uint32
{ if x, ok := err.(*Status); ok { return x.Code } switch { case os.IsNotExist(err): return StatusNoSuchFileOrDir case os.IsExist(err): return StatusFileExists case os.IsPermission(err): return StatusOperationNotPermitted } return StatusGenericError }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L240-L253
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (h *Header) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (h *Header) UnmarshalBinary(data []byte) error
{ buf := bytes.NewBuffer(data) err := binary.Read(buf, binary.LittleEndian, h) if err != nil { return fmt.Errorf("reading hgfs header: %s", err) } if h.Dummy != OpNewHeader { return fmt.Errorf("expected hgfs header with OpNewHeader (%#x), got: %#x", OpNewHeader, h.Dummy) } return nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L263-L301
go
train
// Reply composes a new Packet with the given payload or error
func (r *Packet) Reply(payload interface{}, err error) ([]byte, error)
// Reply composes a new Packet with the given payload or error func (r *Packet) Reply(payload interface{}, err error) ([]byte, error)
{ p := new(Packet) status := uint32(StatusSuccess) if err != nil { status = errorStatus(err) } else { p.Payload, err = MarshalBinary(payload) if err != nil { return nil, err } } p.Header = Header{ Version: HeaderVersion, Dummy: OpNewHeader, PacketSize: headerSize + uint32(len(p.Pay...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L304-L310
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *Packet) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *Packet) MarshalBinary() ([]byte, error)
{ r.Header.PacketSize = packetSize(r) buf, _ := MarshalBinary(r.Header) return append(buf, r.Payload...), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L313-L322
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *Packet) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *Packet) UnmarshalBinary(data []byte) error
{ err := r.Header.UnmarshalBinary(data) if err != nil { return err } r.Payload = data[r.HeaderSize:r.PacketSize] return nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L340-L367
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *RequestCreateSessionV4) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *RequestCreateSessionV4) MarshalBinary() ([]byte, error)
{ buf := new(bytes.Buffer) r.NumCapabilities = uint32(len(r.Capabilities)) fields := []*uint32{ &r.NumCapabilities, &r.MaxPacketSize, &r.Flags, &r.Reserved, } for _, p := range fields { err := binary.Write(buf, binary.LittleEndian, p) if err != nil { return nil, err } } for i := uint32(0); ...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L370-L398
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *RequestCreateSessionV4) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *RequestCreateSessionV4) UnmarshalBinary(data []byte) error
{ buf := bytes.NewBuffer(data) fields := []*uint32{ &r.NumCapabilities, &r.MaxPacketSize, &r.Flags, &r.Reserved, } for _, p := range fields { err := binary.Read(buf, binary.LittleEndian, p) if err != nil { return err } } for i := uint32(0); i < r.NumCapabilities; i++ { var cap Capability ...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L491-L499
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (f *FileName) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (f *FileName) MarshalBinary() ([]byte, error)
{ name := f.Name f.Length = uint32(len(f.Name)) if f.Length == 0 { // field is defined as 'char name[1];', this byte is required for min sizeof() validation name = "\x00" } return MarshalBinary(&f.Length, name) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L502-L510
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (f *FileName) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (f *FileName) UnmarshalBinary(data []byte) error
{ buf := bytes.NewBuffer(data) _ = binary.Read(buf, binary.LittleEndian, &f.Length) f.Name = string(buf.Next(int(f.Length))) return nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L515-L524
go
train
// FromString converts name to a FileName
func (f *FileName) FromString(name string)
// FromString converts name to a FileName func (f *FileName) FromString(name string)
{ name = strings.TrimPrefix(name, "/") cp := strings.Split(name, "/") cp = append([]string{serverPolicyRootShareName}, cp...) f.Name = strings.Join(cp, "\x00") f.Length = uint32(len(f.Name)) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L527-L537
go
train
// Path converts FileName to a string
func (f *FileName) Path() string
// Path converts FileName to a string func (f *FileName) Path() string
{ cp := strings.Split(f.Name, "\x00") if len(cp) == 0 || cp[0] != serverPolicyRootShareName { return "" // TODO: not happening until if/when we handle Windows shares } cp[0] = "" return strings.Join(cp, "/") }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L549-L557
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (f *FileNameV3) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (f *FileNameV3) MarshalBinary() ([]byte, error)
{ name := f.Name f.Length = uint32(len(f.Name)) if f.Length == 0 { // field is defined as 'char name[1];', this byte is required for min sizeof() validation name = "\x00" } return MarshalBinary(&f.Length, &f.Flags, &f.CaseType, &f.ID, name) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L560-L576
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (f *FileNameV3) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (f *FileNameV3) UnmarshalBinary(data []byte) error
{ buf := bytes.NewBuffer(data) fields := []interface{}{ &f.Length, &f.Flags, &f.CaseType, &f.ID, } for _, p := range fields { if err := binary.Read(buf, binary.LittleEndian, p); err != nil { return err } } f.Name = string(buf.Next(int(f.Length))) return nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L579-L584
go
train
// FromString converts name to a FileNameV3
func (f *FileNameV3) FromString(name string)
// FromString converts name to a FileNameV3 func (f *FileNameV3) FromString(name string)
{ p := new(FileName) p.FromString(name) f.Name = p.Name f.Length = p.Length }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L587-L589
go
train
// Path converts FileNameV3 to a string
func (f *FileNameV3) Path() string
// Path converts FileNameV3 to a string func (f *FileNameV3) Path() string
{ return (&FileName{Name: f.Name, Length: f.Length}).Path() }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L630-L632
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *RequestGetattrV2) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *RequestGetattrV2) MarshalBinary() ([]byte, error)
{ return MarshalBinary(&r.Request, &r.AttrHint, &r.Handle, &r.FileName) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L635-L637
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *RequestGetattrV2) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *RequestGetattrV2) UnmarshalBinary(data []byte) error
{ return UnmarshalBinary(data, &r.Request, &r.AttrHint, &r.Handle, &r.FileName) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L647-L649
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *ReplyGetattrV2) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *ReplyGetattrV2) MarshalBinary() ([]byte, error)
{ return MarshalBinary(&r.Reply, &r.Attr, &r.SymlinkTarget) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L652-L654
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *ReplyGetattrV2) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *ReplyGetattrV2) UnmarshalBinary(data []byte) error
{ return UnmarshalBinary(data, &r.Reply, &r.Attr, &r.SymlinkTarget) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L666-L668
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *RequestSetattrV2) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *RequestSetattrV2) MarshalBinary() ([]byte, error)
{ return MarshalBinary(&r.Request, &r.Hints, &r.Attr, &r.Handle, &r.FileName) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L671-L673
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *RequestSetattrV2) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *RequestSetattrV2) UnmarshalBinary(data []byte) error
{ return UnmarshalBinary(data, &r.Request, &r.Hints, &r.Attr, &r.Handle, &r.FileName) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L714-L716
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *RequestOpen) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *RequestOpen) MarshalBinary() ([]byte, error)
{ return MarshalBinary(&r.Request, &r.OpenMode, &r.OpenFlags, r.Permissions, &r.FileName) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L719-L721
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *RequestOpen) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *RequestOpen) UnmarshalBinary(data []byte) error
{ return UnmarshalBinary(data, &r.Request, &r.OpenMode, &r.OpenFlags, &r.Permissions, &r.FileName) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L770-L775
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *RequestOpenV3) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *RequestOpenV3) MarshalBinary() ([]byte, error)
{ return MarshalBinary(&r.Mask, &r.OpenMode, &r.OpenFlags, &r.SpecialPerms, &r.OwnerPerms, &r.GroupPerms, &r.OtherPerms, &r.AttrFlags, &r.AllocationSize, &r.DesiredAccess, &r.ShareAccess, &r.DesiredLock, &r.Reserved1, &r.Reserved2, &r.FileName) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L809-L811
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *ReplyReadV3) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *ReplyReadV3) MarshalBinary() ([]byte, error)
{ return MarshalBinary(&r.ActualSize, &r.Reserved, r.Payload) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L814-L816
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *ReplyReadV3) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *ReplyReadV3) UnmarshalBinary(data []byte) error
{ return UnmarshalBinary(data, &r.ActualSize, &r.Reserved, &r.Payload) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L834-L836
go
train
// MarshalBinary implements the encoding.BinaryMarshaler interface
func (r *RequestWriteV3) MarshalBinary() ([]byte, error)
// MarshalBinary implements the encoding.BinaryMarshaler interface func (r *RequestWriteV3) MarshalBinary() ([]byte, error)
{ return MarshalBinary(&r.Handle, &r.WriteFlags, &r.Offset, &r.RequiredSize, &r.Reserved, r.Payload) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
toolbox/hgfs/protocol.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L839-L841
go
train
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
func (r *RequestWriteV3) UnmarshalBinary(data []byte) error
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface func (r *RequestWriteV3) UnmarshalBinary(data []byte) error
{ return UnmarshalBinary(data, &r.Handle, &r.WriteFlags, &r.Offset, &r.RequiredSize, &r.Reserved, &r.Payload) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
govc/vm/rdm/attach.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/vm/rdm/attach.go#L64-L149
go
train
//This piece of code was developed mainly thanks to the project govmax on github.com //This file in particular https://github.com/codedellemc/govmax/blob/master/api/v1/vmomi.go
func (cmd *attach) Run(ctx context.Context, f *flag.FlagSet) error
//This piece of code was developed mainly thanks to the project govmax on github.com //This file in particular https://github.com/codedellemc/govmax/blob/master/api/v1/vmomi.go func (cmd *attach) Run(ctx context.Context, f *flag.FlagSet) error
{ vm, err := cmd.VirtualMachine() if err != nil { return err } if vm == nil { return flag.ErrHelp } devices, err := vm.Device(ctx) if err != nil { return err } controller, err := devices.FindSCSIController("") if err != nil { return err } vmConfigOptions, err := vm.QueryConfigTarget(ctx) if er...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
sts/simulator/simulator.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/simulator/simulator.go#L34-L46
go
train
// New creates an STS simulator and configures the simulator endpoint in the given settings. // The path returned is that of the settings "config.vpxd.sso.sts.uri" property.
func New(u *url.URL, settings []vim.BaseOptionValue) (string, http.Handler)
// New creates an STS simulator and configures the simulator endpoint in the given settings. // The path returned is that of the settings "config.vpxd.sso.sts.uri" property. func New(u *url.URL, settings []vim.BaseOptionValue) (string, http.Handler)
{ for i := range settings { setting := settings[i].GetOptionValue() if setting.Key == "config.vpxd.sso.sts.uri" { endpoint, _ := url.Parse(setting.Value.(string)) endpoint.Host = u.Host setting.Value = endpoint.String() settings[i] = setting return endpoint.Path, new(handler) } } return "", nil...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
sts/simulator/simulator.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/simulator/simulator.go#L51-L91
go
train
// ServeHTTP handles STS requests.
func (s *handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
// ServeHTTP handles STS requests. func (s *handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
{ action := r.Header.Get("SOAPAction") env := soap.Envelope{} now := time.Now() lifetime := &internal.Lifetime{ Created: now.Format(internal.Time), Expires: now.Add(5 * time.Minute).Format(internal.Time), } switch path.Base(action) { case "Issue": body := internal.RequestSecurityTokenBody{ Res: &inter...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L259-L342
go
train
// WaitForNetIP waits for the VM guest.net property to report an IP address for all VM NICs. // Only consider IPv4 addresses if the v4 param is true. // By default, wait for all NICs to get an IP address, unless 1 or more device is given. // A device can be specified by the MAC address or the device name, e.g. "etherne...
func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...string) (map[string][]string, error)
// WaitForNetIP waits for the VM guest.net property to report an IP address for all VM NICs. // Only consider IPv4 addresses if the v4 param is true. // By default, wait for all NICs to get an IP address, unless 1 or more device is given. // A device can be specified by the MAC address or the device name, e.g. "etherne...
{ macs := make(map[string][]string) eths := make(map[string]string) p := property.DefaultCollector(v.c) // Wait for all NICs to have a MacAddress, which may not be generated yet. err := property.Wait(ctx, p, v.Reference(), []string{"config.hardware.device"}, func(pc []types.PropertyChange) bool { for _, c := ...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L345-L364
go
train
// Device returns the VirtualMachine's config.hardware.device property.
func (v VirtualMachine) Device(ctx context.Context) (VirtualDeviceList, error)
// Device returns the VirtualMachine's config.hardware.device property. func (v VirtualMachine) Device(ctx context.Context) (VirtualDeviceList, error)
{ var o mo.VirtualMachine err := v.Properties(ctx, v.Reference(), []string{"config.hardware.device", "summary.runtime.connectionState"}, &o) if err != nil { return nil, err } // Quoting the SDK doc: // The virtual machine configuration is not guaranteed to be available. // For example, the configuration...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L435-L437
go
train
// AddDevice adds the given devices to the VirtualMachine
func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
// AddDevice adds the given devices to the VirtualMachine func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
{ return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationAdd, types.VirtualDeviceConfigSpecFileOperationCreate, device...) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L440-L442
go
train
// EditDevice edits the given (existing) devices on the VirtualMachine
func (v VirtualMachine) EditDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
// EditDevice edits the given (existing) devices on the VirtualMachine func (v VirtualMachine) EditDevice(ctx context.Context, device ...types.BaseVirtualDevice) error
{ return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationEdit, types.VirtualDeviceConfigSpecFileOperationReplace, device...) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L445-L451
go
train
// RemoveDevice removes the given devices on the VirtualMachine
func (v VirtualMachine) RemoveDevice(ctx context.Context, keepFiles bool, device ...types.BaseVirtualDevice) error
// RemoveDevice removes the given devices on the VirtualMachine func (v VirtualMachine) RemoveDevice(ctx context.Context, keepFiles bool, device ...types.BaseVirtualDevice) error
{ fop := types.VirtualDeviceConfigSpecFileOperationDestroy if keepFiles { fop = "" } return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationRemove, fop, device...) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L454-L463
go
train
// BootOptions returns the VirtualMachine's config.bootOptions property.
func (v VirtualMachine) BootOptions(ctx context.Context) (*types.VirtualMachineBootOptions, error)
// BootOptions returns the VirtualMachine's config.bootOptions property. func (v VirtualMachine) BootOptions(ctx context.Context) (*types.VirtualMachineBootOptions, error)
{ var o mo.VirtualMachine err := v.Properties(ctx, v.Reference(), []string{"config.bootOptions"}, &o) if err != nil { return nil, err } return o.Config.BootOptions, nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L466-L477
go
train
// SetBootOptions reconfigures the VirtualMachine with the given options.
func (v VirtualMachine) SetBootOptions(ctx context.Context, options *types.VirtualMachineBootOptions) error
// SetBootOptions reconfigures the VirtualMachine with the given options. func (v VirtualMachine) SetBootOptions(ctx context.Context, options *types.VirtualMachineBootOptions) error
{ spec := types.VirtualMachineConfigSpec{} spec.BootOptions = options task, err := v.Reconfigure(ctx, spec) if err != nil { return err } return task.Wait(ctx) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L480-L493
go
train
// Answer answers a pending question.
func (v VirtualMachine) Answer(ctx context.Context, id, answer string) error
// Answer answers a pending question. func (v VirtualMachine) Answer(ctx context.Context, id, answer string) error
{ req := types.AnswerVM{ This: v.Reference(), QuestionId: id, AnswerChoice: answer, } _, err := methods.AnswerVM(ctx, v.c, &req) if err != nil { return err } return nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L510-L525
go
train
// CreateSnapshot creates a new snapshot of a virtual machine.
func (v VirtualMachine) CreateSnapshot(ctx context.Context, name string, description string, memory bool, quiesce bool) (*Task, error)
// CreateSnapshot creates a new snapshot of a virtual machine. func (v VirtualMachine) CreateSnapshot(ctx context.Context, name string, description string, memory bool, quiesce bool) (*Task, error)
{ req := types.CreateSnapshot_Task{ This: v.Reference(), Name: name, Description: description, Memory: memory, Quiesce: quiesce, } res, err := methods.CreateSnapshot_Task(ctx, v.c, &req) if err != nil { return nil, err } return NewTask(v.c, res.Returnval), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L528-L540
go
train
// RemoveAllSnapshot removes all snapshots of a virtual machine
func (v VirtualMachine) RemoveAllSnapshot(ctx context.Context, consolidate *bool) (*Task, error)
// RemoveAllSnapshot removes all snapshots of a virtual machine func (v VirtualMachine) RemoveAllSnapshot(ctx context.Context, consolidate *bool) (*Task, error)
{ req := types.RemoveAllSnapshots_Task{ This: v.Reference(), Consolidate: consolidate, } res, err := methods.RemoveAllSnapshots_Task(ctx, v.c, &req) if err != nil { return nil, err } return NewTask(v.c, res.Returnval), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L567-L591
go
train
// FindSnapshot supports snapshot lookup by name, where name can be: // 1) snapshot ManagedObjectReference.Value (unique) // 2) snapshot name (may not be unique) // 3) snapshot tree path (may not be unique)
func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (*types.ManagedObjectReference, error)
// FindSnapshot supports snapshot lookup by name, where name can be: // 1) snapshot ManagedObjectReference.Value (unique) // 2) snapshot name (may not be unique) // 3) snapshot tree path (may not be unique) func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (*types.ManagedObjectReference, error)
{ var o mo.VirtualMachine err := v.Properties(ctx, v.Reference(), []string{"snapshot"}, &o) if err != nil { return nil, err } if o.Snapshot == nil || len(o.Snapshot.RootSnapshotList) == 0 { return nil, errors.New("no snapshots for this VM") } m := make(snapshotMap) m.add("", o.Snapshot.RootSnapshotList)...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L594-L612
go
train
// RemoveSnapshot removes a named snapshot
func (v VirtualMachine) RemoveSnapshot(ctx context.Context, name string, removeChildren bool, consolidate *bool) (*Task, error)
// RemoveSnapshot removes a named snapshot func (v VirtualMachine) RemoveSnapshot(ctx context.Context, name string, removeChildren bool, consolidate *bool) (*Task, error)
{ snapshot, err := v.FindSnapshot(ctx, name) if err != nil { return nil, err } req := types.RemoveSnapshot_Task{ This: snapshot.Reference(), RemoveChildren: removeChildren, Consolidate: consolidate, } res, err := methods.RemoveSnapshot_Task(ctx, v.c, &req) if err != nil { return nil, er...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L615-L627
go
train
// RevertToCurrentSnapshot reverts to the current snapshot
func (v VirtualMachine) RevertToCurrentSnapshot(ctx context.Context, suppressPowerOn bool) (*Task, error)
// RevertToCurrentSnapshot reverts to the current snapshot func (v VirtualMachine) RevertToCurrentSnapshot(ctx context.Context, suppressPowerOn bool) (*Task, error)
{ req := types.RevertToCurrentSnapshot_Task{ This: v.Reference(), SuppressPowerOn: types.NewBool(suppressPowerOn), } res, err := methods.RevertToCurrentSnapshot_Task(ctx, v.c, &req) if err != nil { return nil, err } return NewTask(v.c, res.Returnval), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L630-L647
go
train
// RevertToSnapshot reverts to a named snapshot
func (v VirtualMachine) RevertToSnapshot(ctx context.Context, name string, suppressPowerOn bool) (*Task, error)
// RevertToSnapshot reverts to a named snapshot func (v VirtualMachine) RevertToSnapshot(ctx context.Context, name string, suppressPowerOn bool) (*Task, error)
{ snapshot, err := v.FindSnapshot(ctx, name) if err != nil { return nil, err } req := types.RevertToSnapshot_Task{ This: snapshot.Reference(), SuppressPowerOn: types.NewBool(suppressPowerOn), } res, err := methods.RevertToSnapshot_Task(ctx, v.c, &req) if err != nil { return nil, err } re...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L650-L659
go
train
// IsToolsRunning returns true if VMware Tools is currently running in the guest OS, and false otherwise.
func (v VirtualMachine) IsToolsRunning(ctx context.Context) (bool, error)
// IsToolsRunning returns true if VMware Tools is currently running in the guest OS, and false otherwise. func (v VirtualMachine) IsToolsRunning(ctx context.Context) (bool, error)
{ var o mo.VirtualMachine err := v.Properties(ctx, v.Reference(), []string{"guest.toolsRunningStatus"}, &o) if err != nil { return false, err } return o.Guest.ToolsRunningStatus == string(types.VirtualMachineToolsRunningStatusGuestToolsRunning), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L662-L682
go
train
// Wait for the VirtualMachine to change to the desired power state.
func (v VirtualMachine) WaitForPowerState(ctx context.Context, state types.VirtualMachinePowerState) error
// Wait for the VirtualMachine to change to the desired power state. func (v VirtualMachine) WaitForPowerState(ctx context.Context, state types.VirtualMachinePowerState) error
{ p := property.DefaultCollector(v.c) err := property.Wait(ctx, p, v.Reference(), []string{PropRuntimePowerState}, func(pc []types.PropertyChange) bool { for _, c := range pc { if c.Name != PropRuntimePowerState { continue } if c.Val == nil { continue } ps := c.Val.(types.VirtualMachinePowe...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L751-L769
go
train
// QueryEnvironmentBrowser is a helper to get the environmentBrowser property.
func (v VirtualMachine) QueryConfigTarget(ctx context.Context) (*types.ConfigTarget, error)
// QueryEnvironmentBrowser is a helper to get the environmentBrowser property. func (v VirtualMachine) QueryConfigTarget(ctx context.Context) (*types.ConfigTarget, error)
{ var vm mo.VirtualMachine err := v.Properties(ctx, v.Reference(), []string{"environmentBrowser"}, &vm) if err != nil { return nil, err } req := types.QueryConfigTarget{ This: vm.EnvironmentBrowser, } res, err := methods.QueryConfigTarget(ctx, v.Client(), &req) if err != nil { return nil, err } ret...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/virtual_machine.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L832-L841
go
train
// UUID is a helper to get the UUID of the VirtualMachine managed object. // This method returns an empty string if an error occurs when retrieving UUID from the VirtualMachine object.
func (v VirtualMachine) UUID(ctx context.Context) string
// UUID is a helper to get the UUID of the VirtualMachine managed object. // This method returns an empty string if an error occurs when retrieving UUID from the VirtualMachine object. func (v VirtualMachine) UUID(ctx context.Context) string
{ var o mo.VirtualMachine err := v.Properties(ctx, v.Reference(), []string{"config.uuid"}, &o) if err != nil { return "" } return o.Config.Uuid }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vim25/xml/extras.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/extras.go#L51-L99
go
train
// Return a string for the specified reflect.Type. Panic if unknown.
func typeToString(typ reflect.Type) string
// Return a string for the specified reflect.Type. Panic if unknown. func typeToString(typ reflect.Type) string
{ switch typ.Kind() { case reflect.Bool: return "xsd:boolean" case reflect.Int8: return "xsd:byte" case reflect.Int16: return "xsd:short" case reflect.Int32: return "xsd:int" case reflect.Int, reflect.Int64: return "xsd:long" case reflect.Uint8: return "xsd:unsignedByte" case reflect.Uint16: retu...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
simulator/container.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/container.go#L35-L78
go
train
// inspect applies container network settings to vm.Guest properties.
func (c *container) inspect(vm *VirtualMachine) error
// inspect applies container network settings to vm.Guest properties. func (c *container) inspect(vm *VirtualMachine) error
{ if c.id == "" { return nil } var objects []struct { NetworkSettings struct { Gateway string IPAddress string IPPrefixLen int MacAddress string } } cmd := exec.Command("docker", "inspect", c.id) out, err := cmd.Output() if err != nil { return err } if err = json.NewDecoder(bytes....
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
simulator/container.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/container.go#L81-L128
go
train
// start runs the container if specified by the RUN.container extraConfig property.
func (c *container) start(vm *VirtualMachine)
// start runs the container if specified by the RUN.container extraConfig property. func (c *container) start(vm *VirtualMachine)
{ if c.id != "" { start := "start" if vm.Runtime.PowerState == types.VirtualMachinePowerStateSuspended { start = "unpause" } cmd := exec.Command("docker", start, c.id) err := cmd.Run() if err != nil { log.Printf("%s %s: %s", vm.Name, cmd.Args, err) } return } var args []string for _, opt :=...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
simulator/container.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/container.go#L131-L141
go
train
// stop the container (if any) for the given vm.
func (c *container) stop(vm *VirtualMachine)
// stop the container (if any) for the given vm. func (c *container) stop(vm *VirtualMachine)
{ if c.id == "" { return } cmd := exec.Command("docker", "stop", c.id) err := cmd.Run() if err != nil { log.Printf("%s %s: %s", vm.Name, cmd.Args, err) } }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L78-L99
go
train
// NewClient creates a new client from a URL. The client authenticates with the // server with username/password before returning if the URL contains user information.
func NewClient(ctx context.Context, u *url.URL, insecure bool) (*Client, error)
// NewClient creates a new client from a URL. The client authenticates with the // server with username/password before returning if the URL contains user information. func NewClient(ctx context.Context, u *url.URL, insecure bool) (*Client, error)
{ soapClient := soap.NewClient(u, insecure) vimClient, err := vim25.NewClient(ctx, soapClient) if err != nil { return nil, err } c := &Client{ Client: vimClient, SessionManager: session.NewManager(vimClient), } // Only login if the URL contains user information. if u.User != nil { err = c.Log...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L102-L104
go
train
// Login dispatches to the SessionManager.
func (c *Client) Login(ctx context.Context, u *url.Userinfo) error
// Login dispatches to the SessionManager. func (c *Client) Login(ctx context.Context, u *url.Userinfo) error
{ return c.SessionManager.Login(ctx, u) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L107-L111
go
train
// Logout dispatches to the SessionManager.
func (c *Client) Logout(ctx context.Context) error
// Logout dispatches to the SessionManager. func (c *Client) Logout(ctx context.Context) error
{ // Close any idle connections after logging out. defer c.Client.CloseIdleConnections() return c.SessionManager.Logout(ctx) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L119-L121
go
train
// RetrieveOne dispatches to the Retrieve function on the default property collector.
func (c *Client) RetrieveOne(ctx context.Context, obj types.ManagedObjectReference, p []string, dst interface{}) error
// RetrieveOne dispatches to the Retrieve function on the default property collector. func (c *Client) RetrieveOne(ctx context.Context, obj types.ManagedObjectReference, p []string, dst interface{}) error
{ return c.PropertyCollector().RetrieveOne(ctx, obj, p, dst) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L124-L126
go
train
// Retrieve dispatches to the Retrieve function on the default property collector.
func (c *Client) Retrieve(ctx context.Context, objs []types.ManagedObjectReference, p []string, dst interface{}) error
// Retrieve dispatches to the Retrieve function on the default property collector. func (c *Client) Retrieve(ctx context.Context, objs []types.ManagedObjectReference, p []string, dst interface{}) error
{ return c.PropertyCollector().Retrieve(ctx, objs, p, dst) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L129-L131
go
train
// Wait dispatches to property.Wait.
func (c *Client) Wait(ctx context.Context, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error
// Wait dispatches to property.Wait. func (c *Client) Wait(ctx context.Context, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error
{ return property.Wait(ctx, c.PropertyCollector(), obj, ps, f) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
sts/client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/client.go#L47-L63
go
train
// NewClient returns a client targeting the STS API endpoint. // The Client.URL will be set to that of the Lookup Service's endpoint registration, // as the SSO endpoint can be external to vCenter. If the Lookup Service is not available, // URL defaults to Path on the vim25.Client.URL.Host.
func NewClient(ctx context.Context, c *vim25.Client) (*Client, error)
// NewClient returns a client targeting the STS API endpoint. // The Client.URL will be set to that of the Lookup Service's endpoint registration, // as the SSO endpoint can be external to vCenter. If the Lookup Service is not available, // URL defaults to Path on the vim25.Client.URL.Host. func NewClient(ctx context....
{ filter := &types.LookupServiceRegistrationFilter{ ServiceType: &types.LookupServiceRegistrationServiceType{ Product: "com.vmware.cis", Type: "sso:sts", }, EndpointType: &types.LookupServiceRegistrationEndpointType{ Protocol: "wsTrust", Type: "com.vmware.cis.cs.identity.sso", }, } url :...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
sts/client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/client.go#L145-L177
go
train
// Issue is used to request a security token. // The returned Signer can be used to sign SOAP requests, such as the SessionManager LoginByToken method and the RequestSecurityToken method itself. // One of TokenRequest Certificate or Userinfo is required, with Certificate taking precedence. // When Certificate is set, a...
func (c *Client) Issue(ctx context.Context, req TokenRequest) (*Signer, error)
// Issue is used to request a security token. // The returned Signer can be used to sign SOAP requests, such as the SessionManager LoginByToken method and the RequestSecurityToken method itself. // One of TokenRequest Certificate or Userinfo is required, with Certificate taking precedence. // When Certificate is set, a...
{ s := &Signer{ Certificate: req.Certificate, keyID: req.KeyID, Token: req.Token, user: req.Userinfo, } rst, err := c.newRequest(req, "Issue", s) if err != nil { return nil, err } if req.ActAs { rst.ActAs = &internal.Target{ Token: req.Token, } } header := soap.Header{ ...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
sts/client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/client.go#L180-L209
go
train
// Renew is used to request a security token renewal.
func (c *Client) Renew(ctx context.Context, req TokenRequest) (*Signer, error)
// Renew is used to request a security token renewal. func (c *Client) Renew(ctx context.Context, req TokenRequest) (*Signer, error)
{ s := &Signer{ Certificate: req.Certificate, } rst, err := c.newRequest(req, "Renew", s) if err != nil { return nil, err } if req.Token == "" { return nil, errors.New("TokenRequest Token is required") } rst.RenewTarget = &internal.Target{Token: req.Token} header := soap.Header{ Security: s, Act...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/host_vsan_internal_system.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_vsan_internal_system.go#L41-L55
go
train
// QueryVsanObjectUuidsByFilter returns vSAN DOM object uuids by filter.
func (m HostVsanInternalSystem) QueryVsanObjectUuidsByFilter(ctx context.Context, uuids []string, limit int32, version int32) ([]string, error)
// QueryVsanObjectUuidsByFilter returns vSAN DOM object uuids by filter. func (m HostVsanInternalSystem) QueryVsanObjectUuidsByFilter(ctx context.Context, uuids []string, limit int32, version int32) ([]string, error)
{ req := types.QueryVsanObjectUuidsByFilter{ This: m.Reference(), Uuids: uuids, Limit: &limit, Version: version, } res, err := methods.QueryVsanObjectUuidsByFilter(ctx, m.Client(), &req) if err != nil { return nil, err } return res.Returnval, nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/host_vsan_internal_system.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_vsan_internal_system.go#L82-L98
go
train
// GetVsanObjExtAttrs is internal and intended for troubleshooting/debugging situations in the field. // WARNING: This API can be slow because we do IOs (reads) to all the objects.
func (m HostVsanInternalSystem) GetVsanObjExtAttrs(ctx context.Context, uuids []string) (map[string]VsanObjExtAttrs, error)
// GetVsanObjExtAttrs is internal and intended for troubleshooting/debugging situations in the field. // WARNING: This API can be slow because we do IOs (reads) to all the objects. func (m HostVsanInternalSystem) GetVsanObjExtAttrs(ctx context.Context, uuids []string) (map[string]VsanObjExtAttrs, error)
{ req := types.GetVsanObjExtAttrs{ This: m.Reference(), Uuids: uuids, } res, err := methods.GetVsanObjExtAttrs(ctx, m.Client(), &req) if err != nil { return nil, err } var attrs map[string]VsanObjExtAttrs err = json.Unmarshal([]byte(res.Returnval), &attrs) return attrs, err }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/host_vsan_internal_system.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_vsan_internal_system.go#L104-L117
go
train
// DeleteVsanObjects is internal and intended for troubleshooting/debugging only. // WARNING: This API can be slow because we do IOs to all the objects. // DOM won't allow access to objects which have lost quorum. Such objects can be deleted with the optional "force" flag. // These objects may however re-appear with qu...
func (m HostVsanInternalSystem) DeleteVsanObjects(ctx context.Context, uuids []string, force *bool) ([]types.HostVsanInternalSystemDeleteVsanObjectsResult, error)
// DeleteVsanObjects is internal and intended for troubleshooting/debugging only. // WARNING: This API can be slow because we do IOs to all the objects. // DOM won't allow access to objects which have lost quorum. Such objects can be deleted with the optional "force" flag. // These objects may however re-appear with qu...
{ req := types.DeleteVsanObjects{ This: m.Reference(), Uuids: uuids, Force: force, } res, err := methods.DeleteVsanObjects(ctx, m.Client(), &req) if err != nil { return nil, err } return res.Returnval, nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L83-L95
go
train
// NewURL constructs a url.URL with the given file path for datastore access over HTTP.
func (d Datastore) NewURL(path string) *url.URL
// NewURL constructs a url.URL with the given file path for datastore access over HTTP. func (d Datastore) NewURL(path string) *url.URL
{ u := d.c.URL() return &url.URL{ Scheme: u.Scheme, Host: u.Host, Path: fmt.Sprintf("/folder/%s", path), RawQuery: url.Values{ "dcPath": []string{d.DatacenterPath}, "dsName": []string{d.Name()}, }.Encode(), } }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L98-L100
go
train
// URL is deprecated, use NewURL instead.
func (d Datastore) URL(ctx context.Context, dc *Datacenter, path string) (*url.URL, error)
// URL is deprecated, use NewURL instead. func (d Datastore) URL(ctx context.Context, dc *Datacenter, path string) (*url.URL, error)
{ return d.NewURL(path), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L174-L176
go
train
// HostContext returns a Context where the given host will be used for datastore HTTP access // via the ServiceTicket method.
func (d Datastore) HostContext(ctx context.Context, host *HostSystem) context.Context
// HostContext returns a Context where the given host will be used for datastore HTTP access // via the ServiceTicket method. func (d Datastore) HostContext(ctx context.Context, host *HostSystem) context.Context
{ return context.WithValue(ctx, datastoreServiceTicketHostKey{}, host) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L181-L251
go
train
// ServiceTicket obtains a ticket via AcquireGenericServiceTicket and returns it an http.Cookie with the url.URL // that can be used along with the ticket cookie to access the given path. An host is chosen at random unless the // the given Context was created with a specific host via the HostContext method.
func (d Datastore) ServiceTicket(ctx context.Context, path string, method string) (*url.URL, *http.Cookie, error)
// ServiceTicket obtains a ticket via AcquireGenericServiceTicket and returns it an http.Cookie with the url.URL // that can be used along with the ticket cookie to access the given path. An host is chosen at random unless the // the given Context was created with a specific host via the HostContext method. func (d Da...
{ u := d.NewURL(path) host, ok := ctx.Value(datastoreServiceTicketHostKey{}).(*HostSystem) if !ok { if !d.useServiceTicket() { return u, nil, nil } hosts, err := d.AttachedHosts(ctx) if err != nil { return nil, nil, err } if len(hosts) == 0 { // Fallback to letting vCenter choose a host ...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L286-L292
go
train
// Upload via soap.Upload with an http service ticket
func (d Datastore) Upload(ctx context.Context, f io.Reader, path string, param *soap.Upload) error
// Upload via soap.Upload with an http service ticket func (d Datastore) Upload(ctx context.Context, f io.Reader, path string, param *soap.Upload) error
{ u, p, err := d.uploadTicket(ctx, path, param) if err != nil { return err } return d.Client().Upload(ctx, f, u, p) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L295-L301
go
train
// UploadFile via soap.Upload with an http service ticket
func (d Datastore) UploadFile(ctx context.Context, file string, path string, param *soap.Upload) error
// UploadFile via soap.Upload with an http service ticket func (d Datastore) UploadFile(ctx context.Context, file string, path string, param *soap.Upload) error
{ u, p, err := d.uploadTicket(ctx, path, param) if err != nil { return err } return d.Client().UploadFile(ctx, file, u, p) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L304-L310
go
train
// Download via soap.Download with an http service ticket
func (d Datastore) Download(ctx context.Context, path string, param *soap.Download) (io.ReadCloser, int64, error)
// Download via soap.Download with an http service ticket func (d Datastore) Download(ctx context.Context, path string, param *soap.Download) (io.ReadCloser, int64, error)
{ u, p, err := d.downloadTicket(ctx, path, param) if err != nil { return nil, 0, err } return d.Client().Download(ctx, u, p) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L313-L319
go
train
// DownloadFile via soap.Download with an http service ticket
func (d Datastore) DownloadFile(ctx context.Context, path string, file string, param *soap.Download) error
// DownloadFile via soap.Download with an http service ticket func (d Datastore) DownloadFile(ctx context.Context, path string, file string, param *soap.Download) error
{ u, p, err := d.downloadTicket(ctx, path, param) if err != nil { return err } return d.Client().DownloadFile(ctx, file, u, p) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L322-L359
go
train
// AttachedHosts returns hosts that have this Datastore attached, accessible and writable.
func (d Datastore) AttachedHosts(ctx context.Context) ([]*HostSystem, error)
// AttachedHosts returns hosts that have this Datastore attached, accessible and writable. func (d Datastore) AttachedHosts(ctx context.Context) ([]*HostSystem, error)
{ var ds mo.Datastore var hosts []*HostSystem pc := property.DefaultCollector(d.Client()) err := pc.RetrieveOne(ctx, d.Reference(), []string{"host"}, &ds) if err != nil { return nil, err } mounts := make(map[types.ManagedObjectReference]types.DatastoreHostMount) var refs []types.ManagedObjectReference for...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L362-L387
go
train
// AttachedClusterHosts returns hosts that have this Datastore attached, accessible and writable and are members of the given cluster.
func (d Datastore) AttachedClusterHosts(ctx context.Context, cluster *ComputeResource) ([]*HostSystem, error)
// AttachedClusterHosts returns hosts that have this Datastore attached, accessible and writable and are members of the given cluster. func (d Datastore) AttachedClusterHosts(ctx context.Context, cluster *ComputeResource) ([]*HostSystem, error)
{ var hosts []*HostSystem clusterHosts, err := cluster.Hosts(ctx) if err != nil { return nil, err } attachedHosts, err := d.AttachedHosts(ctx) if err != nil { return nil, err } refs := make(map[types.ManagedObjectReference]bool) for _, host := range attachedHosts { refs[host.Reference()] = true } ...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L432-L439
go
train
// Type returns the type of file system volume.
func (d Datastore) Type(ctx context.Context) (types.HostFileSystemVolumeFileSystemType, error)
// Type returns the type of file system volume. func (d Datastore) Type(ctx context.Context) (types.HostFileSystemVolumeFileSystemType, error)
{ var mds mo.Datastore if err := d.Properties(ctx, d.Reference(), []string{"summary.type"}, &mds); err != nil { return types.HostFileSystemVolumeFileSystemType(""), err } return types.HostFileSystemVolumeFileSystemType(mds.Summary.Type), nil }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vapi/internal/internal.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L67-L72
go
train
// NewAssociation returns an Association, converting ref to an AssociatedObject.
func NewAssociation(ref mo.Reference) Association
// NewAssociation returns an Association, converting ref to an AssociatedObject. func NewAssociation(ref mo.Reference) Association
{ obj := AssociatedObject(ref.Reference()) return Association{ ObjectID: &obj, } }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vapi/internal/internal.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L85-L89
go
train
// URL creates a URL resource
func URL(c CloneURL, path string) *Resource
// URL creates a URL resource func URL(c CloneURL, path string) *Resource
{ r := &Resource{u: c.URL()} r.u.Path = Path + path return r }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vapi/internal/internal.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L96-L99
go
train
// WithID appends id to the URL.Path
func (r *Resource) WithID(id string) *Resource
// WithID appends id to the URL.Path func (r *Resource) WithID(id string) *Resource
{ r.u.Path += "/id:" + id return r }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vapi/internal/internal.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L102-L107
go
train
// WithAction sets adds action to the URL.RawQuery
func (r *Resource) WithAction(action string) *Resource
// WithAction sets adds action to the URL.RawQuery func (r *Resource) WithAction(action string) *Resource
{ r.u.RawQuery = url.Values{ "~action": []string{action}, }.Encode() return r }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vapi/internal/internal.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L110-L115
go
train
// WithParameter sets adds a parameter to the URL.RawQuery
func (r *Resource) WithParameter(name string, value string) *Resource
// WithParameter sets adds a parameter to the URL.RawQuery func (r *Resource) WithParameter(name string, value string) *Resource
{ parameter := url.Values{} parameter.Set(name, value) r.u.RawQuery = parameter.Encode() return r }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vapi/internal/internal.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L119-L129
go
train
// Request returns a new http.Request for the given method. // An optional body can be provided for POST and PATCH methods.
func (r *Resource) Request(method string, body ...interface{}) *http.Request
// Request returns a new http.Request for the given method. // An optional body can be provided for POST and PATCH methods. func (r *Resource) Request(method string, body ...interface{}) *http.Request
{ rdr := io.MultiReader() // empty body by default if len(body) != 0 { rdr = encode(body[0]) } req, err := http.NewRequest(method, r.u.String(), rdr) if err != nil { panic(err) } return req }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vapi/internal/internal.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L140-L147
go
train
// encode body as JSON, deferring any errors until io.Reader is used.
func encode(body interface{}) io.Reader
// encode body as JSON, deferring any errors until io.Reader is used. func encode(body interface{}) io.Reader
{ var b bytes.Buffer err := json.NewEncoder(&b).Encode(body) if err != nil { return errorReader{err} } return &b }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vim25/client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/client.go#L59-L85
go
train
// NewClient creates and returns a new client with the ServiceContent field // filled in.
func NewClient(ctx context.Context, rt soap.RoundTripper) (*Client, error)
// NewClient creates and returns a new client with the ServiceContent field // filled in. func NewClient(ctx context.Context, rt soap.RoundTripper) (*Client, error)
{ c := Client{ RoundTripper: rt, } // Set client if it happens to be a soap.Client if sc, ok := rt.(*soap.Client); ok { c.Client = sc if c.Namespace == "" { c.Namespace = "urn:" + Namespace } else if !strings.Contains(c.Namespace, ":") { c.Namespace = "urn:" + c.Namespace // ensure valid URI format...
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vim25/client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/client.go#L88-L90
go
train
// RoundTrip dispatches to the RoundTripper field.
func (c *Client) RoundTrip(ctx context.Context, req, res soap.HasFault) error
// RoundTrip dispatches to the RoundTripper field. func (c *Client) RoundTrip(ctx context.Context, req, res soap.HasFault) error
{ return c.RoundTripper.RoundTrip(ctx, req, res) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
vim25/client.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/client.go#L125-L141
go
train
// Valid returns whether or not the client is valid and ready for use. // This should be called after unmarshalling the client.
func (c *Client) Valid() bool
// Valid returns whether or not the client is valid and ready for use. // This should be called after unmarshalling the client. func (c *Client) Valid() bool
{ if c == nil { return false } if c.Client == nil { return false } // Use arbitrary pointer field in the service content. // Doesn't matter which one, as long as it is populated by default. if c.ServiceContent.SessionManager == nil { return false } return true }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
govc/task/recent.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/task/recent.go#L91-L101
go
train
// taskName describes the tasks similar to the ESX ui
func taskName(info *types.TaskInfo) string
// taskName describes the tasks similar to the ESX ui func taskName(info *types.TaskInfo) string
{ name := strings.TrimSuffix(info.Name, "_Task") switch name { case "": return info.DescriptionId case "Destroy", "Rename": return info.Entity.Type + "." + name default: return name } }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
govc/flags/datastore.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/datastore.go#L43-L47
go
train
// NewCustomDatastoreFlag creates and returns a new DatastoreFlag without // trying to retrieve an existing one from the specified context.
func NewCustomDatastoreFlag(ctx context.Context) (*DatastoreFlag, context.Context)
// NewCustomDatastoreFlag creates and returns a new DatastoreFlag without // trying to retrieve an existing one from the specified context. func NewCustomDatastoreFlag(ctx context.Context) (*DatastoreFlag, context.Context)
{ v := &DatastoreFlag{} v.DatacenterFlag, ctx = NewDatacenterFlag(ctx) return v, ctx }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore_file_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L45-L58
go
train
// NewFileManager creates a new instance of DatastoreFileManager
func (d Datastore) NewFileManager(dc *Datacenter, force bool) *DatastoreFileManager
// NewFileManager creates a new instance of DatastoreFileManager func (d Datastore) NewFileManager(dc *Datacenter, force bool) *DatastoreFileManager
{ c := d.Client() m := &DatastoreFileManager{ Datacenter: dc, Datastore: &d, FileManager: NewFileManager(c), VirtualDiskManager: NewVirtualDiskManager(c), Force: force, DatacenterTarget: dc, } return m }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore_file_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L74-L81
go
train
// Delete dispatches to the appropriate Delete method based on file name extension
func (m *DatastoreFileManager) Delete(ctx context.Context, name string) error
// Delete dispatches to the appropriate Delete method based on file name extension func (m *DatastoreFileManager) Delete(ctx context.Context, name string) error
{ switch path.Ext(name) { case ".vmdk": return m.DeleteVirtualDisk(ctx, name) default: return m.DeleteFile(ctx, name) } }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore_file_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L84-L93
go
train
// DeleteFile calls FileManager.DeleteDatastoreFile
func (m *DatastoreFileManager) DeleteFile(ctx context.Context, name string) error
// DeleteFile calls FileManager.DeleteDatastoreFile func (m *DatastoreFileManager) DeleteFile(ctx context.Context, name string) error
{ p := m.Path(name) task, err := m.FileManager.DeleteDatastoreFile(ctx, p.String(), m.Datacenter) if err != nil { return err } return m.wait(ctx, task) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore_file_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L98-L114
go
train
// DeleteVirtualDisk calls VirtualDiskManager.DeleteVirtualDisk // Regardless of the Datastore type, DeleteVirtualDisk will fail if 'ddb.deletable=false', // so if Force=true this method attempts to set 'ddb.deletable=true' before starting the delete task.
func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Context, name string) error
// DeleteVirtualDisk calls VirtualDiskManager.DeleteVirtualDisk // Regardless of the Datastore type, DeleteVirtualDisk will fail if 'ddb.deletable=false', // so if Force=true this method attempts to set 'ddb.deletable=true' before starting the delete task. func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Co...
{ p := m.Path(name) var merr error if m.Force { merr = m.markDiskAsDeletable(ctx, p) } task, err := m.VirtualDiskManager.DeleteVirtualDisk(ctx, p.String(), m.Datacenter) if err != nil { log.Printf("markDiskAsDeletable(%s): %s", p, merr) return err } return m.wait(ctx, task) }
vmware/govmomi
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
object/datastore_file_manager.go
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L130-L149
go
train
// Copy dispatches to the appropriate FileManager or VirtualDiskManager Copy method based on file name extension
func (m *DatastoreFileManager) Copy(ctx context.Context, src string, dst string) error
// Copy dispatches to the appropriate FileManager or VirtualDiskManager Copy method based on file name extension func (m *DatastoreFileManager) Copy(ctx context.Context, src string, dst string) error
{ srcp := m.Path(src) dstp := m.Path(dst) f := m.FileManager.CopyDatastoreFile if srcp.IsVMDK() { // types.VirtualDiskSpec=nil as it is not implemented by vCenter f = func(ctx context.Context, src string, srcDC *Datacenter, dst string, dstDC *Datacenter, force bool) (*Task, error) { return m.VirtualDiskMa...