repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
vmware/govmomi
simulator/session_manager.go
SetSession
func (c *Context) SetSession(session Session, login bool) { session.UserAgent = c.req.UserAgent() session.IpAddress = strings.Split(c.req.RemoteAddr, ":")[0] session.LastActiveTime = time.Now() session.CallCount++ c.svc.sm.sessions[session.Key] = session c.Session = &session if login { http.SetCookie(c.res, &http.Cookie{ Name: soap.SessionCookieName, Value: session.Key, }) c.postEvent(&types.UserLoginSessionEvent{ SessionId: session.Key, IpAddress: session.IpAddress, UserAgent: session.UserAgent, Locale: session.Locale, }) } }
go
func (c *Context) SetSession(session Session, login bool) { session.UserAgent = c.req.UserAgent() session.IpAddress = strings.Split(c.req.RemoteAddr, ":")[0] session.LastActiveTime = time.Now() session.CallCount++ c.svc.sm.sessions[session.Key] = session c.Session = &session if login { http.SetCookie(c.res, &http.Cookie{ Name: soap.SessionCookieName, Value: session.Key, }) c.postEvent(&types.UserLoginSessionEvent{ SessionId: session.Key, IpAddress: session.IpAddress, UserAgent: session.UserAgent, Locale: session.Locale, }) } }
[ "func", "(", "c", "*", "Context", ")", "SetSession", "(", "session", "Session", ",", "login", "bool", ")", "{", "session", ".", "UserAgent", "=", "c", ".", "req", ".", "UserAgent", "(", ")", "\n", "session", ".", "IpAddress", "=", "strings", ".", "Split", "(", "c", ".", "req", ".", "RemoteAddr", ",", "\"", "\"", ")", "[", "0", "]", "\n", "session", ".", "LastActiveTime", "=", "time", ".", "Now", "(", ")", "\n", "session", ".", "CallCount", "++", "\n\n", "c", ".", "svc", ".", "sm", ".", "sessions", "[", "session", ".", "Key", "]", "=", "session", "\n", "c", ".", "Session", "=", "&", "session", "\n\n", "if", "login", "{", "http", ".", "SetCookie", "(", "c", ".", "res", ",", "&", "http", ".", "Cookie", "{", "Name", ":", "soap", ".", "SessionCookieName", ",", "Value", ":", "session", ".", "Key", ",", "}", ")", "\n\n", "c", ".", "postEvent", "(", "&", "types", ".", "UserLoginSessionEvent", "{", "SessionId", ":", "session", ".", "Key", ",", "IpAddress", ":", "session", ".", "IpAddress", ",", "UserAgent", ":", "session", ".", "UserAgent", ",", "Locale", ":", "session", ".", "Locale", ",", "}", ")", "\n", "}", "\n", "}" ]
// SetSession should be called after successful authentication.
[ "SetSession", "should", "be", "called", "after", "successful", "authentication", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/session_manager.go#L274-L296
train
vmware/govmomi
simulator/session_manager.go
postEvent
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}) } }) }
go
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}) } }) }
[ "func", "(", "c", "*", "Context", ")", "postEvent", "(", "events", "...", "types", ".", "BaseEvent", ")", "{", "m", ":=", "Map", ".", "EventManager", "(", ")", "\n", "c", ".", "WithLock", "(", "m", ",", "func", "(", ")", "{", "for", "_", ",", "event", ":=", "range", "events", "{", "m", ".", "PostEvent", "(", "c", ",", "&", "types", ".", "PostEvent", "{", "EventToPost", ":", "event", "}", ")", "\n", "}", "\n", "}", ")", "\n", "}" ]
// postEvent wraps EventManager.PostEvent for internal use, with a lock on the EventManager.
[ "postEvent", "wraps", "EventManager", ".", "PostEvent", "for", "internal", "use", "with", "a", "lock", "on", "the", "EventManager", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/session_manager.go#L309-L316
train
vmware/govmomi
simulator/session_manager.go
Put
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) }
go
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) }
[ "func", "(", "s", "*", "Session", ")", "Put", "(", "item", "mo", ".", "Reference", ")", "mo", ".", "Reference", "{", "ref", ":=", "item", ".", "Reference", "(", ")", "\n", "if", "ref", ".", "Value", "==", "\"", "\"", "{", "ref", ".", "Value", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "Key", ",", "uuid", ".", "New", "(", ")", ")", "\n", "}", "\n", "s", ".", "Registry", ".", "setReference", "(", "item", ",", "ref", ")", "\n", "return", "s", ".", "Registry", ".", "Put", "(", "item", ")", "\n", "}" ]
// Put wraps Registry.Put, setting the moref value to include the session key.
[ "Put", "wraps", "Registry", ".", "Put", "setting", "the", "moref", "value", "to", "include", "the", "session", "key", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/session_manager.go#L325-L332
train
vmware/govmomi
simulator/session_manager.go
Get
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 // TODO: we could maintain SessionList as part of the SessionManager singleton for _, session := range m.sessions { m.SessionList = append(m.SessionList, session.UserSession) } return &m case "PropertyCollector": if ref == Map.content().PropertyCollector { return s.Put(NewPropertyCollector(ref)) } } return Map.Get(ref) }
go
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 // TODO: we could maintain SessionList as part of the SessionManager singleton for _, session := range m.sessions { m.SessionList = append(m.SessionList, session.UserSession) } return &m case "PropertyCollector": if ref == Map.content().PropertyCollector { return s.Put(NewPropertyCollector(ref)) } } return Map.Get(ref) }
[ "func", "(", "s", "*", "Session", ")", "Get", "(", "ref", "types", ".", "ManagedObjectReference", ")", "mo", ".", "Reference", "{", "obj", ":=", "s", ".", "Registry", ".", "Get", "(", "ref", ")", "\n", "if", "obj", "!=", "nil", "{", "return", "obj", "\n", "}", "\n\n", "// Return a session \"view\" of certain singleton objects", "switch", "ref", ".", "Type", "{", "case", "\"", "\"", ":", "// Clone SessionManager so the PropertyCollector can properly report CurrentSession", "m", ":=", "*", "Map", ".", "SessionManager", "(", ")", "\n", "m", ".", "CurrentSession", "=", "&", "s", ".", "UserSession", "\n\n", "// TODO: we could maintain SessionList as part of the SessionManager singleton", "for", "_", ",", "session", ":=", "range", "m", ".", "sessions", "{", "m", ".", "SessionList", "=", "append", "(", "m", ".", "SessionList", ",", "session", ".", "UserSession", ")", "\n", "}", "\n\n", "return", "&", "m", "\n", "case", "\"", "\"", ":", "if", "ref", "==", "Map", ".", "content", "(", ")", ".", "PropertyCollector", "{", "return", "s", ".", "Put", "(", "NewPropertyCollector", "(", "ref", ")", ")", "\n", "}", "\n", "}", "\n\n", "return", "Map", ".", "Get", "(", "ref", ")", "\n", "}" ]
// Get wraps Registry.Get, session-izing singleton objects such as SessionManager and the root PropertyCollector.
[ "Get", "wraps", "Registry", ".", "Get", "session", "-", "izing", "singleton", "objects", "such", "as", "SessionManager", "and", "the", "root", "PropertyCollector", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/session_manager.go#L335-L361
train
vmware/govmomi
object/file_manager.go
DeleteDatastoreFile
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 }
go
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 }
[ "func", "(", "f", "FileManager", ")", "DeleteDatastoreFile", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "dc", "*", "Datacenter", ")", "(", "*", "Task", ",", "error", ")", "{", "req", ":=", "types", ".", "DeleteDatastoreFile_Task", "{", "This", ":", "f", ".", "Reference", "(", ")", ",", "Name", ":", "name", ",", "}", "\n\n", "if", "dc", "!=", "nil", "{", "ref", ":=", "dc", ".", "Reference", "(", ")", "\n", "req", ".", "Datacenter", "=", "&", "ref", "\n", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "DeleteDatastoreFile_Task", "(", "ctx", ",", "f", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewTask", "(", "f", ".", "c", ",", "res", ".", "Returnval", ")", ",", "nil", "\n", "}" ]
// DeleteDatastoreFile deletes the specified file or folder from the datastore.
[ "DeleteDatastoreFile", "deletes", "the", "specified", "file", "or", "folder", "from", "the", "datastore", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/file_manager.go#L66-L83
train
vmware/govmomi
object/file_manager.go
MakeDirectory
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 }
go
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 }
[ "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", ")", ",", "}", "\n\n", "if", "dc", "!=", "nil", "{", "ref", ":=", "dc", ".", "Reference", "(", ")", "\n", "req", ".", "Datacenter", "=", "&", "ref", "\n", "}", "\n\n", "_", ",", "err", ":=", "methods", ".", "MakeDirectory", "(", "ctx", ",", "f", ".", "c", ",", "&", "req", ")", "\n", "return", "err", "\n", "}" ]
// MakeDirectory creates a folder using the specified name.
[ "MakeDirectory", "creates", "a", "folder", "using", "the", "specified", "name", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/file_manager.go#L86-L100
train
vmware/govmomi
event/manager.go
EventCategory
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 "", err } switch e := event.(type) { case *types.EventEx: if e.Severity == "" { return "info", nil } return e.Severity, nil } class := reflect.TypeOf(event).Elem().Name() return eventCategory[class], nil }
go
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 "", err } switch e := event.(type) { case *types.EventEx: if e.Severity == "" { return "info", nil } return e.Severity, nil } class := reflect.TypeOf(event).Elem().Name() return eventCategory[class], nil }
[ "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", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "switch", "e", ":=", "event", ".", "(", "type", ")", "{", "case", "*", "types", ".", "EventEx", ":", "if", "e", ".", "Severity", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "return", "e", ".", "Severity", ",", "nil", "\n", "}", "\n\n", "class", ":=", "reflect", ".", "TypeOf", "(", "event", ")", ".", "Elem", "(", ")", ".", "Name", "(", ")", "\n\n", "return", "eventCategory", "[", "class", "]", ",", "nil", "\n", "}" ]
// EventCategory returns the category for an event, such as "info" or "error" for example.
[ "EventCategory", "returns", "the", "category", "for", "an", "event", "such", "as", "info", "or", "error", "for", "example", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/event/manager.go#L152-L172
train
vmware/govmomi
toolbox/hgfs/protocol.go
errorStatus
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 }
go
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 }
[ "func", "errorStatus", "(", "err", "error", ")", "uint32", "{", "if", "x", ",", "ok", ":=", "err", ".", "(", "*", "Status", ")", ";", "ok", "{", "return", "x", ".", "Code", "\n", "}", "\n\n", "switch", "{", "case", "os", ".", "IsNotExist", "(", "err", ")", ":", "return", "StatusNoSuchFileOrDir", "\n", "case", "os", ".", "IsExist", "(", "err", ")", ":", "return", "StatusFileExists", "\n", "case", "os", ".", "IsPermission", "(", "err", ")", ":", "return", "StatusOperationNotPermitted", "\n", "}", "\n\n", "return", "StatusGenericError", "\n", "}" ]
// errorStatus maps the given error type to a status code
[ "errorStatus", "maps", "the", "given", "error", "type", "to", "a", "status", "code" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L178-L193
train
vmware/govmomi
toolbox/hgfs/protocol.go
Reply
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.Payload)), HeaderSize: headerSize, RequestID: r.RequestID, Op: r.Op, Status: status, Flags: PacketFlagReply, Information: 0, SessionID: r.SessionID, } if Trace { rc := "OK" if err != nil { rc = err.Error() } fmt.Fprintf(os.Stderr, "[hgfs] response %#v [%s]\n", p.Header, rc) } else if err != nil { log.Printf("[hgfs] op=%d error: %s", r.Op, err) } return p.MarshalBinary() }
go
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.Payload)), HeaderSize: headerSize, RequestID: r.RequestID, Op: r.Op, Status: status, Flags: PacketFlagReply, Information: 0, SessionID: r.SessionID, } if Trace { rc := "OK" if err != nil { rc = err.Error() } fmt.Fprintf(os.Stderr, "[hgfs] response %#v [%s]\n", p.Header, rc) } else if err != nil { log.Printf("[hgfs] op=%d error: %s", r.Op, err) } return p.MarshalBinary() }
[ "func", "(", "r", "*", "Packet", ")", "Reply", "(", "payload", "interface", "{", "}", ",", "err", "error", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "p", ":=", "new", "(", "Packet", ")", "\n\n", "status", ":=", "uint32", "(", "StatusSuccess", ")", "\n\n", "if", "err", "!=", "nil", "{", "status", "=", "errorStatus", "(", "err", ")", "\n", "}", "else", "{", "p", ".", "Payload", ",", "err", "=", "MarshalBinary", "(", "payload", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "p", ".", "Header", "=", "Header", "{", "Version", ":", "HeaderVersion", ",", "Dummy", ":", "OpNewHeader", ",", "PacketSize", ":", "headerSize", "+", "uint32", "(", "len", "(", "p", ".", "Payload", ")", ")", ",", "HeaderSize", ":", "headerSize", ",", "RequestID", ":", "r", ".", "RequestID", ",", "Op", ":", "r", ".", "Op", ",", "Status", ":", "status", ",", "Flags", ":", "PacketFlagReply", ",", "Information", ":", "0", ",", "SessionID", ":", "r", ".", "SessionID", ",", "}", "\n\n", "if", "Trace", "{", "rc", ":=", "\"", "\"", "\n", "if", "err", "!=", "nil", "{", "rc", "=", "err", ".", "Error", "(", ")", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "p", ".", "Header", ",", "rc", ")", "\n", "}", "else", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ".", "Op", ",", "err", ")", "\n", "}", "\n\n", "return", "p", ".", "MarshalBinary", "(", ")", "\n", "}" ]
// Reply composes a new Packet with the given payload or error
[ "Reply", "composes", "a", "new", "Packet", "with", "the", "given", "payload", "or", "error" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L263-L301
train
vmware/govmomi
toolbox/hgfs/protocol.go
FromString
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)) }
go
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)) }
[ "func", "(", "f", "*", "FileName", ")", "FromString", "(", "name", "string", ")", "{", "name", "=", "strings", ".", "TrimPrefix", "(", "name", ",", "\"", "\"", ")", "\n\n", "cp", ":=", "strings", ".", "Split", "(", "name", ",", "\"", "\"", ")", "\n\n", "cp", "=", "append", "(", "[", "]", "string", "{", "serverPolicyRootShareName", "}", ",", "cp", "...", ")", "\n\n", "f", ".", "Name", "=", "strings", ".", "Join", "(", "cp", ",", "\"", "\\x00", "\"", ")", "\n", "f", ".", "Length", "=", "uint32", "(", "len", "(", "f", ".", "Name", ")", ")", "\n", "}" ]
// FromString converts name to a FileName
[ "FromString", "converts", "name", "to", "a", "FileName" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L515-L524
train
vmware/govmomi
toolbox/hgfs/protocol.go
Path
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, "/") }
go
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, "/") }
[ "func", "(", "f", "*", "FileName", ")", "Path", "(", ")", "string", "{", "cp", ":=", "strings", ".", "Split", "(", "f", ".", "Name", ",", "\"", "\\x00", "\"", ")", "\n\n", "if", "len", "(", "cp", ")", "==", "0", "||", "cp", "[", "0", "]", "!=", "serverPolicyRootShareName", "{", "return", "\"", "\"", "// TODO: not happening until if/when we handle Windows shares", "\n", "}", "\n\n", "cp", "[", "0", "]", "=", "\"", "\"", "\n\n", "return", "strings", ".", "Join", "(", "cp", ",", "\"", "\"", ")", "\n", "}" ]
// Path converts FileName to a string
[ "Path", "converts", "FileName", "to", "a", "string" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L527-L537
train
vmware/govmomi
toolbox/hgfs/protocol.go
FromString
func (f *FileNameV3) FromString(name string) { p := new(FileName) p.FromString(name) f.Name = p.Name f.Length = p.Length }
go
func (f *FileNameV3) FromString(name string) { p := new(FileName) p.FromString(name) f.Name = p.Name f.Length = p.Length }
[ "func", "(", "f", "*", "FileNameV3", ")", "FromString", "(", "name", "string", ")", "{", "p", ":=", "new", "(", "FileName", ")", "\n", "p", ".", "FromString", "(", "name", ")", "\n", "f", ".", "Name", "=", "p", ".", "Name", "\n", "f", ".", "Length", "=", "p", ".", "Length", "\n", "}" ]
// FromString converts name to a FileNameV3
[ "FromString", "converts", "name", "to", "a", "FileNameV3" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L579-L584
train
vmware/govmomi
toolbox/hgfs/protocol.go
Path
func (f *FileNameV3) Path() string { return (&FileName{Name: f.Name, Length: f.Length}).Path() }
go
func (f *FileNameV3) Path() string { return (&FileName{Name: f.Name, Length: f.Length}).Path() }
[ "func", "(", "f", "*", "FileNameV3", ")", "Path", "(", ")", "string", "{", "return", "(", "&", "FileName", "{", "Name", ":", "f", ".", "Name", ",", "Length", ":", "f", ".", "Length", "}", ")", ".", "Path", "(", ")", "\n", "}" ]
// Path converts FileNameV3 to a string
[ "Path", "converts", "FileNameV3", "to", "a", "string" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/protocol.go#L587-L589
train
vmware/govmomi
sts/simulator/simulator.go
New
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 }
go
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 }
[ "func", "New", "(", "u", "*", "url", ".", "URL", ",", "settings", "[", "]", "vim", ".", "BaseOptionValue", ")", "(", "string", ",", "http", ".", "Handler", ")", "{", "for", "i", ":=", "range", "settings", "{", "setting", ":=", "settings", "[", "i", "]", ".", "GetOptionValue", "(", ")", "\n", "if", "setting", ".", "Key", "==", "\"", "\"", "{", "endpoint", ",", "_", ":=", "url", ".", "Parse", "(", "setting", ".", "Value", ".", "(", "string", ")", ")", "\n", "endpoint", ".", "Host", "=", "u", ".", "Host", "\n", "setting", ".", "Value", "=", "endpoint", ".", "String", "(", ")", "\n", "settings", "[", "i", "]", "=", "setting", "\n", "return", "endpoint", ".", "Path", ",", "new", "(", "handler", ")", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", ",", "nil", "\n", "}" ]
// 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.
[ "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", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/simulator/simulator.go#L34-L46
train
vmware/govmomi
sts/simulator/simulator.go
ServeHTTP
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: &internal.RequestSecurityTokenResponseCollection{ RequestSecurityTokenResponse: internal.RequestSecurityTokenResponse{ RequestedSecurityToken: internal.RequestedSecurityToken{ Assertion: token, }, Lifetime: lifetime, }, }, } env.Body = body case "Renew": body := internal.RenewSecurityTokenBody{ Res: &internal.RequestSecurityTokenResponse{ RequestedSecurityToken: internal.RequestedSecurityToken{ Assertion: token, }, Lifetime: lifetime, }, } env.Body = body default: log.Printf("sts: unsupported action=%s", action) w.WriteHeader(http.StatusNotFound) return } w.WriteHeader(http.StatusOK) fmt.Fprint(w, internal.Marshal(env)) }
go
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: &internal.RequestSecurityTokenResponseCollection{ RequestSecurityTokenResponse: internal.RequestSecurityTokenResponse{ RequestedSecurityToken: internal.RequestedSecurityToken{ Assertion: token, }, Lifetime: lifetime, }, }, } env.Body = body case "Renew": body := internal.RenewSecurityTokenBody{ Res: &internal.RequestSecurityTokenResponse{ RequestedSecurityToken: internal.RequestedSecurityToken{ Assertion: token, }, Lifetime: lifetime, }, } env.Body = body default: log.Printf("sts: unsupported action=%s", action) w.WriteHeader(http.StatusNotFound) return } w.WriteHeader(http.StatusOK) fmt.Fprint(w, internal.Marshal(env)) }
[ "func", "(", "s", "*", "handler", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "action", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "env", ":=", "soap", ".", "Envelope", "{", "}", "\n", "now", ":=", "time", ".", "Now", "(", ")", "\n", "lifetime", ":=", "&", "internal", ".", "Lifetime", "{", "Created", ":", "now", ".", "Format", "(", "internal", ".", "Time", ")", ",", "Expires", ":", "now", ".", "Add", "(", "5", "*", "time", ".", "Minute", ")", ".", "Format", "(", "internal", ".", "Time", ")", ",", "}", "\n\n", "switch", "path", ".", "Base", "(", "action", ")", "{", "case", "\"", "\"", ":", "body", ":=", "internal", ".", "RequestSecurityTokenBody", "{", "Res", ":", "&", "internal", ".", "RequestSecurityTokenResponseCollection", "{", "RequestSecurityTokenResponse", ":", "internal", ".", "RequestSecurityTokenResponse", "{", "RequestedSecurityToken", ":", "internal", ".", "RequestedSecurityToken", "{", "Assertion", ":", "token", ",", "}", ",", "Lifetime", ":", "lifetime", ",", "}", ",", "}", ",", "}", "\n", "env", ".", "Body", "=", "body", "\n", "case", "\"", "\"", ":", "body", ":=", "internal", ".", "RenewSecurityTokenBody", "{", "Res", ":", "&", "internal", ".", "RequestSecurityTokenResponse", "{", "RequestedSecurityToken", ":", "internal", ".", "RequestedSecurityToken", "{", "Assertion", ":", "token", ",", "}", ",", "Lifetime", ":", "lifetime", ",", "}", ",", "}", "\n", "env", ".", "Body", "=", "body", "\n", "default", ":", "log", ".", "Printf", "(", "\"", "\"", ",", "action", ")", "\n", "w", ".", "WriteHeader", "(", "http", ".", "StatusNotFound", ")", "\n", "return", "\n", "}", "\n\n", "w", ".", "WriteHeader", "(", "http", ".", "StatusOK", ")", "\n", "fmt", ".", "Fprint", "(", "w", ",", "internal", ".", "Marshal", "(", "env", ")", ")", "\n", "}" ]
// ServeHTTP handles STS requests.
[ "ServeHTTP", "handles", "STS", "requests", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/simulator/simulator.go#L51-L91
train
vmware/govmomi
object/virtual_machine.go
Device
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 information would be unavailable if the server // is unable to access the virtual machine files on disk, and is often also unavailable // during the initial phases of virtual machine creation. if o.Config == nil { return nil, fmt.Errorf("%s Config is not available, connectionState=%s", v.Reference(), o.Summary.Runtime.ConnectionState) } return VirtualDeviceList(o.Config.Hardware.Device), nil }
go
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 information would be unavailable if the server // is unable to access the virtual machine files on disk, and is often also unavailable // during the initial phases of virtual machine creation. if o.Config == nil { return nil, fmt.Errorf("%s Config is not available, connectionState=%s", v.Reference(), o.Summary.Runtime.ConnectionState) } return VirtualDeviceList(o.Config.Hardware.Device), nil }
[ "func", "(", "v", "VirtualMachine", ")", "Device", "(", "ctx", "context", ".", "Context", ")", "(", "VirtualDeviceList", ",", "error", ")", "{", "var", "o", "mo", ".", "VirtualMachine", "\n\n", "err", ":=", "v", ".", "Properties", "(", "ctx", ",", "v", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "&", "o", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Quoting the SDK doc:", "// The virtual machine configuration is not guaranteed to be available.", "// For example, the configuration information would be unavailable if the server", "// is unable to access the virtual machine files on disk, and is often also unavailable", "// during the initial phases of virtual machine creation.", "if", "o", ".", "Config", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "v", ".", "Reference", "(", ")", ",", "o", ".", "Summary", ".", "Runtime", ".", "ConnectionState", ")", "\n", "}", "\n\n", "return", "VirtualDeviceList", "(", "o", ".", "Config", ".", "Hardware", ".", "Device", ")", ",", "nil", "\n", "}" ]
// Device returns the VirtualMachine's config.hardware.device property.
[ "Device", "returns", "the", "VirtualMachine", "s", "config", ".", "hardware", ".", "device", "property", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L345-L364
train
vmware/govmomi
object/virtual_machine.go
AddDevice
func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error { return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationAdd, types.VirtualDeviceConfigSpecFileOperationCreate, device...) }
go
func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error { return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationAdd, types.VirtualDeviceConfigSpecFileOperationCreate, device...) }
[ "func", "(", "v", "VirtualMachine", ")", "AddDevice", "(", "ctx", "context", ".", "Context", ",", "device", "...", "types", ".", "BaseVirtualDevice", ")", "error", "{", "return", "v", ".", "configureDevice", "(", "ctx", ",", "types", ".", "VirtualDeviceConfigSpecOperationAdd", ",", "types", ".", "VirtualDeviceConfigSpecFileOperationCreate", ",", "device", "...", ")", "\n", "}" ]
// AddDevice adds the given devices to the VirtualMachine
[ "AddDevice", "adds", "the", "given", "devices", "to", "the", "VirtualMachine" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L435-L437
train
vmware/govmomi
object/virtual_machine.go
RemoveDevice
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...) }
go
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...) }
[ "func", "(", "v", "VirtualMachine", ")", "RemoveDevice", "(", "ctx", "context", ".", "Context", ",", "keepFiles", "bool", ",", "device", "...", "types", ".", "BaseVirtualDevice", ")", "error", "{", "fop", ":=", "types", ".", "VirtualDeviceConfigSpecFileOperationDestroy", "\n", "if", "keepFiles", "{", "fop", "=", "\"", "\"", "\n", "}", "\n", "return", "v", ".", "configureDevice", "(", "ctx", ",", "types", ".", "VirtualDeviceConfigSpecOperationRemove", ",", "fop", ",", "device", "...", ")", "\n", "}" ]
// RemoveDevice removes the given devices on the VirtualMachine
[ "RemoveDevice", "removes", "the", "given", "devices", "on", "the", "VirtualMachine" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L445-L451
train
vmware/govmomi
object/virtual_machine.go
BootOptions
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 }
go
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 }
[ "func", "(", "v", "VirtualMachine", ")", "BootOptions", "(", "ctx", "context", ".", "Context", ")", "(", "*", "types", ".", "VirtualMachineBootOptions", ",", "error", ")", "{", "var", "o", "mo", ".", "VirtualMachine", "\n\n", "err", ":=", "v", ".", "Properties", "(", "ctx", ",", "v", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "o", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "o", ".", "Config", ".", "BootOptions", ",", "nil", "\n", "}" ]
// BootOptions returns the VirtualMachine's config.bootOptions property.
[ "BootOptions", "returns", "the", "VirtualMachine", "s", "config", ".", "bootOptions", "property", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L454-L463
train
vmware/govmomi
object/virtual_machine.go
SetBootOptions
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) }
go
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) }
[ "func", "(", "v", "VirtualMachine", ")", "SetBootOptions", "(", "ctx", "context", ".", "Context", ",", "options", "*", "types", ".", "VirtualMachineBootOptions", ")", "error", "{", "spec", ":=", "types", ".", "VirtualMachineConfigSpec", "{", "}", "\n\n", "spec", ".", "BootOptions", "=", "options", "\n\n", "task", ",", "err", ":=", "v", ".", "Reconfigure", "(", "ctx", ",", "spec", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "task", ".", "Wait", "(", "ctx", ")", "\n", "}" ]
// SetBootOptions reconfigures the VirtualMachine with the given options.
[ "SetBootOptions", "reconfigures", "the", "VirtualMachine", "with", "the", "given", "options", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L466-L477
train
vmware/govmomi
object/virtual_machine.go
Answer
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 }
go
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 }
[ "func", "(", "v", "VirtualMachine", ")", "Answer", "(", "ctx", "context", ".", "Context", ",", "id", ",", "answer", "string", ")", "error", "{", "req", ":=", "types", ".", "AnswerVM", "{", "This", ":", "v", ".", "Reference", "(", ")", ",", "QuestionId", ":", "id", ",", "AnswerChoice", ":", "answer", ",", "}", "\n\n", "_", ",", "err", ":=", "methods", ".", "AnswerVM", "(", "ctx", ",", "v", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Answer answers a pending question.
[ "Answer", "answers", "a", "pending", "question", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L480-L493
train
vmware/govmomi
object/virtual_machine.go
CreateSnapshot
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 }
go
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 }
[ "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", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "CreateSnapshot_Task", "(", "ctx", ",", "v", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewTask", "(", "v", ".", "c", ",", "res", ".", "Returnval", ")", ",", "nil", "\n", "}" ]
// CreateSnapshot creates a new snapshot of a virtual machine.
[ "CreateSnapshot", "creates", "a", "new", "snapshot", "of", "a", "virtual", "machine", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L510-L525
train
vmware/govmomi
object/virtual_machine.go
RemoveAllSnapshot
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 }
go
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 }
[ "func", "(", "v", "VirtualMachine", ")", "RemoveAllSnapshot", "(", "ctx", "context", ".", "Context", ",", "consolidate", "*", "bool", ")", "(", "*", "Task", ",", "error", ")", "{", "req", ":=", "types", ".", "RemoveAllSnapshots_Task", "{", "This", ":", "v", ".", "Reference", "(", ")", ",", "Consolidate", ":", "consolidate", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "RemoveAllSnapshots_Task", "(", "ctx", ",", "v", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewTask", "(", "v", ".", "c", ",", "res", ".", "Returnval", ")", ",", "nil", "\n", "}" ]
// RemoveAllSnapshot removes all snapshots of a virtual machine
[ "RemoveAllSnapshot", "removes", "all", "snapshots", "of", "a", "virtual", "machine" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L528-L540
train
vmware/govmomi
object/virtual_machine.go
RemoveSnapshot
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, err } return NewTask(v.c, res.Returnval), nil }
go
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, err } return NewTask(v.c, res.Returnval), nil }
[ "func", "(", "v", "VirtualMachine", ")", "RemoveSnapshot", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "removeChildren", "bool", ",", "consolidate", "*", "bool", ")", "(", "*", "Task", ",", "error", ")", "{", "snapshot", ",", "err", ":=", "v", ".", "FindSnapshot", "(", "ctx", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "req", ":=", "types", ".", "RemoveSnapshot_Task", "{", "This", ":", "snapshot", ".", "Reference", "(", ")", ",", "RemoveChildren", ":", "removeChildren", ",", "Consolidate", ":", "consolidate", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "RemoveSnapshot_Task", "(", "ctx", ",", "v", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewTask", "(", "v", ".", "c", ",", "res", ".", "Returnval", ")", ",", "nil", "\n", "}" ]
// RemoveSnapshot removes a named snapshot
[ "RemoveSnapshot", "removes", "a", "named", "snapshot" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L594-L612
train
vmware/govmomi
object/virtual_machine.go
RevertToCurrentSnapshot
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 }
go
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 }
[ "func", "(", "v", "VirtualMachine", ")", "RevertToCurrentSnapshot", "(", "ctx", "context", ".", "Context", ",", "suppressPowerOn", "bool", ")", "(", "*", "Task", ",", "error", ")", "{", "req", ":=", "types", ".", "RevertToCurrentSnapshot_Task", "{", "This", ":", "v", ".", "Reference", "(", ")", ",", "SuppressPowerOn", ":", "types", ".", "NewBool", "(", "suppressPowerOn", ")", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "RevertToCurrentSnapshot_Task", "(", "ctx", ",", "v", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewTask", "(", "v", ".", "c", ",", "res", ".", "Returnval", ")", ",", "nil", "\n", "}" ]
// RevertToCurrentSnapshot reverts to the current snapshot
[ "RevertToCurrentSnapshot", "reverts", "to", "the", "current", "snapshot" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L615-L627
train
vmware/govmomi
object/virtual_machine.go
RevertToSnapshot
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 } return NewTask(v.c, res.Returnval), nil }
go
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 } return NewTask(v.c, res.Returnval), nil }
[ "func", "(", "v", "VirtualMachine", ")", "RevertToSnapshot", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "suppressPowerOn", "bool", ")", "(", "*", "Task", ",", "error", ")", "{", "snapshot", ",", "err", ":=", "v", ".", "FindSnapshot", "(", "ctx", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "req", ":=", "types", ".", "RevertToSnapshot_Task", "{", "This", ":", "snapshot", ".", "Reference", "(", ")", ",", "SuppressPowerOn", ":", "types", ".", "NewBool", "(", "suppressPowerOn", ")", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "RevertToSnapshot_Task", "(", "ctx", ",", "v", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewTask", "(", "v", ".", "c", ",", "res", ".", "Returnval", ")", ",", "nil", "\n", "}" ]
// RevertToSnapshot reverts to a named snapshot
[ "RevertToSnapshot", "reverts", "to", "a", "named", "snapshot" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L630-L647
train
vmware/govmomi
object/virtual_machine.go
IsToolsRunning
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 }
go
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 }
[ "func", "(", "v", "VirtualMachine", ")", "IsToolsRunning", "(", "ctx", "context", ".", "Context", ")", "(", "bool", ",", "error", ")", "{", "var", "o", "mo", ".", "VirtualMachine", "\n\n", "err", ":=", "v", ".", "Properties", "(", "ctx", ",", "v", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "o", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "return", "o", ".", "Guest", ".", "ToolsRunningStatus", "==", "string", "(", "types", ".", "VirtualMachineToolsRunningStatusGuestToolsRunning", ")", ",", "nil", "\n", "}" ]
// IsToolsRunning returns true if VMware Tools is currently running in the guest OS, and false otherwise.
[ "IsToolsRunning", "returns", "true", "if", "VMware", "Tools", "is", "currently", "running", "in", "the", "guest", "OS", "and", "false", "otherwise", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L650-L659
train
vmware/govmomi
object/virtual_machine.go
WaitForPowerState
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.VirtualMachinePowerState) if ps == state { return true } } return false }) return err }
go
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.VirtualMachinePowerState) if ps == state { return true } } return false }) return err }
[ "func", "(", "v", "VirtualMachine", ")", "WaitForPowerState", "(", "ctx", "context", ".", "Context", ",", "state", "types", ".", "VirtualMachinePowerState", ")", "error", "{", "p", ":=", "property", ".", "DefaultCollector", "(", "v", ".", "c", ")", "\n", "err", ":=", "property", ".", "Wait", "(", "ctx", ",", "p", ",", "v", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "PropRuntimePowerState", "}", ",", "func", "(", "pc", "[", "]", "types", ".", "PropertyChange", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "pc", "{", "if", "c", ".", "Name", "!=", "PropRuntimePowerState", "{", "continue", "\n", "}", "\n", "if", "c", ".", "Val", "==", "nil", "{", "continue", "\n", "}", "\n\n", "ps", ":=", "c", ".", "Val", ".", "(", "types", ".", "VirtualMachinePowerState", ")", "\n", "if", "ps", "==", "state", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}", ")", "\n\n", "return", "err", "\n", "}" ]
// Wait for the VirtualMachine to change to the desired power state.
[ "Wait", "for", "the", "VirtualMachine", "to", "change", "to", "the", "desired", "power", "state", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L662-L682
train
vmware/govmomi
object/virtual_machine.go
QueryConfigTarget
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 } return res.Returnval, nil }
go
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 } return res.Returnval, nil }
[ "func", "(", "v", "VirtualMachine", ")", "QueryConfigTarget", "(", "ctx", "context", ".", "Context", ")", "(", "*", "types", ".", "ConfigTarget", ",", "error", ")", "{", "var", "vm", "mo", ".", "VirtualMachine", "\n\n", "err", ":=", "v", ".", "Properties", "(", "ctx", ",", "v", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "vm", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "req", ":=", "types", ".", "QueryConfigTarget", "{", "This", ":", "vm", ".", "EnvironmentBrowser", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "QueryConfigTarget", "(", "ctx", ",", "v", ".", "Client", "(", ")", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "Returnval", ",", "nil", "\n", "}" ]
// QueryEnvironmentBrowser is a helper to get the environmentBrowser property.
[ "QueryEnvironmentBrowser", "is", "a", "helper", "to", "get", "the", "environmentBrowser", "property", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L751-L769
train
vmware/govmomi
object/virtual_machine.go
UUID
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 }
go
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 }
[ "func", "(", "v", "VirtualMachine", ")", "UUID", "(", "ctx", "context", ".", "Context", ")", "string", "{", "var", "o", "mo", ".", "VirtualMachine", "\n\n", "err", ":=", "v", ".", "Properties", "(", "ctx", ",", "v", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "o", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "return", "o", ".", "Config", ".", "Uuid", "\n", "}" ]
// 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.
[ "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", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_machine.go#L832-L841
train
vmware/govmomi
vim25/xml/extras.go
typeToString
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: return "xsd:unsignedShort" case reflect.Uint32: return "xsd:unsignedInt" case reflect.Uint, reflect.Uint64: return "xsd:unsignedLong" case reflect.Float32: return "xsd:float" case reflect.Float64: return "xsd:double" case reflect.String: name := typ.Name() if name == "string" { return "xsd:string" } return name case reflect.Struct: if typ == stringToTypeMap["xsd:dateTime"] { return "xsd:dateTime" } // Expect any other struct to be handled... return typ.Name() case reflect.Slice: if typ.Elem().Kind() == reflect.Uint8 { return "xsd:base64Binary" } case reflect.Array: if typ.Elem().Kind() == reflect.Uint8 { return "xsd:base64Binary" } } panic("don't know what to do for type: " + typ.String()) }
go
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: return "xsd:unsignedShort" case reflect.Uint32: return "xsd:unsignedInt" case reflect.Uint, reflect.Uint64: return "xsd:unsignedLong" case reflect.Float32: return "xsd:float" case reflect.Float64: return "xsd:double" case reflect.String: name := typ.Name() if name == "string" { return "xsd:string" } return name case reflect.Struct: if typ == stringToTypeMap["xsd:dateTime"] { return "xsd:dateTime" } // Expect any other struct to be handled... return typ.Name() case reflect.Slice: if typ.Elem().Kind() == reflect.Uint8 { return "xsd:base64Binary" } case reflect.Array: if typ.Elem().Kind() == reflect.Uint8 { return "xsd:base64Binary" } } panic("don't know what to do for type: " + typ.String()) }
[ "func", "typeToString", "(", "typ", "reflect", ".", "Type", ")", "string", "{", "switch", "typ", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Bool", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Int8", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Int16", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Int32", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Int", ",", "reflect", ".", "Int64", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Uint8", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Uint16", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Uint32", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Uint", ",", "reflect", ".", "Uint64", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Float32", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "Float64", ":", "return", "\"", "\"", "\n", "case", "reflect", ".", "String", ":", "name", ":=", "typ", ".", "Name", "(", ")", "\n", "if", "name", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "name", "\n", "case", "reflect", ".", "Struct", ":", "if", "typ", "==", "stringToTypeMap", "[", "\"", "\"", "]", "{", "return", "\"", "\"", "\n", "}", "\n\n", "// Expect any other struct to be handled...", "return", "typ", ".", "Name", "(", ")", "\n", "case", "reflect", ".", "Slice", ":", "if", "typ", ".", "Elem", "(", ")", ".", "Kind", "(", ")", "==", "reflect", ".", "Uint8", "{", "return", "\"", "\"", "\n", "}", "\n", "case", "reflect", ".", "Array", ":", "if", "typ", ".", "Elem", "(", ")", ".", "Kind", "(", ")", "==", "reflect", ".", "Uint8", "{", "return", "\"", "\"", "\n", "}", "\n", "}", "\n\n", "panic", "(", "\"", "\"", "+", "typ", ".", "String", "(", ")", ")", "\n", "}" ]
// Return a string for the specified reflect.Type. Panic if unknown.
[ "Return", "a", "string", "for", "the", "specified", "reflect", ".", "Type", ".", "Panic", "if", "unknown", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/extras.go#L51-L99
train
vmware/govmomi
simulator/container.go
inspect
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.NewReader(out)).Decode(&objects); err != nil { return err } vm.Config.Annotation = strings.Join(cmd.Args, " ") vm.logPrintf("%s: %s", vm.Config.Annotation, string(out)) for _, o := range objects { s := o.NetworkSettings if s.IPAddress == "" { continue } vm.Guest.IpAddress = s.IPAddress vm.Summary.Guest.IpAddress = s.IPAddress if len(vm.Guest.Net) != 0 { net := &vm.Guest.Net[0] net.IpAddress = []string{s.IPAddress} net.MacAddress = s.MacAddress } } return nil }
go
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.NewReader(out)).Decode(&objects); err != nil { return err } vm.Config.Annotation = strings.Join(cmd.Args, " ") vm.logPrintf("%s: %s", vm.Config.Annotation, string(out)) for _, o := range objects { s := o.NetworkSettings if s.IPAddress == "" { continue } vm.Guest.IpAddress = s.IPAddress vm.Summary.Guest.IpAddress = s.IPAddress if len(vm.Guest.Net) != 0 { net := &vm.Guest.Net[0] net.IpAddress = []string{s.IPAddress} net.MacAddress = s.MacAddress } } return nil }
[ "func", "(", "c", "*", "container", ")", "inspect", "(", "vm", "*", "VirtualMachine", ")", "error", "{", "if", "c", ".", "id", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "var", "objects", "[", "]", "struct", "{", "NetworkSettings", "struct", "{", "Gateway", "string", "\n", "IPAddress", "string", "\n", "IPPrefixLen", "int", "\n", "MacAddress", "string", "\n", "}", "\n", "}", "\n\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "c", ".", "id", ")", "\n", "out", ",", "err", ":=", "cmd", ".", "Output", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", "=", "json", ".", "NewDecoder", "(", "bytes", ".", "NewReader", "(", "out", ")", ")", ".", "Decode", "(", "&", "objects", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "vm", ".", "Config", ".", "Annotation", "=", "strings", ".", "Join", "(", "cmd", ".", "Args", ",", "\"", "\"", ")", "\n", "vm", ".", "logPrintf", "(", "\"", "\"", ",", "vm", ".", "Config", ".", "Annotation", ",", "string", "(", "out", ")", ")", "\n\n", "for", "_", ",", "o", ":=", "range", "objects", "{", "s", ":=", "o", ".", "NetworkSettings", "\n", "if", "s", ".", "IPAddress", "==", "\"", "\"", "{", "continue", "\n", "}", "\n\n", "vm", ".", "Guest", ".", "IpAddress", "=", "s", ".", "IPAddress", "\n", "vm", ".", "Summary", ".", "Guest", ".", "IpAddress", "=", "s", ".", "IPAddress", "\n\n", "if", "len", "(", "vm", ".", "Guest", ".", "Net", ")", "!=", "0", "{", "net", ":=", "&", "vm", ".", "Guest", ".", "Net", "[", "0", "]", "\n", "net", ".", "IpAddress", "=", "[", "]", "string", "{", "s", ".", "IPAddress", "}", "\n", "net", ".", "MacAddress", "=", "s", ".", "MacAddress", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// inspect applies container network settings to vm.Guest properties.
[ "inspect", "applies", "container", "network", "settings", "to", "vm", ".", "Guest", "properties", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/container.go#L35-L78
train
vmware/govmomi
simulator/container.go
start
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 := range vm.Config.ExtraConfig { val := opt.GetOptionValue() if val.Key == "RUN.container" { run := val.Value.(string) err := json.Unmarshal([]byte(run), &args) if err != nil { args = []string{run} } break } } if len(args) == 0 { return } args = append([]string{"run", "-d", "--name", vm.Name}, args...) cmd := exec.Command("docker", args...) out, err := cmd.Output() if err != nil { log.Printf("%s %s: %s", vm.Name, cmd.Args, err) return } c.id = strings.TrimSpace(string(out)) vm.logPrintf("%s %s: %s", cmd.Path, cmd.Args, c.id) if err = c.inspect(vm); err != nil { log.Printf("%s inspect %s: %s", vm.Name, c.id, err) } }
go
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 := range vm.Config.ExtraConfig { val := opt.GetOptionValue() if val.Key == "RUN.container" { run := val.Value.(string) err := json.Unmarshal([]byte(run), &args) if err != nil { args = []string{run} } break } } if len(args) == 0 { return } args = append([]string{"run", "-d", "--name", vm.Name}, args...) cmd := exec.Command("docker", args...) out, err := cmd.Output() if err != nil { log.Printf("%s %s: %s", vm.Name, cmd.Args, err) return } c.id = strings.TrimSpace(string(out)) vm.logPrintf("%s %s: %s", cmd.Path, cmd.Args, c.id) if err = c.inspect(vm); err != nil { log.Printf("%s inspect %s: %s", vm.Name, c.id, err) } }
[ "func", "(", "c", "*", "container", ")", "start", "(", "vm", "*", "VirtualMachine", ")", "{", "if", "c", ".", "id", "!=", "\"", "\"", "{", "start", ":=", "\"", "\"", "\n", "if", "vm", ".", "Runtime", ".", "PowerState", "==", "types", ".", "VirtualMachinePowerStateSuspended", "{", "start", "=", "\"", "\"", "\n", "}", "\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "start", ",", "c", ".", "id", ")", "\n", "err", ":=", "cmd", ".", "Run", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "vm", ".", "Name", ",", "cmd", ".", "Args", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n\n", "var", "args", "[", "]", "string", "\n\n", "for", "_", ",", "opt", ":=", "range", "vm", ".", "Config", ".", "ExtraConfig", "{", "val", ":=", "opt", ".", "GetOptionValue", "(", ")", "\n", "if", "val", ".", "Key", "==", "\"", "\"", "{", "run", ":=", "val", ".", "Value", ".", "(", "string", ")", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "run", ")", ",", "&", "args", ")", "\n", "if", "err", "!=", "nil", "{", "args", "=", "[", "]", "string", "{", "run", "}", "\n", "}", "\n\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "args", ")", "==", "0", "{", "return", "\n", "}", "\n\n", "args", "=", "append", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "vm", ".", "Name", "}", ",", "args", "...", ")", "\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "args", "...", ")", "\n", "out", ",", "err", ":=", "cmd", ".", "Output", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "vm", ".", "Name", ",", "cmd", ".", "Args", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "c", ".", "id", "=", "strings", ".", "TrimSpace", "(", "string", "(", "out", ")", ")", "\n", "vm", ".", "logPrintf", "(", "\"", "\"", ",", "cmd", ".", "Path", ",", "cmd", ".", "Args", ",", "c", ".", "id", ")", "\n\n", "if", "err", "=", "c", ".", "inspect", "(", "vm", ")", ";", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "vm", ".", "Name", ",", "c", ".", "id", ",", "err", ")", "\n", "}", "\n", "}" ]
// start runs the container if specified by the RUN.container extraConfig property.
[ "start", "runs", "the", "container", "if", "specified", "by", "the", "RUN", ".", "container", "extraConfig", "property", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/container.go#L81-L128
train
vmware/govmomi
client.go
Login
func (c *Client) Login(ctx context.Context, u *url.Userinfo) error { return c.SessionManager.Login(ctx, u) }
go
func (c *Client) Login(ctx context.Context, u *url.Userinfo) error { return c.SessionManager.Login(ctx, u) }
[ "func", "(", "c", "*", "Client", ")", "Login", "(", "ctx", "context", ".", "Context", ",", "u", "*", "url", ".", "Userinfo", ")", "error", "{", "return", "c", ".", "SessionManager", ".", "Login", "(", "ctx", ",", "u", ")", "\n", "}" ]
// Login dispatches to the SessionManager.
[ "Login", "dispatches", "to", "the", "SessionManager", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L102-L104
train
vmware/govmomi
client.go
Logout
func (c *Client) Logout(ctx context.Context) error { // Close any idle connections after logging out. defer c.Client.CloseIdleConnections() return c.SessionManager.Logout(ctx) }
go
func (c *Client) Logout(ctx context.Context) error { // Close any idle connections after logging out. defer c.Client.CloseIdleConnections() return c.SessionManager.Logout(ctx) }
[ "func", "(", "c", "*", "Client", ")", "Logout", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// Close any idle connections after logging out.", "defer", "c", ".", "Client", ".", "CloseIdleConnections", "(", ")", "\n", "return", "c", ".", "SessionManager", ".", "Logout", "(", "ctx", ")", "\n", "}" ]
// Logout dispatches to the SessionManager.
[ "Logout", "dispatches", "to", "the", "SessionManager", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L107-L111
train
vmware/govmomi
client.go
RetrieveOne
func (c *Client) RetrieveOne(ctx context.Context, obj types.ManagedObjectReference, p []string, dst interface{}) error { return c.PropertyCollector().RetrieveOne(ctx, obj, p, dst) }
go
func (c *Client) RetrieveOne(ctx context.Context, obj types.ManagedObjectReference, p []string, dst interface{}) error { return c.PropertyCollector().RetrieveOne(ctx, obj, p, dst) }
[ "func", "(", "c", "*", "Client", ")", "RetrieveOne", "(", "ctx", "context", ".", "Context", ",", "obj", "types", ".", "ManagedObjectReference", ",", "p", "[", "]", "string", ",", "dst", "interface", "{", "}", ")", "error", "{", "return", "c", ".", "PropertyCollector", "(", ")", ".", "RetrieveOne", "(", "ctx", ",", "obj", ",", "p", ",", "dst", ")", "\n", "}" ]
// RetrieveOne dispatches to the Retrieve function on the default property collector.
[ "RetrieveOne", "dispatches", "to", "the", "Retrieve", "function", "on", "the", "default", "property", "collector", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L119-L121
train
vmware/govmomi
client.go
Retrieve
func (c *Client) Retrieve(ctx context.Context, objs []types.ManagedObjectReference, p []string, dst interface{}) error { return c.PropertyCollector().Retrieve(ctx, objs, p, dst) }
go
func (c *Client) Retrieve(ctx context.Context, objs []types.ManagedObjectReference, p []string, dst interface{}) error { return c.PropertyCollector().Retrieve(ctx, objs, p, dst) }
[ "func", "(", "c", "*", "Client", ")", "Retrieve", "(", "ctx", "context", ".", "Context", ",", "objs", "[", "]", "types", ".", "ManagedObjectReference", ",", "p", "[", "]", "string", ",", "dst", "interface", "{", "}", ")", "error", "{", "return", "c", ".", "PropertyCollector", "(", ")", ".", "Retrieve", "(", "ctx", ",", "objs", ",", "p", ",", "dst", ")", "\n", "}" ]
// Retrieve dispatches to the Retrieve function on the default property collector.
[ "Retrieve", "dispatches", "to", "the", "Retrieve", "function", "on", "the", "default", "property", "collector", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L124-L126
train
vmware/govmomi
client.go
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) }
go
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) }
[ "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", ")", "\n", "}" ]
// Wait dispatches to property.Wait.
[ "Wait", "dispatches", "to", "property", ".", "Wait", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/client.go#L129-L131
train
vmware/govmomi
sts/client.go
NewClient
func NewClient(ctx context.Context, c *vim25.Client) (*Client, error) { 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 := lookup.EndpointURL(ctx, c, Path, filter) sc := c.Client.NewServiceClient(url, Namespace) return &Client{sc}, nil }
go
func NewClient(ctx context.Context, c *vim25.Client) (*Client, error) { 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 := lookup.EndpointURL(ctx, c, Path, filter) sc := c.Client.NewServiceClient(url, Namespace) return &Client{sc}, nil }
[ "func", "NewClient", "(", "ctx", "context", ".", "Context", ",", "c", "*", "vim25", ".", "Client", ")", "(", "*", "Client", ",", "error", ")", "{", "filter", ":=", "&", "types", ".", "LookupServiceRegistrationFilter", "{", "ServiceType", ":", "&", "types", ".", "LookupServiceRegistrationServiceType", "{", "Product", ":", "\"", "\"", ",", "Type", ":", "\"", "\"", ",", "}", ",", "EndpointType", ":", "&", "types", ".", "LookupServiceRegistrationEndpointType", "{", "Protocol", ":", "\"", "\"", ",", "Type", ":", "\"", "\"", ",", "}", ",", "}", "\n\n", "url", ":=", "lookup", ".", "EndpointURL", "(", "ctx", ",", "c", ",", "Path", ",", "filter", ")", "\n", "sc", ":=", "c", ".", "Client", ".", "NewServiceClient", "(", "url", ",", "Namespace", ")", "\n\n", "return", "&", "Client", "{", "sc", "}", ",", "nil", "\n", "}" ]
// 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.
[ "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", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/client.go#L47-L63
train
vmware/govmomi
sts/client.go
Renew
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, Action: rst.Action(), } res, err := internal.Renew(c.WithHeader(ctx, header), c, &rst) if err != nil { return nil, err } s.Token = res.RequestedSecurityToken.Assertion return s, s.setLifetime(res.Lifetime) }
go
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, Action: rst.Action(), } res, err := internal.Renew(c.WithHeader(ctx, header), c, &rst) if err != nil { return nil, err } s.Token = res.RequestedSecurityToken.Assertion return s, s.setLifetime(res.Lifetime) }
[ "func", "(", "c", "*", "Client", ")", "Renew", "(", "ctx", "context", ".", "Context", ",", "req", "TokenRequest", ")", "(", "*", "Signer", ",", "error", ")", "{", "s", ":=", "&", "Signer", "{", "Certificate", ":", "req", ".", "Certificate", ",", "}", "\n\n", "rst", ",", "err", ":=", "c", ".", "newRequest", "(", "req", ",", "\"", "\"", ",", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "req", ".", "Token", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "rst", ".", "RenewTarget", "=", "&", "internal", ".", "Target", "{", "Token", ":", "req", ".", "Token", "}", "\n\n", "header", ":=", "soap", ".", "Header", "{", "Security", ":", "s", ",", "Action", ":", "rst", ".", "Action", "(", ")", ",", "}", "\n\n", "res", ",", "err", ":=", "internal", ".", "Renew", "(", "c", ".", "WithHeader", "(", "ctx", ",", "header", ")", ",", "c", ",", "&", "rst", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "s", ".", "Token", "=", "res", ".", "RequestedSecurityToken", ".", "Assertion", "\n\n", "return", "s", ",", "s", ".", "setLifetime", "(", "res", ".", "Lifetime", ")", "\n", "}" ]
// Renew is used to request a security token renewal.
[ "Renew", "is", "used", "to", "request", "a", "security", "token", "renewal", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/client.go#L180-L209
train
vmware/govmomi
object/host_vsan_internal_system.go
QueryVsanObjectUuidsByFilter
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 }
go
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 }
[ "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", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "QueryVsanObjectUuidsByFilter", "(", "ctx", ",", "m", ".", "Client", "(", ")", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "Returnval", ",", "nil", "\n", "}" ]
// QueryVsanObjectUuidsByFilter returns vSAN DOM object uuids by filter.
[ "QueryVsanObjectUuidsByFilter", "returns", "vSAN", "DOM", "object", "uuids", "by", "filter", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_vsan_internal_system.go#L41-L55
train
vmware/govmomi
object/datastore.go
NewURL
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(), } }
go
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(), } }
[ "func", "(", "d", "Datastore", ")", "NewURL", "(", "path", "string", ")", "*", "url", ".", "URL", "{", "u", ":=", "d", ".", "c", ".", "URL", "(", ")", "\n\n", "return", "&", "url", ".", "URL", "{", "Scheme", ":", "u", ".", "Scheme", ",", "Host", ":", "u", ".", "Host", ",", "Path", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "path", ")", ",", "RawQuery", ":", "url", ".", "Values", "{", "\"", "\"", ":", "[", "]", "string", "{", "d", ".", "DatacenterPath", "}", ",", "\"", "\"", ":", "[", "]", "string", "{", "d", ".", "Name", "(", ")", "}", ",", "}", ".", "Encode", "(", ")", ",", "}", "\n", "}" ]
// NewURL constructs a url.URL with the given file path for datastore access over HTTP.
[ "NewURL", "constructs", "a", "url", ".", "URL", "with", "the", "given", "file", "path", "for", "datastore", "access", "over", "HTTP", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L83-L95
train
vmware/govmomi
object/datastore.go
URL
func (d Datastore) URL(ctx context.Context, dc *Datacenter, path string) (*url.URL, error) { return d.NewURL(path), nil }
go
func (d Datastore) URL(ctx context.Context, dc *Datacenter, path string) (*url.URL, error) { return d.NewURL(path), nil }
[ "func", "(", "d", "Datastore", ")", "URL", "(", "ctx", "context", ".", "Context", ",", "dc", "*", "Datacenter", ",", "path", "string", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "return", "d", ".", "NewURL", "(", "path", ")", ",", "nil", "\n", "}" ]
// URL is deprecated, use NewURL instead.
[ "URL", "is", "deprecated", "use", "NewURL", "instead", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L98-L100
train
vmware/govmomi
object/datastore.go
HostContext
func (d Datastore) HostContext(ctx context.Context, host *HostSystem) context.Context { return context.WithValue(ctx, datastoreServiceTicketHostKey{}, host) }
go
func (d Datastore) HostContext(ctx context.Context, host *HostSystem) context.Context { return context.WithValue(ctx, datastoreServiceTicketHostKey{}, host) }
[ "func", "(", "d", "Datastore", ")", "HostContext", "(", "ctx", "context", ".", "Context", ",", "host", "*", "HostSystem", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "datastoreServiceTicketHostKey", "{", "}", ",", "host", ")", "\n", "}" ]
// HostContext returns a Context where the given host will be used for datastore HTTP access // via the ServiceTicket method.
[ "HostContext", "returns", "a", "Context", "where", "the", "given", "host", "will", "be", "used", "for", "datastore", "HTTP", "access", "via", "the", "ServiceTicket", "method", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L174-L176
train
vmware/govmomi
object/datastore.go
ServiceTicket
func (d Datastore) ServiceTicket(ctx context.Context, path string, method string) (*url.URL, *http.Cookie, error) { 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 return u, nil, nil } // Pick a random attached host host = hosts[rand.Intn(len(hosts))] } ips, err := host.ManagementIPs(ctx) if err != nil { return nil, nil, err } if len(ips) > 0 { // prefer a ManagementIP u.Host = ips[0].String() } else { // fallback to inventory name u.Host, err = host.ObjectName(ctx) if err != nil { return nil, nil, err } } // VC datacenter path will not be valid against ESX q := u.Query() delete(q, "dcPath") u.RawQuery = q.Encode() spec := types.SessionManagerHttpServiceRequestSpec{ Url: u.String(), // See SessionManagerHttpServiceRequestSpecMethod enum Method: fmt.Sprintf("http%s%s", method[0:1], strings.ToLower(method[1:])), } sm := session.NewManager(d.Client()) ticket, err := sm.AcquireGenericServiceTicket(ctx, &spec) if err != nil { return nil, nil, err } cookie := &http.Cookie{ Name: "vmware_cgi_ticket", Value: ticket.Id, } if d.useServiceTicketHostName(ticket.HostName) { u.Host = ticket.HostName } d.Client().SetThumbprint(u.Host, ticket.SslThumbprint) return u, cookie, nil }
go
func (d Datastore) ServiceTicket(ctx context.Context, path string, method string) (*url.URL, *http.Cookie, error) { 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 return u, nil, nil } // Pick a random attached host host = hosts[rand.Intn(len(hosts))] } ips, err := host.ManagementIPs(ctx) if err != nil { return nil, nil, err } if len(ips) > 0 { // prefer a ManagementIP u.Host = ips[0].String() } else { // fallback to inventory name u.Host, err = host.ObjectName(ctx) if err != nil { return nil, nil, err } } // VC datacenter path will not be valid against ESX q := u.Query() delete(q, "dcPath") u.RawQuery = q.Encode() spec := types.SessionManagerHttpServiceRequestSpec{ Url: u.String(), // See SessionManagerHttpServiceRequestSpecMethod enum Method: fmt.Sprintf("http%s%s", method[0:1], strings.ToLower(method[1:])), } sm := session.NewManager(d.Client()) ticket, err := sm.AcquireGenericServiceTicket(ctx, &spec) if err != nil { return nil, nil, err } cookie := &http.Cookie{ Name: "vmware_cgi_ticket", Value: ticket.Id, } if d.useServiceTicketHostName(ticket.HostName) { u.Host = ticket.HostName } d.Client().SetThumbprint(u.Host, ticket.SslThumbprint) return u, cookie, nil }
[ "func", "(", "d", "Datastore", ")", "ServiceTicket", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "method", "string", ")", "(", "*", "url", ".", "URL", ",", "*", "http", ".", "Cookie", ",", "error", ")", "{", "u", ":=", "d", ".", "NewURL", "(", "path", ")", "\n\n", "host", ",", "ok", ":=", "ctx", ".", "Value", "(", "datastoreServiceTicketHostKey", "{", "}", ")", ".", "(", "*", "HostSystem", ")", "\n\n", "if", "!", "ok", "{", "if", "!", "d", ".", "useServiceTicket", "(", ")", "{", "return", "u", ",", "nil", ",", "nil", "\n", "}", "\n\n", "hosts", ",", "err", ":=", "d", ".", "AttachedHosts", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "hosts", ")", "==", "0", "{", "// Fallback to letting vCenter choose a host", "return", "u", ",", "nil", ",", "nil", "\n", "}", "\n\n", "// Pick a random attached host", "host", "=", "hosts", "[", "rand", ".", "Intn", "(", "len", "(", "hosts", ")", ")", "]", "\n", "}", "\n\n", "ips", ",", "err", ":=", "host", ".", "ManagementIPs", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "ips", ")", ">", "0", "{", "// prefer a ManagementIP", "u", ".", "Host", "=", "ips", "[", "0", "]", ".", "String", "(", ")", "\n", "}", "else", "{", "// fallback to inventory name", "u", ".", "Host", ",", "err", "=", "host", ".", "ObjectName", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "// VC datacenter path will not be valid against ESX", "q", ":=", "u", ".", "Query", "(", ")", "\n", "delete", "(", "q", ",", "\"", "\"", ")", "\n", "u", ".", "RawQuery", "=", "q", ".", "Encode", "(", ")", "\n\n", "spec", ":=", "types", ".", "SessionManagerHttpServiceRequestSpec", "{", "Url", ":", "u", ".", "String", "(", ")", ",", "// See SessionManagerHttpServiceRequestSpecMethod enum", "Method", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "method", "[", "0", ":", "1", "]", ",", "strings", ".", "ToLower", "(", "method", "[", "1", ":", "]", ")", ")", ",", "}", "\n\n", "sm", ":=", "session", ".", "NewManager", "(", "d", ".", "Client", "(", ")", ")", "\n\n", "ticket", ",", "err", ":=", "sm", ".", "AcquireGenericServiceTicket", "(", "ctx", ",", "&", "spec", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "cookie", ":=", "&", "http", ".", "Cookie", "{", "Name", ":", "\"", "\"", ",", "Value", ":", "ticket", ".", "Id", ",", "}", "\n\n", "if", "d", ".", "useServiceTicketHostName", "(", "ticket", ".", "HostName", ")", "{", "u", ".", "Host", "=", "ticket", ".", "HostName", "\n", "}", "\n\n", "d", ".", "Client", "(", ")", ".", "SetThumbprint", "(", "u", ".", "Host", ",", "ticket", ".", "SslThumbprint", ")", "\n\n", "return", "u", ",", "cookie", ",", "nil", "\n", "}" ]
// 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.
[ "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", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L181-L251
train
vmware/govmomi
object/datastore.go
Upload
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) }
go
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) }
[ "func", "(", "d", "Datastore", ")", "Upload", "(", "ctx", "context", ".", "Context", ",", "f", "io", ".", "Reader", ",", "path", "string", ",", "param", "*", "soap", ".", "Upload", ")", "error", "{", "u", ",", "p", ",", "err", ":=", "d", ".", "uploadTicket", "(", "ctx", ",", "path", ",", "param", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "d", ".", "Client", "(", ")", ".", "Upload", "(", "ctx", ",", "f", ",", "u", ",", "p", ")", "\n", "}" ]
// Upload via soap.Upload with an http service ticket
[ "Upload", "via", "soap", ".", "Upload", "with", "an", "http", "service", "ticket" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L286-L292
train
vmware/govmomi
object/datastore.go
UploadFile
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) }
go
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) }
[ "func", "(", "d", "Datastore", ")", "UploadFile", "(", "ctx", "context", ".", "Context", ",", "file", "string", ",", "path", "string", ",", "param", "*", "soap", ".", "Upload", ")", "error", "{", "u", ",", "p", ",", "err", ":=", "d", ".", "uploadTicket", "(", "ctx", ",", "path", ",", "param", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "d", ".", "Client", "(", ")", ".", "UploadFile", "(", "ctx", ",", "file", ",", "u", ",", "p", ")", "\n", "}" ]
// UploadFile via soap.Upload with an http service ticket
[ "UploadFile", "via", "soap", ".", "Upload", "with", "an", "http", "service", "ticket" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L295-L301
train
vmware/govmomi
object/datastore.go
Download
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) }
go
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) }
[ "func", "(", "d", "Datastore", ")", "Download", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "param", "*", "soap", ".", "Download", ")", "(", "io", ".", "ReadCloser", ",", "int64", ",", "error", ")", "{", "u", ",", "p", ",", "err", ":=", "d", ".", "downloadTicket", "(", "ctx", ",", "path", ",", "param", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "err", "\n", "}", "\n", "return", "d", ".", "Client", "(", ")", ".", "Download", "(", "ctx", ",", "u", ",", "p", ")", "\n", "}" ]
// Download via soap.Download with an http service ticket
[ "Download", "via", "soap", ".", "Download", "with", "an", "http", "service", "ticket" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L304-L310
train
vmware/govmomi
object/datastore.go
DownloadFile
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) }
go
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) }
[ "func", "(", "d", "Datastore", ")", "DownloadFile", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "file", "string", ",", "param", "*", "soap", ".", "Download", ")", "error", "{", "u", ",", "p", ",", "err", ":=", "d", ".", "downloadTicket", "(", "ctx", ",", "path", ",", "param", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "d", ".", "Client", "(", ")", ".", "DownloadFile", "(", "ctx", ",", "file", ",", "u", ",", "p", ")", "\n", "}" ]
// DownloadFile via soap.Download with an http service ticket
[ "DownloadFile", "via", "soap", ".", "Download", "with", "an", "http", "service", "ticket" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L313-L319
train
vmware/govmomi
object/datastore.go
AttachedHosts
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 _, host := range ds.Host { refs = append(refs, host.Key) mounts[host.Key] = host } var hs []mo.HostSystem err = pc.Retrieve(ctx, refs, []string{"runtime.connectionState", "runtime.powerState"}, &hs) if err != nil { return nil, err } for _, host := range hs { if host.Runtime.ConnectionState == types.HostSystemConnectionStateConnected && host.Runtime.PowerState == types.HostSystemPowerStatePoweredOn { mount := mounts[host.Reference()] info := mount.MountInfo if *info.Mounted && *info.Accessible && info.AccessMode == string(types.HostMountModeReadWrite) { hosts = append(hosts, NewHostSystem(d.Client(), mount.Key)) } } } return hosts, nil }
go
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 _, host := range ds.Host { refs = append(refs, host.Key) mounts[host.Key] = host } var hs []mo.HostSystem err = pc.Retrieve(ctx, refs, []string{"runtime.connectionState", "runtime.powerState"}, &hs) if err != nil { return nil, err } for _, host := range hs { if host.Runtime.ConnectionState == types.HostSystemConnectionStateConnected && host.Runtime.PowerState == types.HostSystemPowerStatePoweredOn { mount := mounts[host.Reference()] info := mount.MountInfo if *info.Mounted && *info.Accessible && info.AccessMode == string(types.HostMountModeReadWrite) { hosts = append(hosts, NewHostSystem(d.Client(), mount.Key)) } } } return hosts, nil }
[ "func", "(", "d", "Datastore", ")", "AttachedHosts", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "*", "HostSystem", ",", "error", ")", "{", "var", "ds", "mo", ".", "Datastore", "\n", "var", "hosts", "[", "]", "*", "HostSystem", "\n\n", "pc", ":=", "property", ".", "DefaultCollector", "(", "d", ".", "Client", "(", ")", ")", "\n", "err", ":=", "pc", ".", "RetrieveOne", "(", "ctx", ",", "d", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "ds", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "mounts", ":=", "make", "(", "map", "[", "types", ".", "ManagedObjectReference", "]", "types", ".", "DatastoreHostMount", ")", "\n", "var", "refs", "[", "]", "types", ".", "ManagedObjectReference", "\n", "for", "_", ",", "host", ":=", "range", "ds", ".", "Host", "{", "refs", "=", "append", "(", "refs", ",", "host", ".", "Key", ")", "\n", "mounts", "[", "host", ".", "Key", "]", "=", "host", "\n", "}", "\n\n", "var", "hs", "[", "]", "mo", ".", "HostSystem", "\n", "err", "=", "pc", ".", "Retrieve", "(", "ctx", ",", "refs", ",", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "&", "hs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "host", ":=", "range", "hs", "{", "if", "host", ".", "Runtime", ".", "ConnectionState", "==", "types", ".", "HostSystemConnectionStateConnected", "&&", "host", ".", "Runtime", ".", "PowerState", "==", "types", ".", "HostSystemPowerStatePoweredOn", "{", "mount", ":=", "mounts", "[", "host", ".", "Reference", "(", ")", "]", "\n", "info", ":=", "mount", ".", "MountInfo", "\n\n", "if", "*", "info", ".", "Mounted", "&&", "*", "info", ".", "Accessible", "&&", "info", ".", "AccessMode", "==", "string", "(", "types", ".", "HostMountModeReadWrite", ")", "{", "hosts", "=", "append", "(", "hosts", ",", "NewHostSystem", "(", "d", ".", "Client", "(", ")", ",", "mount", ".", "Key", ")", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "hosts", ",", "nil", "\n", "}" ]
// AttachedHosts returns hosts that have this Datastore attached, accessible and writable.
[ "AttachedHosts", "returns", "hosts", "that", "have", "this", "Datastore", "attached", "accessible", "and", "writable", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L322-L359
train
vmware/govmomi
object/datastore.go
AttachedClusterHosts
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 } for _, host := range clusterHosts { if refs[host.Reference()] { hosts = append(hosts, host) } } return hosts, nil }
go
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 } for _, host := range clusterHosts { if refs[host.Reference()] { hosts = append(hosts, host) } } return hosts, nil }
[ "func", "(", "d", "Datastore", ")", "AttachedClusterHosts", "(", "ctx", "context", ".", "Context", ",", "cluster", "*", "ComputeResource", ")", "(", "[", "]", "*", "HostSystem", ",", "error", ")", "{", "var", "hosts", "[", "]", "*", "HostSystem", "\n\n", "clusterHosts", ",", "err", ":=", "cluster", ".", "Hosts", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "attachedHosts", ",", "err", ":=", "d", ".", "AttachedHosts", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "refs", ":=", "make", "(", "map", "[", "types", ".", "ManagedObjectReference", "]", "bool", ")", "\n", "for", "_", ",", "host", ":=", "range", "attachedHosts", "{", "refs", "[", "host", ".", "Reference", "(", ")", "]", "=", "true", "\n", "}", "\n\n", "for", "_", ",", "host", ":=", "range", "clusterHosts", "{", "if", "refs", "[", "host", ".", "Reference", "(", ")", "]", "{", "hosts", "=", "append", "(", "hosts", ",", "host", ")", "\n", "}", "\n", "}", "\n\n", "return", "hosts", ",", "nil", "\n", "}" ]
// AttachedClusterHosts returns hosts that have this Datastore attached, accessible and writable and are members of the given cluster.
[ "AttachedClusterHosts", "returns", "hosts", "that", "have", "this", "Datastore", "attached", "accessible", "and", "writable", "and", "are", "members", "of", "the", "given", "cluster", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L362-L387
train
vmware/govmomi
object/datastore.go
Type
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 }
go
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 }
[ "func", "(", "d", "Datastore", ")", "Type", "(", "ctx", "context", ".", "Context", ")", "(", "types", ".", "HostFileSystemVolumeFileSystemType", ",", "error", ")", "{", "var", "mds", "mo", ".", "Datastore", "\n\n", "if", "err", ":=", "d", ".", "Properties", "(", "ctx", ",", "d", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "mds", ")", ";", "err", "!=", "nil", "{", "return", "types", ".", "HostFileSystemVolumeFileSystemType", "(", "\"", "\"", ")", ",", "err", "\n", "}", "\n", "return", "types", ".", "HostFileSystemVolumeFileSystemType", "(", "mds", ".", "Summary", ".", "Type", ")", ",", "nil", "\n", "}" ]
// Type returns the type of file system volume.
[ "Type", "returns", "the", "type", "of", "file", "system", "volume", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore.go#L432-L439
train
vmware/govmomi
vapi/internal/internal.go
NewAssociation
func NewAssociation(ref mo.Reference) Association { obj := AssociatedObject(ref.Reference()) return Association{ ObjectID: &obj, } }
go
func NewAssociation(ref mo.Reference) Association { obj := AssociatedObject(ref.Reference()) return Association{ ObjectID: &obj, } }
[ "func", "NewAssociation", "(", "ref", "mo", ".", "Reference", ")", "Association", "{", "obj", ":=", "AssociatedObject", "(", "ref", ".", "Reference", "(", ")", ")", "\n", "return", "Association", "{", "ObjectID", ":", "&", "obj", ",", "}", "\n", "}" ]
// NewAssociation returns an Association, converting ref to an AssociatedObject.
[ "NewAssociation", "returns", "an", "Association", "converting", "ref", "to", "an", "AssociatedObject", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L67-L72
train
vmware/govmomi
vapi/internal/internal.go
URL
func URL(c CloneURL, path string) *Resource { r := &Resource{u: c.URL()} r.u.Path = Path + path return r }
go
func URL(c CloneURL, path string) *Resource { r := &Resource{u: c.URL()} r.u.Path = Path + path return r }
[ "func", "URL", "(", "c", "CloneURL", ",", "path", "string", ")", "*", "Resource", "{", "r", ":=", "&", "Resource", "{", "u", ":", "c", ".", "URL", "(", ")", "}", "\n", "r", ".", "u", ".", "Path", "=", "Path", "+", "path", "\n", "return", "r", "\n", "}" ]
// URL creates a URL resource
[ "URL", "creates", "a", "URL", "resource" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L85-L89
train
vmware/govmomi
vapi/internal/internal.go
WithID
func (r *Resource) WithID(id string) *Resource { r.u.Path += "/id:" + id return r }
go
func (r *Resource) WithID(id string) *Resource { r.u.Path += "/id:" + id return r }
[ "func", "(", "r", "*", "Resource", ")", "WithID", "(", "id", "string", ")", "*", "Resource", "{", "r", ".", "u", ".", "Path", "+=", "\"", "\"", "+", "id", "\n", "return", "r", "\n", "}" ]
// WithID appends id to the URL.Path
[ "WithID", "appends", "id", "to", "the", "URL", ".", "Path" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L96-L99
train
vmware/govmomi
vapi/internal/internal.go
WithAction
func (r *Resource) WithAction(action string) *Resource { r.u.RawQuery = url.Values{ "~action": []string{action}, }.Encode() return r }
go
func (r *Resource) WithAction(action string) *Resource { r.u.RawQuery = url.Values{ "~action": []string{action}, }.Encode() return r }
[ "func", "(", "r", "*", "Resource", ")", "WithAction", "(", "action", "string", ")", "*", "Resource", "{", "r", ".", "u", ".", "RawQuery", "=", "url", ".", "Values", "{", "\"", "\"", ":", "[", "]", "string", "{", "action", "}", ",", "}", ".", "Encode", "(", ")", "\n", "return", "r", "\n", "}" ]
// WithAction sets adds action to the URL.RawQuery
[ "WithAction", "sets", "adds", "action", "to", "the", "URL", ".", "RawQuery" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L102-L107
train
vmware/govmomi
vapi/internal/internal.go
WithParameter
func (r *Resource) WithParameter(name string, value string) *Resource { parameter := url.Values{} parameter.Set(name, value) r.u.RawQuery = parameter.Encode() return r }
go
func (r *Resource) WithParameter(name string, value string) *Resource { parameter := url.Values{} parameter.Set(name, value) r.u.RawQuery = parameter.Encode() return r }
[ "func", "(", "r", "*", "Resource", ")", "WithParameter", "(", "name", "string", ",", "value", "string", ")", "*", "Resource", "{", "parameter", ":=", "url", ".", "Values", "{", "}", "\n", "parameter", ".", "Set", "(", "name", ",", "value", ")", "\n", "r", ".", "u", ".", "RawQuery", "=", "parameter", ".", "Encode", "(", ")", "\n", "return", "r", "\n", "}" ]
// WithParameter sets adds a parameter to the URL.RawQuery
[ "WithParameter", "sets", "adds", "a", "parameter", "to", "the", "URL", ".", "RawQuery" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L110-L115
train
vmware/govmomi
vapi/internal/internal.go
Request
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 }
go
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 }
[ "func", "(", "r", "*", "Resource", ")", "Request", "(", "method", "string", ",", "body", "...", "interface", "{", "}", ")", "*", "http", ".", "Request", "{", "rdr", ":=", "io", ".", "MultiReader", "(", ")", "// empty body by default", "\n", "if", "len", "(", "body", ")", "!=", "0", "{", "rdr", "=", "encode", "(", "body", "[", "0", "]", ")", "\n", "}", "\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "method", ",", "r", ".", "u", ".", "String", "(", ")", ",", "rdr", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "req", "\n", "}" ]
// Request returns a new http.Request for the given method. // An optional body can be provided for POST and PATCH methods.
[ "Request", "returns", "a", "new", "http", ".", "Request", "for", "the", "given", "method", ".", "An", "optional", "body", "can", "be", "provided", "for", "POST", "and", "PATCH", "methods", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L119-L129
train
vmware/govmomi
vapi/internal/internal.go
encode
func encode(body interface{}) io.Reader { var b bytes.Buffer err := json.NewEncoder(&b).Encode(body) if err != nil { return errorReader{err} } return &b }
go
func encode(body interface{}) io.Reader { var b bytes.Buffer err := json.NewEncoder(&b).Encode(body) if err != nil { return errorReader{err} } return &b }
[ "func", "encode", "(", "body", "interface", "{", "}", ")", "io", ".", "Reader", "{", "var", "b", "bytes", ".", "Buffer", "\n", "err", ":=", "json", ".", "NewEncoder", "(", "&", "b", ")", ".", "Encode", "(", "body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errorReader", "{", "err", "}", "\n", "}", "\n", "return", "&", "b", "\n", "}" ]
// encode body as JSON, deferring any errors until io.Reader is used.
[ "encode", "body", "as", "JSON", "deferring", "any", "errors", "until", "io", ".", "Reader", "is", "used", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/internal/internal.go#L140-L147
train
vmware/govmomi
vim25/client.go
NewClient
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 } if c.Version == "" { c.Version = Version } } var err error c.ServiceContent, err = methods.GetServiceContent(ctx, rt) if err != nil { return nil, err } return &c, nil }
go
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 } if c.Version == "" { c.Version = Version } } var err error c.ServiceContent, err = methods.GetServiceContent(ctx, rt) if err != nil { return nil, err } return &c, nil }
[ "func", "NewClient", "(", "ctx", "context", ".", "Context", ",", "rt", "soap", ".", "RoundTripper", ")", "(", "*", "Client", ",", "error", ")", "{", "c", ":=", "Client", "{", "RoundTripper", ":", "rt", ",", "}", "\n\n", "// Set client if it happens to be a soap.Client", "if", "sc", ",", "ok", ":=", "rt", ".", "(", "*", "soap", ".", "Client", ")", ";", "ok", "{", "c", ".", "Client", "=", "sc", "\n\n", "if", "c", ".", "Namespace", "==", "\"", "\"", "{", "c", ".", "Namespace", "=", "\"", "\"", "+", "Namespace", "\n", "}", "else", "if", "!", "strings", ".", "Contains", "(", "c", ".", "Namespace", ",", "\"", "\"", ")", "{", "c", ".", "Namespace", "=", "\"", "\"", "+", "c", ".", "Namespace", "// ensure valid URI format", "\n", "}", "\n", "if", "c", ".", "Version", "==", "\"", "\"", "{", "c", ".", "Version", "=", "Version", "\n", "}", "\n", "}", "\n\n", "var", "err", "error", "\n", "c", ".", "ServiceContent", ",", "err", "=", "methods", ".", "GetServiceContent", "(", "ctx", ",", "rt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "c", ",", "nil", "\n", "}" ]
// NewClient creates and returns a new client with the ServiceContent field // filled in.
[ "NewClient", "creates", "and", "returns", "a", "new", "client", "with", "the", "ServiceContent", "field", "filled", "in", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/client.go#L59-L85
train
vmware/govmomi
vim25/client.go
RoundTrip
func (c *Client) RoundTrip(ctx context.Context, req, res soap.HasFault) error { return c.RoundTripper.RoundTrip(ctx, req, res) }
go
func (c *Client) RoundTrip(ctx context.Context, req, res soap.HasFault) error { return c.RoundTripper.RoundTrip(ctx, req, res) }
[ "func", "(", "c", "*", "Client", ")", "RoundTrip", "(", "ctx", "context", ".", "Context", ",", "req", ",", "res", "soap", ".", "HasFault", ")", "error", "{", "return", "c", ".", "RoundTripper", ".", "RoundTrip", "(", "ctx", ",", "req", ",", "res", ")", "\n", "}" ]
// RoundTrip dispatches to the RoundTripper field.
[ "RoundTrip", "dispatches", "to", "the", "RoundTripper", "field", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/client.go#L88-L90
train
vmware/govmomi
vim25/client.go
Valid
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 }
go
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 }
[ "func", "(", "c", "*", "Client", ")", "Valid", "(", ")", "bool", "{", "if", "c", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "c", ".", "Client", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "// 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", "\n", "}", "\n\n", "return", "true", "\n", "}" ]
// Valid returns whether or not the client is valid and ready for use. // This should be called after unmarshalling the client.
[ "Valid", "returns", "whether", "or", "not", "the", "client", "is", "valid", "and", "ready", "for", "use", ".", "This", "should", "be", "called", "after", "unmarshalling", "the", "client", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/client.go#L125-L141
train
vmware/govmomi
govc/task/recent.go
taskName
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 } }
go
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 } }
[ "func", "taskName", "(", "info", "*", "types", ".", "TaskInfo", ")", "string", "{", "name", ":=", "strings", ".", "TrimSuffix", "(", "info", ".", "Name", ",", "\"", "\"", ")", "\n", "switch", "name", "{", "case", "\"", "\"", ":", "return", "info", ".", "DescriptionId", "\n", "case", "\"", "\"", ",", "\"", "\"", ":", "return", "info", ".", "Entity", ".", "Type", "+", "\"", "\"", "+", "name", "\n", "default", ":", "return", "name", "\n", "}", "\n", "}" ]
// taskName describes the tasks similar to the ESX ui
[ "taskName", "describes", "the", "tasks", "similar", "to", "the", "ESX", "ui" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/task/recent.go#L91-L101
train
vmware/govmomi
govc/flags/datastore.go
NewCustomDatastoreFlag
func NewCustomDatastoreFlag(ctx context.Context) (*DatastoreFlag, context.Context) { v := &DatastoreFlag{} v.DatacenterFlag, ctx = NewDatacenterFlag(ctx) return v, ctx }
go
func NewCustomDatastoreFlag(ctx context.Context) (*DatastoreFlag, context.Context) { v := &DatastoreFlag{} v.DatacenterFlag, ctx = NewDatacenterFlag(ctx) return v, ctx }
[ "func", "NewCustomDatastoreFlag", "(", "ctx", "context", ".", "Context", ")", "(", "*", "DatastoreFlag", ",", "context", ".", "Context", ")", "{", "v", ":=", "&", "DatastoreFlag", "{", "}", "\n", "v", ".", "DatacenterFlag", ",", "ctx", "=", "NewDatacenterFlag", "(", "ctx", ")", "\n", "return", "v", ",", "ctx", "\n", "}" ]
// NewCustomDatastoreFlag creates and returns a new DatastoreFlag without // trying to retrieve an existing one from the specified context.
[ "NewCustomDatastoreFlag", "creates", "and", "returns", "a", "new", "DatastoreFlag", "without", "trying", "to", "retrieve", "an", "existing", "one", "from", "the", "specified", "context", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/datastore.go#L43-L47
train
vmware/govmomi
object/datastore_file_manager.go
NewFileManager
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 }
go
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 }
[ "func", "(", "d", "Datastore", ")", "NewFileManager", "(", "dc", "*", "Datacenter", ",", "force", "bool", ")", "*", "DatastoreFileManager", "{", "c", ":=", "d", ".", "Client", "(", ")", "\n\n", "m", ":=", "&", "DatastoreFileManager", "{", "Datacenter", ":", "dc", ",", "Datastore", ":", "&", "d", ",", "FileManager", ":", "NewFileManager", "(", "c", ")", ",", "VirtualDiskManager", ":", "NewVirtualDiskManager", "(", "c", ")", ",", "Force", ":", "force", ",", "DatacenterTarget", ":", "dc", ",", "}", "\n\n", "return", "m", "\n", "}" ]
// NewFileManager creates a new instance of DatastoreFileManager
[ "NewFileManager", "creates", "a", "new", "instance", "of", "DatastoreFileManager" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L45-L58
train
vmware/govmomi
object/datastore_file_manager.go
Delete
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) } }
go
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) } }
[ "func", "(", "m", "*", "DatastoreFileManager", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "error", "{", "switch", "path", ".", "Ext", "(", "name", ")", "{", "case", "\"", "\"", ":", "return", "m", ".", "DeleteVirtualDisk", "(", "ctx", ",", "name", ")", "\n", "default", ":", "return", "m", ".", "DeleteFile", "(", "ctx", ",", "name", ")", "\n", "}", "\n", "}" ]
// Delete dispatches to the appropriate Delete method based on file name extension
[ "Delete", "dispatches", "to", "the", "appropriate", "Delete", "method", "based", "on", "file", "name", "extension" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L74-L81
train
vmware/govmomi
object/datastore_file_manager.go
DeleteFile
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) }
go
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) }
[ "func", "(", "m", "*", "DatastoreFileManager", ")", "DeleteFile", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "error", "{", "p", ":=", "m", ".", "Path", "(", "name", ")", "\n\n", "task", ",", "err", ":=", "m", ".", "FileManager", ".", "DeleteDatastoreFile", "(", "ctx", ",", "p", ".", "String", "(", ")", ",", "m", ".", "Datacenter", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "m", ".", "wait", "(", "ctx", ",", "task", ")", "\n", "}" ]
// DeleteFile calls FileManager.DeleteDatastoreFile
[ "DeleteFile", "calls", "FileManager", ".", "DeleteDatastoreFile" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L84-L93
train
vmware/govmomi
object/datastore_file_manager.go
DeleteVirtualDisk
func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Context, name string) error { 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) }
go
func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Context, name string) error { 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) }
[ "func", "(", "m", "*", "DatastoreFileManager", ")", "DeleteVirtualDisk", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "error", "{", "p", ":=", "m", ".", "Path", "(", "name", ")", "\n\n", "var", "merr", "error", "\n\n", "if", "m", ".", "Force", "{", "merr", "=", "m", ".", "markDiskAsDeletable", "(", "ctx", ",", "p", ")", "\n", "}", "\n\n", "task", ",", "err", ":=", "m", ".", "VirtualDiskManager", ".", "DeleteVirtualDisk", "(", "ctx", ",", "p", ".", "String", "(", ")", ",", "m", ".", "Datacenter", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "p", ",", "merr", ")", "\n", "return", "err", "\n", "}", "\n\n", "return", "m", ".", "wait", "(", "ctx", ",", "task", ")", "\n", "}" ]
// 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.
[ "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", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L98-L114
train
vmware/govmomi
object/datastore_file_manager.go
Copy
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.VirtualDiskManager.CopyVirtualDisk(ctx, src, srcDC, dst, dstDC, nil, force) } } task, err := f(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force) if err != nil { return err } return m.wait(ctx, task) }
go
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.VirtualDiskManager.CopyVirtualDisk(ctx, src, srcDC, dst, dstDC, nil, force) } } task, err := f(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force) if err != nil { return err } return m.wait(ctx, task) }
[ "func", "(", "m", "*", "DatastoreFileManager", ")", "Copy", "(", "ctx", "context", ".", "Context", ",", "src", "string", ",", "dst", "string", ")", "error", "{", "srcp", ":=", "m", ".", "Path", "(", "src", ")", "\n", "dstp", ":=", "m", ".", "Path", "(", "dst", ")", "\n\n", "f", ":=", "m", ".", "FileManager", ".", "CopyDatastoreFile", "\n\n", "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", ".", "VirtualDiskManager", ".", "CopyVirtualDisk", "(", "ctx", ",", "src", ",", "srcDC", ",", "dst", ",", "dstDC", ",", "nil", ",", "force", ")", "\n", "}", "\n", "}", "\n\n", "task", ",", "err", ":=", "f", "(", "ctx", ",", "srcp", ".", "String", "(", ")", ",", "m", ".", "Datacenter", ",", "dstp", ".", "String", "(", ")", ",", "m", ".", "DatacenterTarget", ",", "m", ".", "Force", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "m", ".", "wait", "(", "ctx", ",", "task", ")", "\n", "}" ]
// Copy dispatches to the appropriate FileManager or VirtualDiskManager Copy method based on file name extension
[ "Copy", "dispatches", "to", "the", "appropriate", "FileManager", "or", "VirtualDiskManager", "Copy", "method", "based", "on", "file", "name", "extension" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L130-L149
train
vmware/govmomi
object/datastore_file_manager.go
MoveFile
func (m *DatastoreFileManager) MoveFile(ctx context.Context, src string, dst string) error { srcp := m.Path(src) dstp := m.Path(dst) task, err := m.FileManager.MoveDatastoreFile(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force) if err != nil { return err } return m.wait(ctx, task) }
go
func (m *DatastoreFileManager) MoveFile(ctx context.Context, src string, dst string) error { srcp := m.Path(src) dstp := m.Path(dst) task, err := m.FileManager.MoveDatastoreFile(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force) if err != nil { return err } return m.wait(ctx, task) }
[ "func", "(", "m", "*", "DatastoreFileManager", ")", "MoveFile", "(", "ctx", "context", ".", "Context", ",", "src", "string", ",", "dst", "string", ")", "error", "{", "srcp", ":=", "m", ".", "Path", "(", "src", ")", "\n", "dstp", ":=", "m", ".", "Path", "(", "dst", ")", "\n\n", "task", ",", "err", ":=", "m", ".", "FileManager", ".", "MoveDatastoreFile", "(", "ctx", ",", "srcp", ".", "String", "(", ")", ",", "m", ".", "Datacenter", ",", "dstp", ".", "String", "(", ")", ",", "m", ".", "DatacenterTarget", ",", "m", ".", "Force", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "m", ".", "wait", "(", "ctx", ",", "task", ")", "\n", "}" ]
// MoveFile calls FileManager.MoveDatastoreFile
[ "MoveFile", "calls", "FileManager", ".", "MoveDatastoreFile" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L152-L162
train
vmware/govmomi
object/datastore_file_manager.go
Move
func (m *DatastoreFileManager) Move(ctx context.Context, src string, dst string) error { srcp := m.Path(src) dstp := m.Path(dst) f := m.FileManager.MoveDatastoreFile if srcp.IsVMDK() { f = m.VirtualDiskManager.MoveVirtualDisk } task, err := f(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force) if err != nil { return err } return m.wait(ctx, task) }
go
func (m *DatastoreFileManager) Move(ctx context.Context, src string, dst string) error { srcp := m.Path(src) dstp := m.Path(dst) f := m.FileManager.MoveDatastoreFile if srcp.IsVMDK() { f = m.VirtualDiskManager.MoveVirtualDisk } task, err := f(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force) if err != nil { return err } return m.wait(ctx, task) }
[ "func", "(", "m", "*", "DatastoreFileManager", ")", "Move", "(", "ctx", "context", ".", "Context", ",", "src", "string", ",", "dst", "string", ")", "error", "{", "srcp", ":=", "m", ".", "Path", "(", "src", ")", "\n", "dstp", ":=", "m", ".", "Path", "(", "dst", ")", "\n\n", "f", ":=", "m", ".", "FileManager", ".", "MoveDatastoreFile", "\n\n", "if", "srcp", ".", "IsVMDK", "(", ")", "{", "f", "=", "m", ".", "VirtualDiskManager", ".", "MoveVirtualDisk", "\n", "}", "\n\n", "task", ",", "err", ":=", "f", "(", "ctx", ",", "srcp", ".", "String", "(", ")", ",", "m", ".", "Datacenter", ",", "dstp", ".", "String", "(", ")", ",", "m", ".", "DatacenterTarget", ",", "m", ".", "Force", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "m", ".", "wait", "(", "ctx", ",", "task", ")", "\n", "}" ]
// Move dispatches to the appropriate FileManager or VirtualDiskManager Move method based on file name extension
[ "Move", "dispatches", "to", "the", "appropriate", "FileManager", "or", "VirtualDiskManager", "Move", "method", "based", "on", "file", "name", "extension" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L165-L181
train
vmware/govmomi
object/datastore_file_manager.go
Path
func (m *DatastoreFileManager) Path(name string) *DatastorePath { var p DatastorePath if !p.FromString(name) { p.Path = name p.Datastore = m.Datastore.Name() } return &p }
go
func (m *DatastoreFileManager) Path(name string) *DatastorePath { var p DatastorePath if !p.FromString(name) { p.Path = name p.Datastore = m.Datastore.Name() } return &p }
[ "func", "(", "m", "*", "DatastoreFileManager", ")", "Path", "(", "name", "string", ")", "*", "DatastorePath", "{", "var", "p", "DatastorePath", "\n\n", "if", "!", "p", ".", "FromString", "(", "name", ")", "{", "p", ".", "Path", "=", "name", "\n", "p", ".", "Datastore", "=", "m", ".", "Datastore", ".", "Name", "(", ")", "\n", "}", "\n\n", "return", "&", "p", "\n", "}" ]
// Path converts path name to a DatastorePath
[ "Path", "converts", "path", "name", "to", "a", "DatastorePath" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file_manager.go#L184-L193
train
vmware/govmomi
nfc/lease.go
Abort
func (l *Lease) Abort(ctx context.Context, fault *types.LocalizedMethodFault) error { req := types.HttpNfcLeaseAbort{ This: l.Reference(), Fault: fault, } _, err := methods.HttpNfcLeaseAbort(ctx, l.c, &req) if err != nil { return err } return nil }
go
func (l *Lease) Abort(ctx context.Context, fault *types.LocalizedMethodFault) error { req := types.HttpNfcLeaseAbort{ This: l.Reference(), Fault: fault, } _, err := methods.HttpNfcLeaseAbort(ctx, l.c, &req) if err != nil { return err } return nil }
[ "func", "(", "l", "*", "Lease", ")", "Abort", "(", "ctx", "context", ".", "Context", ",", "fault", "*", "types", ".", "LocalizedMethodFault", ")", "error", "{", "req", ":=", "types", ".", "HttpNfcLeaseAbort", "{", "This", ":", "l", ".", "Reference", "(", ")", ",", "Fault", ":", "fault", ",", "}", "\n\n", "_", ",", "err", ":=", "methods", ".", "HttpNfcLeaseAbort", "(", "ctx", ",", "l", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Abort wraps methods.Abort
[ "Abort", "wraps", "methods", ".", "Abort" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/nfc/lease.go#L45-L57
train
vmware/govmomi
nfc/lease.go
Complete
func (l *Lease) Complete(ctx context.Context) error { req := types.HttpNfcLeaseComplete{ This: l.Reference(), } _, err := methods.HttpNfcLeaseComplete(ctx, l.c, &req) if err != nil { return err } return nil }
go
func (l *Lease) Complete(ctx context.Context) error { req := types.HttpNfcLeaseComplete{ This: l.Reference(), } _, err := methods.HttpNfcLeaseComplete(ctx, l.c, &req) if err != nil { return err } return nil }
[ "func", "(", "l", "*", "Lease", ")", "Complete", "(", "ctx", "context", ".", "Context", ")", "error", "{", "req", ":=", "types", ".", "HttpNfcLeaseComplete", "{", "This", ":", "l", ".", "Reference", "(", ")", ",", "}", "\n\n", "_", ",", "err", ":=", "methods", ".", "HttpNfcLeaseComplete", "(", "ctx", ",", "l", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Complete wraps methods.Complete
[ "Complete", "wraps", "methods", ".", "Complete" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/nfc/lease.go#L60-L71
train
vmware/govmomi
nfc/lease.go
GetManifest
func (l *Lease) GetManifest(ctx context.Context) error { req := types.HttpNfcLeaseGetManifest{ This: l.Reference(), } _, err := methods.HttpNfcLeaseGetManifest(ctx, l.c, &req) if err != nil { return err } return nil }
go
func (l *Lease) GetManifest(ctx context.Context) error { req := types.HttpNfcLeaseGetManifest{ This: l.Reference(), } _, err := methods.HttpNfcLeaseGetManifest(ctx, l.c, &req) if err != nil { return err } return nil }
[ "func", "(", "l", "*", "Lease", ")", "GetManifest", "(", "ctx", "context", ".", "Context", ")", "error", "{", "req", ":=", "types", ".", "HttpNfcLeaseGetManifest", "{", "This", ":", "l", ".", "Reference", "(", ")", ",", "}", "\n\n", "_", ",", "err", ":=", "methods", ".", "HttpNfcLeaseGetManifest", "(", "ctx", ",", "l", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// GetManifest wraps methods.GetManifest
[ "GetManifest", "wraps", "methods", ".", "GetManifest" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/nfc/lease.go#L74-L85
train
vmware/govmomi
nfc/lease.go
Progress
func (l *Lease) Progress(ctx context.Context, percent int32) error { req := types.HttpNfcLeaseProgress{ This: l.Reference(), Percent: percent, } _, err := methods.HttpNfcLeaseProgress(ctx, l.c, &req) if err != nil { return err } return nil }
go
func (l *Lease) Progress(ctx context.Context, percent int32) error { req := types.HttpNfcLeaseProgress{ This: l.Reference(), Percent: percent, } _, err := methods.HttpNfcLeaseProgress(ctx, l.c, &req) if err != nil { return err } return nil }
[ "func", "(", "l", "*", "Lease", ")", "Progress", "(", "ctx", "context", ".", "Context", ",", "percent", "int32", ")", "error", "{", "req", ":=", "types", ".", "HttpNfcLeaseProgress", "{", "This", ":", "l", ".", "Reference", "(", ")", ",", "Percent", ":", "percent", ",", "}", "\n\n", "_", ",", "err", ":=", "methods", ".", "HttpNfcLeaseProgress", "(", "ctx", ",", "l", ".", "c", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Progress wraps methods.Progress
[ "Progress", "wraps", "methods", ".", "Progress" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/nfc/lease.go#L88-L100
train
vmware/govmomi
vapi/library/library.go
FindLibrary
func (c *Manager) FindLibrary(ctx context.Context, search Find) ([]string, error) { url := internal.URL(c, internal.LibraryPath).WithAction("find") spec := struct { Spec Find `json:"spec"` }{search} var res []string return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res) }
go
func (c *Manager) FindLibrary(ctx context.Context, search Find) ([]string, error) { url := internal.URL(c, internal.LibraryPath).WithAction("find") spec := struct { Spec Find `json:"spec"` }{search} var res []string return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res) }
[ "func", "(", "c", "*", "Manager", ")", "FindLibrary", "(", "ctx", "context", ".", "Context", ",", "search", "Find", ")", "(", "[", "]", "string", ",", "error", ")", "{", "url", ":=", "internal", ".", "URL", "(", "c", ",", "internal", ".", "LibraryPath", ")", ".", "WithAction", "(", "\"", "\"", ")", "\n", "spec", ":=", "struct", "{", "Spec", "Find", "`json:\"spec\"`", "\n", "}", "{", "search", "}", "\n", "var", "res", "[", "]", "string", "\n", "return", "res", ",", "c", ".", "Do", "(", "ctx", ",", "url", ".", "Request", "(", "http", ".", "MethodPost", ",", "spec", ")", ",", "&", "res", ")", "\n", "}" ]
// FindLibrary returns one or more libraries that match the provided search // criteria. // // The provided name is case-insensitive. // // Either the name or type of library may be set to empty values in order // to search for all libraries, all libraries with a specific name, regardless // of type, or all libraries of a specified type.
[ "FindLibrary", "returns", "one", "or", "more", "libraries", "that", "match", "the", "provided", "search", "criteria", ".", "The", "provided", "name", "is", "case", "-", "insensitive", ".", "Either", "the", "name", "or", "type", "of", "library", "may", "be", "set", "to", "empty", "values", "in", "order", "to", "search", "for", "all", "libraries", "all", "libraries", "with", "a", "specific", "name", "regardless", "of", "type", "or", "all", "libraries", "of", "a", "specified", "type", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library.go#L83-L90
train
vmware/govmomi
vapi/library/library.go
CreateLibrary
func (c *Manager) CreateLibrary(ctx context.Context, library Library) (string, error) { if library.Type != "LOCAL" { return "", fmt.Errorf("unsupported library type: %q", library.Type) } spec := struct { Library Library `json:"create_spec"` }{library} url := internal.URL(c, internal.LocalLibraryPath) var res string return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res) }
go
func (c *Manager) CreateLibrary(ctx context.Context, library Library) (string, error) { if library.Type != "LOCAL" { return "", fmt.Errorf("unsupported library type: %q", library.Type) } spec := struct { Library Library `json:"create_spec"` }{library} url := internal.URL(c, internal.LocalLibraryPath) var res string return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res) }
[ "func", "(", "c", "*", "Manager", ")", "CreateLibrary", "(", "ctx", "context", ".", "Context", ",", "library", "Library", ")", "(", "string", ",", "error", ")", "{", "if", "library", ".", "Type", "!=", "\"", "\"", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "library", ".", "Type", ")", "\n", "}", "\n", "spec", ":=", "struct", "{", "Library", "Library", "`json:\"create_spec\"`", "\n", "}", "{", "library", "}", "\n", "url", ":=", "internal", ".", "URL", "(", "c", ",", "internal", ".", "LocalLibraryPath", ")", "\n", "var", "res", "string", "\n", "return", "res", ",", "c", ".", "Do", "(", "ctx", ",", "url", ".", "Request", "(", "http", ".", "MethodPost", ",", "spec", ")", ",", "&", "res", ")", "\n", "}" ]
// CreateLibrary creates a new library with the given Type, Name, // Description, and CategoryID.
[ "CreateLibrary", "creates", "a", "new", "library", "with", "the", "given", "Type", "Name", "Description", "and", "CategoryID", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library.go#L94-L104
train
vmware/govmomi
vapi/library/library.go
DeleteLibrary
func (c *Manager) DeleteLibrary(ctx context.Context, library *Library) error { url := internal.URL(c, internal.LocalLibraryPath).WithID(library.ID) return c.Do(ctx, url.Request(http.MethodDelete), nil) }
go
func (c *Manager) DeleteLibrary(ctx context.Context, library *Library) error { url := internal.URL(c, internal.LocalLibraryPath).WithID(library.ID) return c.Do(ctx, url.Request(http.MethodDelete), nil) }
[ "func", "(", "c", "*", "Manager", ")", "DeleteLibrary", "(", "ctx", "context", ".", "Context", ",", "library", "*", "Library", ")", "error", "{", "url", ":=", "internal", ".", "URL", "(", "c", ",", "internal", ".", "LocalLibraryPath", ")", ".", "WithID", "(", "library", ".", "ID", ")", "\n", "return", "c", ".", "Do", "(", "ctx", ",", "url", ".", "Request", "(", "http", ".", "MethodDelete", ")", ",", "nil", ")", "\n", "}" ]
// DeleteLibrary deletes an existing library.
[ "DeleteLibrary", "deletes", "an", "existing", "library", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library.go#L107-L110
train
vmware/govmomi
vapi/library/library.go
ListLibraries
func (c *Manager) ListLibraries(ctx context.Context) ([]string, error) { url := internal.URL(c, internal.LibraryPath) var res []string return res, c.Do(ctx, url.Request(http.MethodGet), &res) }
go
func (c *Manager) ListLibraries(ctx context.Context) ([]string, error) { url := internal.URL(c, internal.LibraryPath) var res []string return res, c.Do(ctx, url.Request(http.MethodGet), &res) }
[ "func", "(", "c", "*", "Manager", ")", "ListLibraries", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "string", ",", "error", ")", "{", "url", ":=", "internal", ".", "URL", "(", "c", ",", "internal", ".", "LibraryPath", ")", "\n", "var", "res", "[", "]", "string", "\n", "return", "res", ",", "c", ".", "Do", "(", "ctx", ",", "url", ".", "Request", "(", "http", ".", "MethodGet", ")", ",", "&", "res", ")", "\n", "}" ]
// ListLibraries returns a list of all content library IDs in the system.
[ "ListLibraries", "returns", "a", "list", "of", "all", "content", "library", "IDs", "in", "the", "system", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library.go#L113-L117
train
vmware/govmomi
vapi/library/library.go
GetLibraryByID
func (c *Manager) GetLibraryByID(ctx context.Context, id string) (*Library, error) { url := internal.URL(c, internal.LibraryPath).WithID(id) var res Library return &res, c.Do(ctx, url.Request(http.MethodGet), &res) }
go
func (c *Manager) GetLibraryByID(ctx context.Context, id string) (*Library, error) { url := internal.URL(c, internal.LibraryPath).WithID(id) var res Library return &res, c.Do(ctx, url.Request(http.MethodGet), &res) }
[ "func", "(", "c", "*", "Manager", ")", "GetLibraryByID", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "*", "Library", ",", "error", ")", "{", "url", ":=", "internal", ".", "URL", "(", "c", ",", "internal", ".", "LibraryPath", ")", ".", "WithID", "(", "id", ")", "\n", "var", "res", "Library", "\n", "return", "&", "res", ",", "c", ".", "Do", "(", "ctx", ",", "url", ".", "Request", "(", "http", ".", "MethodGet", ")", ",", "&", "res", ")", "\n", "}" ]
// GetLibraryByID returns information on a library for the given ID.
[ "GetLibraryByID", "returns", "information", "on", "a", "library", "for", "the", "given", "ID", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library.go#L120-L124
train
vmware/govmomi
vapi/library/library.go
GetLibraryByName
func (c *Manager) GetLibraryByName(ctx context.Context, name string) (*Library, error) { // Lookup by name libraries, err := c.GetLibraries(ctx) if err != nil { return nil, err } for i := range libraries { if libraries[i].Name == name { return &libraries[i], nil } } return nil, fmt.Errorf("library name (%s) not found", name) }
go
func (c *Manager) GetLibraryByName(ctx context.Context, name string) (*Library, error) { // Lookup by name libraries, err := c.GetLibraries(ctx) if err != nil { return nil, err } for i := range libraries { if libraries[i].Name == name { return &libraries[i], nil } } return nil, fmt.Errorf("library name (%s) not found", name) }
[ "func", "(", "c", "*", "Manager", ")", "GetLibraryByName", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "(", "*", "Library", ",", "error", ")", "{", "// Lookup by name", "libraries", ",", "err", ":=", "c", ".", "GetLibraries", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "i", ":=", "range", "libraries", "{", "if", "libraries", "[", "i", "]", ".", "Name", "==", "name", "{", "return", "&", "libraries", "[", "i", "]", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}" ]
// GetLibraryByName returns information on a library for the given name.
[ "GetLibraryByName", "returns", "information", "on", "a", "library", "for", "the", "given", "name", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library.go#L127-L139
train
vmware/govmomi
vapi/library/library.go
GetLibraries
func (c *Manager) GetLibraries(ctx context.Context) ([]Library, error) { ids, err := c.ListLibraries(ctx) if err != nil { return nil, fmt.Errorf("get libraries failed for: %s", err) } var libraries []Library for _, id := range ids { library, err := c.GetLibraryByID(ctx, id) if err != nil { return nil, fmt.Errorf("get library %s failed for %s", id, err) } libraries = append(libraries, *library) } return libraries, nil }
go
func (c *Manager) GetLibraries(ctx context.Context) ([]Library, error) { ids, err := c.ListLibraries(ctx) if err != nil { return nil, fmt.Errorf("get libraries failed for: %s", err) } var libraries []Library for _, id := range ids { library, err := c.GetLibraryByID(ctx, id) if err != nil { return nil, fmt.Errorf("get library %s failed for %s", id, err) } libraries = append(libraries, *library) } return libraries, nil }
[ "func", "(", "c", "*", "Manager", ")", "GetLibraries", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "Library", ",", "error", ")", "{", "ids", ",", "err", ":=", "c", ".", "ListLibraries", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "var", "libraries", "[", "]", "Library", "\n", "for", "_", ",", "id", ":=", "range", "ids", "{", "library", ",", "err", ":=", "c", ".", "GetLibraryByID", "(", "ctx", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "id", ",", "err", ")", "\n", "}", "\n\n", "libraries", "=", "append", "(", "libraries", ",", "*", "library", ")", "\n\n", "}", "\n", "return", "libraries", ",", "nil", "\n", "}" ]
// GetLibraries returns a list of all content library details in the system.
[ "GetLibraries", "returns", "a", "list", "of", "all", "content", "library", "details", "in", "the", "system", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library.go#L142-L159
train
vmware/govmomi
simulator/property_collector.go
wrapValue
func wrapValue(rval reflect.Value, rtype reflect.Type) interface{} { pval := rval.Interface() if rval.Kind() == reflect.Slice { // Convert slice to types.ArrayOf* switch v := pval.(type) { case []string: pval = &types.ArrayOfString{ String: v, } case []uint8: pval = &types.ArrayOfByte{ Byte: v, } case []int16: pval = &types.ArrayOfShort{ Short: v, } case []int32: pval = &types.ArrayOfInt{ Int: v, } case []int64: pval = &types.ArrayOfLong{ Long: v, } default: kind := rtype.Elem().Name() // Remove govmomi interface prefix name kind = strings.TrimPrefix(kind, "Base") akind, _ := defaultMapType("ArrayOf" + kind) a := reflect.New(akind) a.Elem().FieldByName(kind).Set(rval) pval = a.Interface() } } return pval }
go
func wrapValue(rval reflect.Value, rtype reflect.Type) interface{} { pval := rval.Interface() if rval.Kind() == reflect.Slice { // Convert slice to types.ArrayOf* switch v := pval.(type) { case []string: pval = &types.ArrayOfString{ String: v, } case []uint8: pval = &types.ArrayOfByte{ Byte: v, } case []int16: pval = &types.ArrayOfShort{ Short: v, } case []int32: pval = &types.ArrayOfInt{ Int: v, } case []int64: pval = &types.ArrayOfLong{ Long: v, } default: kind := rtype.Elem().Name() // Remove govmomi interface prefix name kind = strings.TrimPrefix(kind, "Base") akind, _ := defaultMapType("ArrayOf" + kind) a := reflect.New(akind) a.Elem().FieldByName(kind).Set(rval) pval = a.Interface() } } return pval }
[ "func", "wrapValue", "(", "rval", "reflect", ".", "Value", ",", "rtype", "reflect", ".", "Type", ")", "interface", "{", "}", "{", "pval", ":=", "rval", ".", "Interface", "(", ")", "\n\n", "if", "rval", ".", "Kind", "(", ")", "==", "reflect", ".", "Slice", "{", "// Convert slice to types.ArrayOf*", "switch", "v", ":=", "pval", ".", "(", "type", ")", "{", "case", "[", "]", "string", ":", "pval", "=", "&", "types", ".", "ArrayOfString", "{", "String", ":", "v", ",", "}", "\n", "case", "[", "]", "uint8", ":", "pval", "=", "&", "types", ".", "ArrayOfByte", "{", "Byte", ":", "v", ",", "}", "\n", "case", "[", "]", "int16", ":", "pval", "=", "&", "types", ".", "ArrayOfShort", "{", "Short", ":", "v", ",", "}", "\n", "case", "[", "]", "int32", ":", "pval", "=", "&", "types", ".", "ArrayOfInt", "{", "Int", ":", "v", ",", "}", "\n", "case", "[", "]", "int64", ":", "pval", "=", "&", "types", ".", "ArrayOfLong", "{", "Long", ":", "v", ",", "}", "\n", "default", ":", "kind", ":=", "rtype", ".", "Elem", "(", ")", ".", "Name", "(", ")", "\n", "// Remove govmomi interface prefix name", "kind", "=", "strings", ".", "TrimPrefix", "(", "kind", ",", "\"", "\"", ")", "\n", "akind", ",", "_", ":=", "defaultMapType", "(", "\"", "\"", "+", "kind", ")", "\n", "a", ":=", "reflect", ".", "New", "(", "akind", ")", "\n", "a", ".", "Elem", "(", ")", ".", "FieldByName", "(", "kind", ")", ".", "Set", "(", "rval", ")", "\n", "pval", "=", "a", ".", "Interface", "(", ")", "\n", "}", "\n", "}", "\n\n", "return", "pval", "\n", "}" ]
// wrapValue converts slice types to the appropriate ArrayOf type used in property collector responses.
[ "wrapValue", "converts", "slice", "types", "to", "the", "appropriate", "ArrayOf", "type", "used", "in", "property", "collector", "responses", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/property_collector.go#L113-L151
train
vmware/govmomi
simulator/property_collector.go
RetrieveProperties
func (pc *PropertyCollector) RetrieveProperties(ctx *Context, r *types.RetrieveProperties) soap.HasFault { body := &methods.RetrievePropertiesBody{} res := pc.RetrievePropertiesEx(ctx, &types.RetrievePropertiesEx{ This: r.This, SpecSet: r.SpecSet, }) if res.Fault() != nil { body.Fault_ = res.Fault() } else { body.Res = &types.RetrievePropertiesResponse{ Returnval: res.(*methods.RetrievePropertiesExBody).Res.Returnval.Objects, } } return body }
go
func (pc *PropertyCollector) RetrieveProperties(ctx *Context, r *types.RetrieveProperties) soap.HasFault { body := &methods.RetrievePropertiesBody{} res := pc.RetrievePropertiesEx(ctx, &types.RetrievePropertiesEx{ This: r.This, SpecSet: r.SpecSet, }) if res.Fault() != nil { body.Fault_ = res.Fault() } else { body.Res = &types.RetrievePropertiesResponse{ Returnval: res.(*methods.RetrievePropertiesExBody).Res.Returnval.Objects, } } return body }
[ "func", "(", "pc", "*", "PropertyCollector", ")", "RetrieveProperties", "(", "ctx", "*", "Context", ",", "r", "*", "types", ".", "RetrieveProperties", ")", "soap", ".", "HasFault", "{", "body", ":=", "&", "methods", ".", "RetrievePropertiesBody", "{", "}", "\n\n", "res", ":=", "pc", ".", "RetrievePropertiesEx", "(", "ctx", ",", "&", "types", ".", "RetrievePropertiesEx", "{", "This", ":", "r", ".", "This", ",", "SpecSet", ":", "r", ".", "SpecSet", ",", "}", ")", "\n\n", "if", "res", ".", "Fault", "(", ")", "!=", "nil", "{", "body", ".", "Fault_", "=", "res", ".", "Fault", "(", ")", "\n", "}", "else", "{", "body", ".", "Res", "=", "&", "types", ".", "RetrievePropertiesResponse", "{", "Returnval", ":", "res", ".", "(", "*", "methods", ".", "RetrievePropertiesExBody", ")", ".", "Res", ".", "Returnval", ".", "Objects", ",", "}", "\n", "}", "\n\n", "return", "body", "\n", "}" ]
// RetrieveProperties is deprecated, but govmomi is still using it at the moment.
[ "RetrieveProperties", "is", "deprecated", "but", "govmomi", "is", "still", "using", "it", "at", "the", "moment", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/property_collector.go#L531-L548
train
vmware/govmomi
simulator/property_collector.go
WaitForUpdates
func (pc *PropertyCollector) WaitForUpdates(ctx *Context, r *types.WaitForUpdates) soap.HasFault { body := &methods.WaitForUpdatesBody{} res := pc.WaitForUpdatesEx(ctx, &types.WaitForUpdatesEx{ This: r.This, Version: r.Version, }) if res.Fault() != nil { body.Fault_ = res.Fault() } else { body.Res = &types.WaitForUpdatesResponse{ Returnval: *res.(*methods.WaitForUpdatesExBody).Res.Returnval, } } return body }
go
func (pc *PropertyCollector) WaitForUpdates(ctx *Context, r *types.WaitForUpdates) soap.HasFault { body := &methods.WaitForUpdatesBody{} res := pc.WaitForUpdatesEx(ctx, &types.WaitForUpdatesEx{ This: r.This, Version: r.Version, }) if res.Fault() != nil { body.Fault_ = res.Fault() } else { body.Res = &types.WaitForUpdatesResponse{ Returnval: *res.(*methods.WaitForUpdatesExBody).Res.Returnval, } } return body }
[ "func", "(", "pc", "*", "PropertyCollector", ")", "WaitForUpdates", "(", "ctx", "*", "Context", ",", "r", "*", "types", ".", "WaitForUpdates", ")", "soap", ".", "HasFault", "{", "body", ":=", "&", "methods", ".", "WaitForUpdatesBody", "{", "}", "\n\n", "res", ":=", "pc", ".", "WaitForUpdatesEx", "(", "ctx", ",", "&", "types", ".", "WaitForUpdatesEx", "{", "This", ":", "r", ".", "This", ",", "Version", ":", "r", ".", "Version", ",", "}", ")", "\n\n", "if", "res", ".", "Fault", "(", ")", "!=", "nil", "{", "body", ".", "Fault_", "=", "res", ".", "Fault", "(", ")", "\n", "}", "else", "{", "body", ".", "Res", "=", "&", "types", ".", "WaitForUpdatesResponse", "{", "Returnval", ":", "*", "res", ".", "(", "*", "methods", ".", "WaitForUpdatesExBody", ")", ".", "Res", ".", "Returnval", ",", "}", "\n", "}", "\n\n", "return", "body", "\n", "}" ]
// WaitForUpdates is deprecated, but pyvmomi is still using it at the moment.
[ "WaitForUpdates", "is", "deprecated", "but", "pyvmomi", "is", "still", "using", "it", "at", "the", "moment", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/property_collector.go#L759-L776
train
vmware/govmomi
simulator/property_collector.go
Fetch
func (pc *PropertyCollector) Fetch(ctx *Context, req *internal.Fetch) soap.HasFault { body := new(internal.FetchBody) if req.This == vim25.ServiceInstance && req.Prop == "content" { content := ctx.Map.content() // ovftool uses API version for 6.0 and fails when these fields are non-nil; TODO content.VStorageObjectManager = nil content.HostProfileManager = nil content.HostSpecManager = nil content.CryptoManager = nil content.HostProfileManager = nil content.HealthUpdateManager = nil content.FailoverClusterConfigurator = nil content.FailoverClusterManager = nil body.Res = &internal.FetchResponse{ Returnval: content, } return body } if ctx.Map.Get(req.This) == nil { // The Fetch method supports use of super class types, this is a quick hack to support the cases used by ovftool switch req.This.Type { case "ManagedEntity": for o := range ctx.Map.objects { if o.Value == req.This.Value { req.This.Type = o.Type break } } case "ComputeResource": req.This.Type = "Cluster" + req.This.Type } } res := pc.RetrievePropertiesEx(ctx, &types.RetrievePropertiesEx{ SpecSet: []types.PropertyFilterSpec{{ PropSet: []types.PropertySpec{{ Type: req.This.Type, PathSet: []string{req.Prop}, }}, ObjectSet: []types.ObjectSpec{{ Obj: req.This, }}, }}}) if res.Fault() != nil { return res } obj := res.(*methods.RetrievePropertiesExBody).Res.Returnval.Objects[0] if len(obj.PropSet) == 0 { fault := obj.MissingSet[0].Fault body.Fault_ = Fault(fault.LocalizedMessage, fault.Fault) return body } body.Res = &internal.FetchResponse{ Returnval: obj.PropSet[0].Val, } return body }
go
func (pc *PropertyCollector) Fetch(ctx *Context, req *internal.Fetch) soap.HasFault { body := new(internal.FetchBody) if req.This == vim25.ServiceInstance && req.Prop == "content" { content := ctx.Map.content() // ovftool uses API version for 6.0 and fails when these fields are non-nil; TODO content.VStorageObjectManager = nil content.HostProfileManager = nil content.HostSpecManager = nil content.CryptoManager = nil content.HostProfileManager = nil content.HealthUpdateManager = nil content.FailoverClusterConfigurator = nil content.FailoverClusterManager = nil body.Res = &internal.FetchResponse{ Returnval: content, } return body } if ctx.Map.Get(req.This) == nil { // The Fetch method supports use of super class types, this is a quick hack to support the cases used by ovftool switch req.This.Type { case "ManagedEntity": for o := range ctx.Map.objects { if o.Value == req.This.Value { req.This.Type = o.Type break } } case "ComputeResource": req.This.Type = "Cluster" + req.This.Type } } res := pc.RetrievePropertiesEx(ctx, &types.RetrievePropertiesEx{ SpecSet: []types.PropertyFilterSpec{{ PropSet: []types.PropertySpec{{ Type: req.This.Type, PathSet: []string{req.Prop}, }}, ObjectSet: []types.ObjectSpec{{ Obj: req.This, }}, }}}) if res.Fault() != nil { return res } obj := res.(*methods.RetrievePropertiesExBody).Res.Returnval.Objects[0] if len(obj.PropSet) == 0 { fault := obj.MissingSet[0].Fault body.Fault_ = Fault(fault.LocalizedMessage, fault.Fault) return body } body.Res = &internal.FetchResponse{ Returnval: obj.PropSet[0].Val, } return body }
[ "func", "(", "pc", "*", "PropertyCollector", ")", "Fetch", "(", "ctx", "*", "Context", ",", "req", "*", "internal", ".", "Fetch", ")", "soap", ".", "HasFault", "{", "body", ":=", "new", "(", "internal", ".", "FetchBody", ")", "\n\n", "if", "req", ".", "This", "==", "vim25", ".", "ServiceInstance", "&&", "req", ".", "Prop", "==", "\"", "\"", "{", "content", ":=", "ctx", ".", "Map", ".", "content", "(", ")", "\n", "// ovftool uses API version for 6.0 and fails when these fields are non-nil; TODO", "content", ".", "VStorageObjectManager", "=", "nil", "\n", "content", ".", "HostProfileManager", "=", "nil", "\n", "content", ".", "HostSpecManager", "=", "nil", "\n", "content", ".", "CryptoManager", "=", "nil", "\n", "content", ".", "HostProfileManager", "=", "nil", "\n", "content", ".", "HealthUpdateManager", "=", "nil", "\n", "content", ".", "FailoverClusterConfigurator", "=", "nil", "\n", "content", ".", "FailoverClusterManager", "=", "nil", "\n", "body", ".", "Res", "=", "&", "internal", ".", "FetchResponse", "{", "Returnval", ":", "content", ",", "}", "\n", "return", "body", "\n", "}", "\n\n", "if", "ctx", ".", "Map", ".", "Get", "(", "req", ".", "This", ")", "==", "nil", "{", "// The Fetch method supports use of super class types, this is a quick hack to support the cases used by ovftool", "switch", "req", ".", "This", ".", "Type", "{", "case", "\"", "\"", ":", "for", "o", ":=", "range", "ctx", ".", "Map", ".", "objects", "{", "if", "o", ".", "Value", "==", "req", ".", "This", ".", "Value", "{", "req", ".", "This", ".", "Type", "=", "o", ".", "Type", "\n", "break", "\n", "}", "\n", "}", "\n", "case", "\"", "\"", ":", "req", ".", "This", ".", "Type", "=", "\"", "\"", "+", "req", ".", "This", ".", "Type", "\n", "}", "\n", "}", "\n\n", "res", ":=", "pc", ".", "RetrievePropertiesEx", "(", "ctx", ",", "&", "types", ".", "RetrievePropertiesEx", "{", "SpecSet", ":", "[", "]", "types", ".", "PropertyFilterSpec", "{", "{", "PropSet", ":", "[", "]", "types", ".", "PropertySpec", "{", "{", "Type", ":", "req", ".", "This", ".", "Type", ",", "PathSet", ":", "[", "]", "string", "{", "req", ".", "Prop", "}", ",", "}", "}", ",", "ObjectSet", ":", "[", "]", "types", ".", "ObjectSpec", "{", "{", "Obj", ":", "req", ".", "This", ",", "}", "}", ",", "}", "}", "}", ")", "\n\n", "if", "res", ".", "Fault", "(", ")", "!=", "nil", "{", "return", "res", "\n", "}", "\n\n", "obj", ":=", "res", ".", "(", "*", "methods", ".", "RetrievePropertiesExBody", ")", ".", "Res", ".", "Returnval", ".", "Objects", "[", "0", "]", "\n", "if", "len", "(", "obj", ".", "PropSet", ")", "==", "0", "{", "fault", ":=", "obj", ".", "MissingSet", "[", "0", "]", ".", "Fault", "\n", "body", ".", "Fault_", "=", "Fault", "(", "fault", ".", "LocalizedMessage", ",", "fault", ".", "Fault", ")", "\n", "return", "body", "\n", "}", "\n\n", "body", ".", "Res", "=", "&", "internal", ".", "FetchResponse", "{", "Returnval", ":", "obj", ".", "PropSet", "[", "0", "]", ".", "Val", ",", "}", "\n", "return", "body", "\n", "}" ]
// Fetch is not documented in the vSphere SDK, but ovftool depends on it. // A Fetch request is converted to a RetrievePropertiesEx method call by vcsim.
[ "Fetch", "is", "not", "documented", "in", "the", "vSphere", "SDK", "but", "ovftool", "depends", "on", "it", ".", "A", "Fetch", "request", "is", "converted", "to", "a", "RetrievePropertiesEx", "method", "call", "by", "vcsim", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/property_collector.go#L780-L841
train
vmware/govmomi
object/datastore_path.go
FromString
func (p *DatastorePath) FromString(s string) bool { if s == "" { return false } s = strings.TrimSpace(s) if !strings.HasPrefix(s, "[") { return false } s = s[1:] ix := strings.Index(s, "]") if ix < 0 { return false } p.Datastore = s[:ix] p.Path = strings.TrimSpace(s[ix+1:]) return true }
go
func (p *DatastorePath) FromString(s string) bool { if s == "" { return false } s = strings.TrimSpace(s) if !strings.HasPrefix(s, "[") { return false } s = s[1:] ix := strings.Index(s, "]") if ix < 0 { return false } p.Datastore = s[:ix] p.Path = strings.TrimSpace(s[ix+1:]) return true }
[ "func", "(", "p", "*", "DatastorePath", ")", "FromString", "(", "s", "string", ")", "bool", "{", "if", "s", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n\n", "s", "=", "strings", ".", "TrimSpace", "(", "s", ")", "\n\n", "if", "!", "strings", ".", "HasPrefix", "(", "s", ",", "\"", "\"", ")", "{", "return", "false", "\n", "}", "\n\n", "s", "=", "s", "[", "1", ":", "]", "\n\n", "ix", ":=", "strings", ".", "Index", "(", "s", ",", "\"", "\"", ")", "\n", "if", "ix", "<", "0", "{", "return", "false", "\n", "}", "\n\n", "p", ".", "Datastore", "=", "s", "[", ":", "ix", "]", "\n", "p", ".", "Path", "=", "strings", ".", "TrimSpace", "(", "s", "[", "ix", "+", "1", ":", "]", ")", "\n\n", "return", "true", "\n", "}" ]
// FromString parses a datastore path. // Returns true if the path could be parsed, false otherwise.
[ "FromString", "parses", "a", "datastore", "path", ".", "Returns", "true", "if", "the", "path", "could", "be", "parsed", "false", "otherwise", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_path.go#L33-L55
train
vmware/govmomi
object/datastore_path.go
String
func (p *DatastorePath) String() string { s := fmt.Sprintf("[%s]", p.Datastore) if p.Path == "" { return s } return strings.Join([]string{s, p.Path}, " ") }
go
func (p *DatastorePath) String() string { s := fmt.Sprintf("[%s]", p.Datastore) if p.Path == "" { return s } return strings.Join([]string{s, p.Path}, " ") }
[ "func", "(", "p", "*", "DatastorePath", ")", "String", "(", ")", "string", "{", "s", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "Datastore", ")", "\n\n", "if", "p", ".", "Path", "==", "\"", "\"", "{", "return", "s", "\n", "}", "\n\n", "return", "strings", ".", "Join", "(", "[", "]", "string", "{", "s", ",", "p", ".", "Path", "}", ",", "\"", "\"", ")", "\n", "}" ]
// String formats a datastore path.
[ "String", "formats", "a", "datastore", "path", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_path.go#L58-L66
train
vmware/govmomi
object/common.go
Name
func (c Common) Name() string { if c.InventoryPath == "" { return "" } return path.Base(c.InventoryPath) }
go
func (c Common) Name() string { if c.InventoryPath == "" { return "" } return path.Base(c.InventoryPath) }
[ "func", "(", "c", "Common", ")", "Name", "(", ")", "string", "{", "if", "c", ".", "InventoryPath", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "path", ".", "Base", "(", "c", ".", "InventoryPath", ")", "\n", "}" ]
// Name returns the base name of the InventoryPath field
[ "Name", "returns", "the", "base", "name", "of", "the", "InventoryPath", "field" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/common.go#L67-L72
train
vmware/govmomi
object/common.go
ObjectName
func (c Common) ObjectName(ctx context.Context) (string, error) { var o mo.ManagedEntity err := c.Properties(ctx, c.Reference(), []string{"name"}, &o) if err != nil { return "", err } if o.Name != "" { return o.Name, nil } // Network has its own "name" field... var n mo.Network err = c.Properties(ctx, c.Reference(), []string{"name"}, &n) if err != nil { return "", err } return n.Name, nil }
go
func (c Common) ObjectName(ctx context.Context) (string, error) { var o mo.ManagedEntity err := c.Properties(ctx, c.Reference(), []string{"name"}, &o) if err != nil { return "", err } if o.Name != "" { return o.Name, nil } // Network has its own "name" field... var n mo.Network err = c.Properties(ctx, c.Reference(), []string{"name"}, &n) if err != nil { return "", err } return n.Name, nil }
[ "func", "(", "c", "Common", ")", "ObjectName", "(", "ctx", "context", ".", "Context", ")", "(", "string", ",", "error", ")", "{", "var", "o", "mo", ".", "ManagedEntity", "\n\n", "err", ":=", "c", ".", "Properties", "(", "ctx", ",", "c", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "o", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "o", ".", "Name", "!=", "\"", "\"", "{", "return", "o", ".", "Name", ",", "nil", "\n", "}", "\n\n", "// Network has its own \"name\" field...", "var", "n", "mo", ".", "Network", "\n\n", "err", "=", "c", ".", "Properties", "(", "ctx", ",", "c", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "n", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "n", ".", "Name", ",", "nil", "\n", "}" ]
// ObjectName returns the base name of the InventoryPath field if set, // otherwise fetches the mo.ManagedEntity.Name field via the property collector.
[ "ObjectName", "returns", "the", "base", "name", "of", "the", "InventoryPath", "field", "if", "set", "otherwise", "fetches", "the", "mo", ".", "ManagedEntity", ".", "Name", "field", "via", "the", "property", "collector", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/common.go#L80-L101
train
vmware/govmomi
session/manager.go
UserSession
func (sm *Manager) UserSession(ctx context.Context) (*types.UserSession, error) { var mgr mo.SessionManager pc := property.DefaultCollector(sm.client) err := pc.RetrieveOne(ctx, sm.Reference(), []string{"currentSession"}, &mgr) if err != nil { // It's OK if we can't retrieve properties because we're not authenticated if f, ok := err.(types.HasFault); ok { switch f.Fault().(type) { case *types.NotAuthenticated: return nil, nil } } return nil, err } return mgr.CurrentSession, nil }
go
func (sm *Manager) UserSession(ctx context.Context) (*types.UserSession, error) { var mgr mo.SessionManager pc := property.DefaultCollector(sm.client) err := pc.RetrieveOne(ctx, sm.Reference(), []string{"currentSession"}, &mgr) if err != nil { // It's OK if we can't retrieve properties because we're not authenticated if f, ok := err.(types.HasFault); ok { switch f.Fault().(type) { case *types.NotAuthenticated: return nil, nil } } return nil, err } return mgr.CurrentSession, nil }
[ "func", "(", "sm", "*", "Manager", ")", "UserSession", "(", "ctx", "context", ".", "Context", ")", "(", "*", "types", ".", "UserSession", ",", "error", ")", "{", "var", "mgr", "mo", ".", "SessionManager", "\n\n", "pc", ":=", "property", ".", "DefaultCollector", "(", "sm", ".", "client", ")", "\n", "err", ":=", "pc", ".", "RetrieveOne", "(", "ctx", ",", "sm", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "&", "mgr", ")", "\n", "if", "err", "!=", "nil", "{", "// It's OK if we can't retrieve properties because we're not authenticated", "if", "f", ",", "ok", ":=", "err", ".", "(", "types", ".", "HasFault", ")", ";", "ok", "{", "switch", "f", ".", "Fault", "(", ")", ".", "(", "type", ")", "{", "case", "*", "types", ".", "NotAuthenticated", ":", "return", "nil", ",", "nil", "\n", "}", "\n", "}", "\n\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "mgr", ".", "CurrentSession", ",", "nil", "\n", "}" ]
// UserSession retrieves and returns the SessionManager's CurrentSession field. // Nil is returned if the session is not authenticated.
[ "UserSession", "retrieves", "and", "returns", "the", "SessionManager", "s", "CurrentSession", "field", ".", "Nil", "is", "returned", "if", "the", "session", "is", "not", "authenticated", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/session/manager.go#L162-L180
train
vmware/govmomi
session/manager.go
SessionIsActive
func (sm *Manager) SessionIsActive(ctx context.Context) (bool, error) { if sm.userSession == nil { return false, nil } req := types.SessionIsActive{ This: sm.Reference(), SessionID: sm.userSession.Key, UserName: sm.userSession.UserName, } active, err := methods.SessionIsActive(ctx, sm.client, &req) if err != nil { return false, err } return active.Returnval, err }
go
func (sm *Manager) SessionIsActive(ctx context.Context) (bool, error) { if sm.userSession == nil { return false, nil } req := types.SessionIsActive{ This: sm.Reference(), SessionID: sm.userSession.Key, UserName: sm.userSession.UserName, } active, err := methods.SessionIsActive(ctx, sm.client, &req) if err != nil { return false, err } return active.Returnval, err }
[ "func", "(", "sm", "*", "Manager", ")", "SessionIsActive", "(", "ctx", "context", ".", "Context", ")", "(", "bool", ",", "error", ")", "{", "if", "sm", ".", "userSession", "==", "nil", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "req", ":=", "types", ".", "SessionIsActive", "{", "This", ":", "sm", ".", "Reference", "(", ")", ",", "SessionID", ":", "sm", ".", "userSession", ".", "Key", ",", "UserName", ":", "sm", ".", "userSession", ".", "UserName", ",", "}", "\n\n", "active", ",", "err", ":=", "methods", ".", "SessionIsActive", "(", "ctx", ",", "sm", ".", "client", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "return", "active", ".", "Returnval", ",", "err", "\n", "}" ]
// SessionIsActive checks whether the session that was created at login is // still valid. This function only works against vCenter.
[ "SessionIsActive", "checks", "whether", "the", "session", "that", "was", "created", "at", "login", "is", "still", "valid", ".", "This", "function", "only", "works", "against", "vCenter", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/session/manager.go#L194-L211
train
vmware/govmomi
property/collector.go
DefaultCollector
func DefaultCollector(c *vim25.Client) *Collector { p := Collector{ roundTripper: c, reference: c.ServiceContent.PropertyCollector, } return &p }
go
func DefaultCollector(c *vim25.Client) *Collector { p := Collector{ roundTripper: c, reference: c.ServiceContent.PropertyCollector, } return &p }
[ "func", "DefaultCollector", "(", "c", "*", "vim25", ".", "Client", ")", "*", "Collector", "{", "p", ":=", "Collector", "{", "roundTripper", ":", "c", ",", "reference", ":", "c", ".", "ServiceContent", ".", "PropertyCollector", ",", "}", "\n\n", "return", "&", "p", "\n", "}" ]
// DefaultCollector returns the session's default property collector.
[ "DefaultCollector", "returns", "the", "session", "s", "default", "property", "collector", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/property/collector.go#L41-L48
train
vmware/govmomi
property/collector.go
Create
func (p *Collector) Create(ctx context.Context) (*Collector, error) { req := types.CreatePropertyCollector{ This: p.Reference(), } res, err := methods.CreatePropertyCollector(ctx, p.roundTripper, &req) if err != nil { return nil, err } newp := Collector{ roundTripper: p.roundTripper, reference: res.Returnval, } return &newp, nil }
go
func (p *Collector) Create(ctx context.Context) (*Collector, error) { req := types.CreatePropertyCollector{ This: p.Reference(), } res, err := methods.CreatePropertyCollector(ctx, p.roundTripper, &req) if err != nil { return nil, err } newp := Collector{ roundTripper: p.roundTripper, reference: res.Returnval, } return &newp, nil }
[ "func", "(", "p", "*", "Collector", ")", "Create", "(", "ctx", "context", ".", "Context", ")", "(", "*", "Collector", ",", "error", ")", "{", "req", ":=", "types", ".", "CreatePropertyCollector", "{", "This", ":", "p", ".", "Reference", "(", ")", ",", "}", "\n\n", "res", ",", "err", ":=", "methods", ".", "CreatePropertyCollector", "(", "ctx", ",", "p", ".", "roundTripper", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "newp", ":=", "Collector", "{", "roundTripper", ":", "p", ".", "roundTripper", ",", "reference", ":", "res", ".", "Returnval", ",", "}", "\n\n", "return", "&", "newp", ",", "nil", "\n", "}" ]
// Create creates a new session-specific Collector that can be used to // retrieve property updates independent of any other Collector.
[ "Create", "creates", "a", "new", "session", "-", "specific", "Collector", "that", "can", "be", "used", "to", "retrieve", "property", "updates", "independent", "of", "any", "other", "Collector", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/property/collector.go#L56-L72
train
vmware/govmomi
property/collector.go
Destroy
func (p *Collector) Destroy(ctx context.Context) error { req := types.DestroyPropertyCollector{ This: p.Reference(), } _, err := methods.DestroyPropertyCollector(ctx, p.roundTripper, &req) if err != nil { return err } p.reference = types.ManagedObjectReference{} return nil }
go
func (p *Collector) Destroy(ctx context.Context) error { req := types.DestroyPropertyCollector{ This: p.Reference(), } _, err := methods.DestroyPropertyCollector(ctx, p.roundTripper, &req) if err != nil { return err } p.reference = types.ManagedObjectReference{} return nil }
[ "func", "(", "p", "*", "Collector", ")", "Destroy", "(", "ctx", "context", ".", "Context", ")", "error", "{", "req", ":=", "types", ".", "DestroyPropertyCollector", "{", "This", ":", "p", ".", "Reference", "(", ")", ",", "}", "\n\n", "_", ",", "err", ":=", "methods", ".", "DestroyPropertyCollector", "(", "ctx", ",", "p", ".", "roundTripper", ",", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "p", ".", "reference", "=", "types", ".", "ManagedObjectReference", "{", "}", "\n", "return", "nil", "\n", "}" ]
// Destroy destroys this Collector.
[ "Destroy", "destroys", "this", "Collector", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/property/collector.go#L75-L87
train
vmware/govmomi
property/wait.go
Add
func (f *WaitFilter) Add(obj types.ManagedObjectReference, kind string, ps []string, set ...types.BaseSelectionSpec) *WaitFilter { spec := types.ObjectSpec{ Obj: obj, SelectSet: set, } pset := types.PropertySpec{ Type: kind, PathSet: ps, } if len(ps) == 0 { pset.All = types.NewBool(true) } f.Spec.ObjectSet = append(f.Spec.ObjectSet, spec) f.Spec.PropSet = append(f.Spec.PropSet, pset) return f }
go
func (f *WaitFilter) Add(obj types.ManagedObjectReference, kind string, ps []string, set ...types.BaseSelectionSpec) *WaitFilter { spec := types.ObjectSpec{ Obj: obj, SelectSet: set, } pset := types.PropertySpec{ Type: kind, PathSet: ps, } if len(ps) == 0 { pset.All = types.NewBool(true) } f.Spec.ObjectSet = append(f.Spec.ObjectSet, spec) f.Spec.PropSet = append(f.Spec.PropSet, pset) return f }
[ "func", "(", "f", "*", "WaitFilter", ")", "Add", "(", "obj", "types", ".", "ManagedObjectReference", ",", "kind", "string", ",", "ps", "[", "]", "string", ",", "set", "...", "types", ".", "BaseSelectionSpec", ")", "*", "WaitFilter", "{", "spec", ":=", "types", ".", "ObjectSpec", "{", "Obj", ":", "obj", ",", "SelectSet", ":", "set", ",", "}", "\n\n", "pset", ":=", "types", ".", "PropertySpec", "{", "Type", ":", "kind", ",", "PathSet", ":", "ps", ",", "}", "\n\n", "if", "len", "(", "ps", ")", "==", "0", "{", "pset", ".", "All", "=", "types", ".", "NewBool", "(", "true", ")", "\n", "}", "\n\n", "f", ".", "Spec", ".", "ObjectSet", "=", "append", "(", "f", ".", "Spec", ".", "ObjectSet", ",", "spec", ")", "\n\n", "f", ".", "Spec", ".", "PropSet", "=", "append", "(", "f", ".", "Spec", ".", "PropSet", ",", "pset", ")", "\n\n", "return", "f", "\n", "}" ]
// Add a new ObjectSpec and PropertySpec to the WaitFilter
[ "Add", "a", "new", "ObjectSpec", "and", "PropertySpec", "to", "the", "WaitFilter" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/property/wait.go#L33-L53
train
vmware/govmomi
property/wait.go
Wait
func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error { filter := new(WaitFilter).Add(obj, obj.Type, ps) return WaitForUpdates(ctx, c, filter, func(updates []types.ObjectUpdate) bool { for _, update := range updates { if f(update.ChangeSet) { return true } } return false }) }
go
func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error { filter := new(WaitFilter).Add(obj, obj.Type, ps) return WaitForUpdates(ctx, c, filter, func(updates []types.ObjectUpdate) bool { for _, update := range updates { if f(update.ChangeSet) { return true } } return false }) }
[ "func", "Wait", "(", "ctx", "context", ".", "Context", ",", "c", "*", "Collector", ",", "obj", "types", ".", "ManagedObjectReference", ",", "ps", "[", "]", "string", ",", "f", "func", "(", "[", "]", "types", ".", "PropertyChange", ")", "bool", ")", "error", "{", "filter", ":=", "new", "(", "WaitFilter", ")", ".", "Add", "(", "obj", ",", "obj", ".", "Type", ",", "ps", ")", "\n\n", "return", "WaitForUpdates", "(", "ctx", ",", "c", ",", "filter", ",", "func", "(", "updates", "[", "]", "types", ".", "ObjectUpdate", ")", "bool", "{", "for", "_", ",", "update", ":=", "range", "updates", "{", "if", "f", "(", "update", ".", "ChangeSet", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n\n", "return", "false", "\n", "}", ")", "\n", "}" ]
// Wait creates a new WaitFilter and calls the specified function for each ObjectUpdate via WaitForUpdates
[ "Wait", "creates", "a", "new", "WaitFilter", "and", "calls", "the", "specified", "function", "for", "each", "ObjectUpdate", "via", "WaitForUpdates" ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/property/wait.go#L56-L68
train
vmware/govmomi
govc/flags/network.go
Change
func (flag *NetworkFlag) Change(device types.BaseVirtualDevice, update types.BaseVirtualDevice) { current := device.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard() changed := update.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard() current.Backing = changed.Backing if changed.MacAddress != "" { current.MacAddress = changed.MacAddress } if changed.AddressType != "" { current.AddressType = changed.AddressType } }
go
func (flag *NetworkFlag) Change(device types.BaseVirtualDevice, update types.BaseVirtualDevice) { current := device.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard() changed := update.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard() current.Backing = changed.Backing if changed.MacAddress != "" { current.MacAddress = changed.MacAddress } if changed.AddressType != "" { current.AddressType = changed.AddressType } }
[ "func", "(", "flag", "*", "NetworkFlag", ")", "Change", "(", "device", "types", ".", "BaseVirtualDevice", ",", "update", "types", ".", "BaseVirtualDevice", ")", "{", "current", ":=", "device", ".", "(", "types", ".", "BaseVirtualEthernetCard", ")", ".", "GetVirtualEthernetCard", "(", ")", "\n", "changed", ":=", "update", ".", "(", "types", ".", "BaseVirtualEthernetCard", ")", ".", "GetVirtualEthernetCard", "(", ")", "\n\n", "current", ".", "Backing", "=", "changed", ".", "Backing", "\n\n", "if", "changed", ".", "MacAddress", "!=", "\"", "\"", "{", "current", ".", "MacAddress", "=", "changed", ".", "MacAddress", "\n", "}", "\n\n", "if", "changed", ".", "AddressType", "!=", "\"", "\"", "{", "current", ".", "AddressType", "=", "changed", ".", "AddressType", "\n", "}", "\n", "}" ]
// Change applies update backing and hardware address changes to the given network device.
[ "Change", "applies", "update", "backing", "and", "hardware", "address", "changes", "to", "the", "given", "network", "device", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/network.go#L134-L147
train
vmware/govmomi
object/extension_manager.go
GetExtensionManager
func GetExtensionManager(c *vim25.Client) (*ExtensionManager, error) { if c.ServiceContent.ExtensionManager == nil { return nil, ErrNotSupported } return NewExtensionManager(c), nil }
go
func GetExtensionManager(c *vim25.Client) (*ExtensionManager, error) { if c.ServiceContent.ExtensionManager == nil { return nil, ErrNotSupported } return NewExtensionManager(c), nil }
[ "func", "GetExtensionManager", "(", "c", "*", "vim25", ".", "Client", ")", "(", "*", "ExtensionManager", ",", "error", ")", "{", "if", "c", ".", "ServiceContent", ".", "ExtensionManager", "==", "nil", "{", "return", "nil", ",", "ErrNotSupported", "\n", "}", "\n", "return", "NewExtensionManager", "(", "c", ")", ",", "nil", "\n", "}" ]
// GetExtensionManager wraps NewExtensionManager, returning ErrNotSupported // when the client is not connected to a vCenter instance.
[ "GetExtensionManager", "wraps", "NewExtensionManager", "returning", "ErrNotSupported", "when", "the", "client", "is", "not", "connected", "to", "a", "vCenter", "instance", "." ]
fc3f0e9d2275df0e497a80917807a7c72d3c35bc
https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/extension_manager.go#L34-L39
train