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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
vmware/govmomi | toolbox/hgfs/server.go | SetattrV2 | func (s *Server) SetattrV2(p *Packet) (interface{}, error) {
res := &ReplySetattrV2{}
req := new(RequestSetattrV2)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
name := req.FileName.Path()
_, err = os.Stat(name)
if err != nil && os.IsNotExist(err) {
// assuming this is a virtua... | go | func (s *Server) SetattrV2(p *Packet) (interface{}, error) {
res := &ReplySetattrV2{}
req := new(RequestSetattrV2)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
name := req.FileName.Path()
_, err = os.Stat(name)
if err != nil && os.IsNotExist(err) {
// assuming this is a virtua... | [
"func",
"(",
"s",
"*",
"Server",
")",
"SetattrV2",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"res",
":=",
"&",
"ReplySetattrV2",
"{",
"}",
"\n\n",
"req",
":=",
"new",
"(",
"RequestSetattrV2",
")",
"\n",
"err"... | // SetattrV2 handles OpSetattrV2 requests | [
"SetattrV2",
"handles",
"OpSetattrV2",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L348-L402 | train |
vmware/govmomi | toolbox/hgfs/server.go | Open | func (s *Server) Open(p *Packet) (interface{}, error) {
req := new(RequestOpen)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
name := req.FileName.Path()
mode := req.OpenMode
if mode != OpenModeReadOnly {
ret... | go | func (s *Server) Open(p *Packet) (interface{}, error) {
req := new(RequestOpen)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
name := req.FileName.Path()
mode := req.OpenMode
if mode != OpenModeReadOnly {
ret... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Open",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"req",
":=",
"new",
"(",
"RequestOpen",
")",
"\n",
"err",
":=",
"UnmarshalBinary",
"(",
"p",
".",
"Payload",
",",
"req... | // Open handles OpOpen requests | [
"Open",
"handles",
"OpOpen",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L409-L445 | train |
vmware/govmomi | toolbox/hgfs/server.go | Close | func (s *Server) Close(p *Packet) (interface{}, error) {
req := new(RequestClose)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
session.mu.Lock()
file, ok := session.files[req.Handle]
if ok {
delete(session.fi... | go | func (s *Server) Close(p *Packet) (interface{}, error) {
req := new(RequestClose)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
session.mu.Lock()
file, ok := session.files[req.Handle]
if ok {
delete(session.fi... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Close",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"req",
":=",
"new",
"(",
"RequestClose",
")",
"\n",
"err",
":=",
"UnmarshalBinary",
"(",
"p",
".",
"Payload",
",",
"r... | // Close handles OpClose requests | [
"Close",
"handles",
"OpClose",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L448-L474 | train |
vmware/govmomi | toolbox/hgfs/server.go | OpenV3 | func (s *Server) OpenV3(p *Packet) (interface{}, error) {
req := new(RequestOpenV3)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
name := req.FileName.Path()
if req.DesiredLock != LockNone {
return nil, &Statu... | go | func (s *Server) OpenV3(p *Packet) (interface{}, error) {
req := new(RequestOpenV3)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
name := req.FileName.Path()
if req.DesiredLock != LockNone {
return nil, &Statu... | [
"func",
"(",
"s",
"*",
"Server",
")",
"OpenV3",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"req",
":=",
"new",
"(",
"RequestOpenV3",
")",
"\n",
"err",
":=",
"UnmarshalBinary",
"(",
"p",
".",
"Payload",
",",
... | // OpenV3 handles OpOpenV3 requests | [
"OpenV3",
"handles",
"OpOpenV3",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L477-L512 | train |
vmware/govmomi | toolbox/hgfs/server.go | ReadV3 | func (s *Server) ReadV3(p *Packet) (interface{}, error) {
req := new(RequestReadV3)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
session.mu.Lock()
file, ok := session.files[req.Handle]
session.mu.Unlock()
if ... | go | func (s *Server) ReadV3(p *Packet) (interface{}, error) {
req := new(RequestReadV3)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
session.mu.Lock()
file, ok := session.files[req.Handle]
session.mu.Unlock()
if ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"ReadV3",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"req",
":=",
"new",
"(",
"RequestReadV3",
")",
"\n",
"err",
":=",
"UnmarshalBinary",
"(",
"p",
".",
"Payload",
",",
... | // ReadV3 handles OpReadV3 requests | [
"ReadV3",
"handles",
"OpReadV3",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L515-L552 | train |
vmware/govmomi | toolbox/hgfs/server.go | WriteV3 | func (s *Server) WriteV3(p *Packet) (interface{}, error) {
req := new(RequestWriteV3)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
session.mu.Lock()
file, ok := session.files[req.Handle]
session.mu.Unlock()
i... | go | func (s *Server) WriteV3(p *Packet) (interface{}, error) {
req := new(RequestWriteV3)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
session, err := s.getSession(p)
if err != nil {
return nil, err
}
session.mu.Lock()
file, ok := session.files[req.Handle]
session.mu.Unlock()
i... | [
"func",
"(",
"s",
"*",
"Server",
")",
"WriteV3",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"req",
":=",
"new",
"(",
"RequestWriteV3",
")",
"\n",
"err",
":=",
"UnmarshalBinary",
"(",
"p",
".",
"Payload",
",",
... | // WriteV3 handles OpWriteV3 requests | [
"WriteV3",
"handles",
"OpWriteV3",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L555-L585 | train |
vmware/govmomi | simulator/internal/server.go | NewServer | func NewServer(handler http.Handler) *Server {
ts := NewUnstartedServer(handler, "")
ts.Start()
return ts
} | go | func NewServer(handler http.Handler) *Server {
ts := NewUnstartedServer(handler, "")
ts.Start()
return ts
} | [
"func",
"NewServer",
"(",
"handler",
"http",
".",
"Handler",
")",
"*",
"Server",
"{",
"ts",
":=",
"NewUnstartedServer",
"(",
"handler",
",",
"\"",
"\"",
")",
"\n",
"ts",
".",
"Start",
"(",
")",
"\n",
"return",
"ts",
"\n",
"}"
] | // NewServer starts and returns a new Server.
// The caller should call Close when finished, to shut it down. | [
"NewServer",
"starts",
"and",
"returns",
"a",
"new",
"Server",
".",
"The",
"caller",
"should",
"call",
"Close",
"when",
"finished",
"to",
"shut",
"it",
"down",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L71-L75 | train |
vmware/govmomi | simulator/internal/server.go | NewUnstartedServer | func NewUnstartedServer(handler http.Handler, serve string) *Server {
return &Server{
Listener: newLocalListener(serve),
Config: &http.Server{Handler: handler},
}
} | go | func NewUnstartedServer(handler http.Handler, serve string) *Server {
return &Server{
Listener: newLocalListener(serve),
Config: &http.Server{Handler: handler},
}
} | [
"func",
"NewUnstartedServer",
"(",
"handler",
"http",
".",
"Handler",
",",
"serve",
"string",
")",
"*",
"Server",
"{",
"return",
"&",
"Server",
"{",
"Listener",
":",
"newLocalListener",
"(",
"serve",
")",
",",
"Config",
":",
"&",
"http",
".",
"Server",
"... | // NewUnstartedServer returns a new Server but doesn't start it.
//
// After changing its configuration, the caller should call Start or
// StartTLS.
//
// The caller should call Close when finished, to shut it down.
// serve allows the server's listen address to be specified. | [
"NewUnstartedServer",
"returns",
"a",
"new",
"Server",
"but",
"doesn",
"t",
"start",
"it",
".",
"After",
"changing",
"its",
"configuration",
"the",
"caller",
"should",
"call",
"Start",
"or",
"StartTLS",
".",
"The",
"caller",
"should",
"call",
"Close",
"when",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L84-L89 | train |
vmware/govmomi | simulator/internal/server.go | Start | func (s *Server) Start() {
if s.URL != "" {
panic("Server already started")
}
if s.client == nil {
s.client = &http.Client{Transport: &http.Transport{}}
}
s.URL = "http://" + s.Listener.Addr().String()
s.wrap()
s.goServe()
} | go | func (s *Server) Start() {
if s.URL != "" {
panic("Server already started")
}
if s.client == nil {
s.client = &http.Client{Transport: &http.Transport{}}
}
s.URL = "http://" + s.Listener.Addr().String()
s.wrap()
s.goServe()
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Start",
"(",
")",
"{",
"if",
"s",
".",
"URL",
"!=",
"\"",
"\"",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"client",
"==",
"nil",
"{",
"s",
".",
"client",
"=",
"&",
"http",
... | // Start starts a server from NewUnstartedServer. | [
"Start",
"starts",
"a",
"server",
"from",
"NewUnstartedServer",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L92-L102 | train |
vmware/govmomi | simulator/internal/server.go | StartTLS | func (s *Server) StartTLS() {
if s.URL != "" {
panic("Server already started")
}
if s.client == nil {
s.client = &http.Client{Transport: &http.Transport{}}
}
cert, err := tls.X509KeyPair(LocalhostCert, LocalhostKey)
if err != nil {
panic(fmt.Sprintf("httptest: NewTLSServer: %v", err))
}
existingConfig :=... | go | func (s *Server) StartTLS() {
if s.URL != "" {
panic("Server already started")
}
if s.client == nil {
s.client = &http.Client{Transport: &http.Transport{}}
}
cert, err := tls.X509KeyPair(LocalhostCert, LocalhostKey)
if err != nil {
panic(fmt.Sprintf("httptest: NewTLSServer: %v", err))
}
existingConfig :=... | [
"func",
"(",
"s",
"*",
"Server",
")",
"StartTLS",
"(",
")",
"{",
"if",
"s",
".",
"URL",
"!=",
"\"",
"\"",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"client",
"==",
"nil",
"{",
"s",
".",
"client",
"=",
"&",
"http",... | // StartTLS starts TLS on a server from NewUnstartedServer. | [
"StartTLS",
"starts",
"TLS",
"on",
"a",
"server",
"from",
"NewUnstartedServer",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L105-L144 | train |
vmware/govmomi | simulator/internal/server.go | NewTLSServer | func NewTLSServer(handler http.Handler) *Server {
ts := NewUnstartedServer(handler, "")
ts.StartTLS()
return ts
} | go | func NewTLSServer(handler http.Handler) *Server {
ts := NewUnstartedServer(handler, "")
ts.StartTLS()
return ts
} | [
"func",
"NewTLSServer",
"(",
"handler",
"http",
".",
"Handler",
")",
"*",
"Server",
"{",
"ts",
":=",
"NewUnstartedServer",
"(",
"handler",
",",
"\"",
"\"",
")",
"\n",
"ts",
".",
"StartTLS",
"(",
")",
"\n",
"return",
"ts",
"\n",
"}"
] | // NewTLSServer starts and returns a new Server using TLS.
// The caller should call Close when finished, to shut it down. | [
"NewTLSServer",
"starts",
"and",
"returns",
"a",
"new",
"Server",
"using",
"TLS",
".",
"The",
"caller",
"should",
"call",
"Close",
"when",
"finished",
"to",
"shut",
"it",
"down",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L148-L152 | train |
vmware/govmomi | simulator/internal/server.go | CloseClientConnections | func (s *Server) CloseClientConnections() {
s.mu.Lock()
nconn := len(s.conns)
ch := make(chan struct{}, nconn)
for c := range s.conns {
go s.closeConnChan(c, ch)
}
s.mu.Unlock()
// Wait for outstanding closes to finish.
//
// Out of paranoia for making a late change in Go 1.6, we
// bound how long this can... | go | func (s *Server) CloseClientConnections() {
s.mu.Lock()
nconn := len(s.conns)
ch := make(chan struct{}, nconn)
for c := range s.conns {
go s.closeConnChan(c, ch)
}
s.mu.Unlock()
// Wait for outstanding closes to finish.
//
// Out of paranoia for making a late change in Go 1.6, we
// bound how long this can... | [
"func",
"(",
"s",
"*",
"Server",
")",
"CloseClientConnections",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"nconn",
":=",
"len",
"(",
"s",
".",
"conns",
")",
"\n",
"ch",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"ncon... | // CloseClientConnections closes any open HTTP connections to the test Server. | [
"CloseClientConnections",
"closes",
"any",
"open",
"HTTP",
"connections",
"to",
"the",
"test",
"Server",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L224-L249 | train |
vmware/govmomi | simulator/internal/server.go | wrap | func (s *Server) wrap() {
oldHook := s.Config.ConnState
s.Config.ConnState = func(c net.Conn, cs http.ConnState) {
s.mu.Lock()
defer s.mu.Unlock()
switch cs {
case http.StateNew:
s.wg.Add(1)
if _, exists := s.conns[c]; exists {
panic("invalid state transition")
}
if s.conns == nil {
s.conn... | go | func (s *Server) wrap() {
oldHook := s.Config.ConnState
s.Config.ConnState = func(c net.Conn, cs http.ConnState) {
s.mu.Lock()
defer s.mu.Unlock()
switch cs {
case http.StateNew:
s.wg.Add(1)
if _, exists := s.conns[c]; exists {
panic("invalid state transition")
}
if s.conns == nil {
s.conn... | [
"func",
"(",
"s",
"*",
"Server",
")",
"wrap",
"(",
")",
"{",
"oldHook",
":=",
"s",
".",
"Config",
".",
"ConnState",
"\n",
"s",
".",
"Config",
".",
"ConnState",
"=",
"func",
"(",
"c",
"net",
".",
"Conn",
",",
"cs",
"http",
".",
"ConnState",
")",
... | // wrap installs the connection state-tracking hook to know which
// connections are idle. | [
"wrap",
"installs",
"the",
"connection",
"state",
"-",
"tracking",
"hook",
"to",
"know",
"which",
"connections",
"are",
"idle",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L274-L320 | train |
vmware/govmomi | simulator/internal/server.go | closeConnChan | func (s *Server) closeConnChan(c net.Conn, done chan<- struct{}) {
c.Close()
if done != nil {
done <- struct{}{}
}
} | go | func (s *Server) closeConnChan(c net.Conn, done chan<- struct{}) {
c.Close()
if done != nil {
done <- struct{}{}
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"closeConnChan",
"(",
"c",
"net",
".",
"Conn",
",",
"done",
"chan",
"<-",
"struct",
"{",
"}",
")",
"{",
"c",
".",
"Close",
"(",
")",
"\n",
"if",
"done",
"!=",
"nil",
"{",
"done",
"<-",
"struct",
"{",
"}",
... | // closeConnChan is like closeConn, but takes an optional channel to receive a value
// when the goroutine closing c is done. | [
"closeConnChan",
"is",
"like",
"closeConn",
"but",
"takes",
"an",
"optional",
"channel",
"to",
"receive",
"a",
"value",
"when",
"the",
"goroutine",
"closing",
"c",
"is",
"done",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L328-L333 | train |
vmware/govmomi | simulator/internal/server.go | forgetConn | func (s *Server) forgetConn(c net.Conn) {
if _, ok := s.conns[c]; ok {
delete(s.conns, c)
s.wg.Done()
}
} | go | func (s *Server) forgetConn(c net.Conn) {
if _, ok := s.conns[c]; ok {
delete(s.conns, c)
s.wg.Done()
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"forgetConn",
"(",
"c",
"net",
".",
"Conn",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"s",
".",
"conns",
"[",
"c",
"]",
";",
"ok",
"{",
"delete",
"(",
"s",
".",
"conns",
",",
"c",
")",
"\n",
"s",
".",
"wg... | // forgetConn removes c from the set of tracked conns and decrements it from the
// waitgroup, unless it was previously removed.
// s.mu must be held. | [
"forgetConn",
"removes",
"c",
"from",
"the",
"set",
"of",
"tracked",
"conns",
"and",
"decrements",
"it",
"from",
"the",
"waitgroup",
"unless",
"it",
"was",
"previously",
"removed",
".",
"s",
".",
"mu",
"must",
"be",
"held",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/internal/server.go#L338-L343 | train |
vmware/govmomi | simulator/property_filter.go | matches | func (f *PropertyFilter) matches(ctx *Context, ref types.ManagedObjectReference, change *types.PropertyChange) bool {
var kind reflect.Type
for _, p := range f.Spec.PropSet {
if p.Type != ref.Type {
if kind == nil {
kind = getManagedObject(ctx.Map.Get(ref)).Type()
}
// e.g. ManagedEntity, ComputeResou... | go | func (f *PropertyFilter) matches(ctx *Context, ref types.ManagedObjectReference, change *types.PropertyChange) bool {
var kind reflect.Type
for _, p := range f.Spec.PropSet {
if p.Type != ref.Type {
if kind == nil {
kind = getManagedObject(ctx.Map.Get(ref)).Type()
}
// e.g. ManagedEntity, ComputeResou... | [
"func",
"(",
"f",
"*",
"PropertyFilter",
")",
"matches",
"(",
"ctx",
"*",
"Context",
",",
"ref",
"types",
".",
"ManagedObjectReference",
",",
"change",
"*",
"types",
".",
"PropertyChange",
")",
"bool",
"{",
"var",
"kind",
"reflect",
".",
"Type",
"\n\n",
... | // matches returns true if the change matches one of the filter Spec.PropSet | [
"matches",
"returns",
"true",
"if",
"the",
"change",
"matches",
"one",
"of",
"the",
"filter",
"Spec",
".",
"PropSet"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/property_filter.go#L49-L86 | train |
vmware/govmomi | simulator/property_filter.go | apply | func (f *PropertyFilter) apply(ctx *Context, change types.ObjectUpdate) types.ObjectUpdate {
parents := make(map[string]bool)
set := change.ChangeSet
change.ChangeSet = nil
for i, p := range set {
if f.matches(ctx, change.Obj, &p) {
if p.Name != set[i].Name {
// update matches a parent field from the spec... | go | func (f *PropertyFilter) apply(ctx *Context, change types.ObjectUpdate) types.ObjectUpdate {
parents := make(map[string]bool)
set := change.ChangeSet
change.ChangeSet = nil
for i, p := range set {
if f.matches(ctx, change.Obj, &p) {
if p.Name != set[i].Name {
// update matches a parent field from the spec... | [
"func",
"(",
"f",
"*",
"PropertyFilter",
")",
"apply",
"(",
"ctx",
"*",
"Context",
",",
"change",
"types",
".",
"ObjectUpdate",
")",
"types",
".",
"ObjectUpdate",
"{",
"parents",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"set",
... | // apply the PropertyFilter.Spec to the given ObjectUpdate | [
"apply",
"the",
"PropertyFilter",
".",
"Spec",
"to",
"the",
"given",
"ObjectUpdate"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/property_filter.go#L89-L108 | train |
vmware/govmomi | vim25/xml/typeinfo.go | getTypeInfo | func getTypeInfo(typ reflect.Type) (*typeInfo, error) {
tinfoLock.RLock()
tinfo, ok := tinfoMap[typ]
tinfoLock.RUnlock()
if ok {
return tinfo, nil
}
tinfo = &typeInfo{}
if typ.Kind() == reflect.Struct && typ != nameType {
n := typ.NumField()
for i := 0; i < n; i++ {
f := typ.Field(i)
if f.PkgPath != ... | go | func getTypeInfo(typ reflect.Type) (*typeInfo, error) {
tinfoLock.RLock()
tinfo, ok := tinfoMap[typ]
tinfoLock.RUnlock()
if ok {
return tinfo, nil
}
tinfo = &typeInfo{}
if typ.Kind() == reflect.Struct && typ != nameType {
n := typ.NumField()
for i := 0; i < n; i++ {
f := typ.Field(i)
if f.PkgPath != ... | [
"func",
"getTypeInfo",
"(",
"typ",
"reflect",
".",
"Type",
")",
"(",
"*",
"typeInfo",
",",
"error",
")",
"{",
"tinfoLock",
".",
"RLock",
"(",
")",
"\n",
"tinfo",
",",
"ok",
":=",
"tinfoMap",
"[",
"typ",
"]",
"\n",
"tinfoLock",
".",
"RUnlock",
"(",
... | // getTypeInfo returns the typeInfo structure with details necessary
// for marshalling and unmarshalling typ. | [
"getTypeInfo",
"returns",
"the",
"typeInfo",
"structure",
"with",
"details",
"necessary",
"for",
"marshalling",
"and",
"unmarshalling",
"typ",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/typeinfo.go#L52-L112 | train |
vmware/govmomi | vim25/xml/typeinfo.go | lookupXMLName | func lookupXMLName(typ reflect.Type) (xmlname *fieldInfo) {
for typ.Kind() == reflect.Ptr {
typ = typ.Elem()
}
if typ.Kind() != reflect.Struct {
return nil
}
for i, n := 0, typ.NumField(); i < n; i++ {
f := typ.Field(i)
if f.Name != "XMLName" {
continue
}
finfo, err := structFieldInfo(typ, &f)
if ... | go | func lookupXMLName(typ reflect.Type) (xmlname *fieldInfo) {
for typ.Kind() == reflect.Ptr {
typ = typ.Elem()
}
if typ.Kind() != reflect.Struct {
return nil
}
for i, n := 0, typ.NumField(); i < n; i++ {
f := typ.Field(i)
if f.Name != "XMLName" {
continue
}
finfo, err := structFieldInfo(typ, &f)
if ... | [
"func",
"lookupXMLName",
"(",
"typ",
"reflect",
".",
"Type",
")",
"(",
"xmlname",
"*",
"fieldInfo",
")",
"{",
"for",
"typ",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"{",
"typ",
"=",
"typ",
".",
"Elem",
"(",
")",
"\n",
"}",
"\n",
"if",
... | // lookupXMLName returns the fieldInfo for typ's XMLName field
// in case it exists and has a valid xml field tag, otherwise
// it returns nil. | [
"lookupXMLName",
"returns",
"the",
"fieldInfo",
"for",
"typ",
"s",
"XMLName",
"field",
"in",
"case",
"it",
"exists",
"and",
"has",
"a",
"valid",
"xml",
"field",
"tag",
"otherwise",
"it",
"returns",
"nil",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/typeinfo.go#L233-L254 | train |
vmware/govmomi | vapi/library/library_file.go | ListLibraryItemFiles | func (c *Manager) ListLibraryItemFiles(ctx context.Context, id string) ([]File, error) {
url := internal.URL(c, internal.LibraryItemFilePath).WithParameter("library_item_id", id)
var res []File
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | func (c *Manager) ListLibraryItemFiles(ctx context.Context, id string) ([]File, error) {
url := internal.URL(c, internal.LibraryItemFilePath).WithParameter("library_item_id", id)
var res []File
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"ListLibraryItemFiles",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"[",
"]",
"File",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"Lib... | // ListLibraryItemFiles returns a list of all the files for a library item. | [
"ListLibraryItemFiles",
"returns",
"a",
"list",
"of",
"all",
"the",
"files",
"for",
"a",
"library",
"item",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_file.go#L42-L46 | train |
vmware/govmomi | vapi/library/library_file.go | GetLibraryItemFile | func (c *Manager) GetLibraryItemFile(ctx context.Context, id, fileName string) (*File, error) {
url := internal.URL(c, internal.LibraryItemFilePath).WithID(id).WithAction("get")
spec := struct {
Name string `json:"name"`
}{fileName}
var res File
return &res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
} | go | func (c *Manager) GetLibraryItemFile(ctx context.Context, id, fileName string) (*File, error) {
url := internal.URL(c, internal.LibraryItemFilePath).WithID(id).WithAction("get")
spec := struct {
Name string `json:"name"`
}{fileName}
var res File
return &res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetLibraryItemFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
",",
"fileName",
"string",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
... | // GetLibraryItemFile returns a file with the provided name for a library item. | [
"GetLibraryItemFile",
"returns",
"a",
"file",
"with",
"the",
"provided",
"name",
"for",
"a",
"library",
"item",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_file.go#L49-L56 | train |
vmware/govmomi | nfc/lease_updater.go | File | func (o FileItem) File() types.OvfFile {
return types.OvfFile{
DeviceId: o.DeviceId,
Path: o.Path,
Size: o.Size,
}
} | go | func (o FileItem) File() types.OvfFile {
return types.OvfFile{
DeviceId: o.DeviceId,
Path: o.Path,
Size: o.Size,
}
} | [
"func",
"(",
"o",
"FileItem",
")",
"File",
"(",
")",
"types",
".",
"OvfFile",
"{",
"return",
"types",
".",
"OvfFile",
"{",
"DeviceId",
":",
"o",
".",
"DeviceId",
",",
"Path",
":",
"o",
".",
"Path",
",",
"Size",
":",
"o",
".",
"Size",
",",
"}",
... | // File converts the FileItem.OvfFileItem to an OvfFile | [
"File",
"converts",
"the",
"FileItem",
".",
"OvfFileItem",
"to",
"an",
"OvfFile"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/nfc/lease_updater.go#L51-L57 | train |
vmware/govmomi | govc/datastore/ls.go | hasMultiplePaths | func (o *listOutput) hasMultiplePaths() bool {
if len(o.rs) == 0 {
return false
}
p := o.rs[0].FolderPath
// Multiple paths if any entry is not equal to the first one.
for _, e := range o.rs {
if e.FolderPath != p {
return true
}
}
return false
} | go | func (o *listOutput) hasMultiplePaths() bool {
if len(o.rs) == 0 {
return false
}
p := o.rs[0].FolderPath
// Multiple paths if any entry is not equal to the first one.
for _, e := range o.rs {
if e.FolderPath != p {
return true
}
}
return false
} | [
"func",
"(",
"o",
"*",
"listOutput",
")",
"hasMultiplePaths",
"(",
")",
"bool",
"{",
"if",
"len",
"(",
"o",
".",
"rs",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"p",
":=",
"o",
".",
"rs",
"[",
"0",
"]",
".",
"FolderPath",
"\n\n... | // hasMultiplePaths returns whether or not the slice of search results contains
// results from more than one folder path. | [
"hasMultiplePaths",
"returns",
"whether",
"or",
"not",
"the",
"slice",
"of",
"search",
"results",
"contains",
"results",
"from",
"more",
"than",
"one",
"folder",
"path",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/datastore/ls.go#L233-L248 | train |
vmware/govmomi | vapi/tags/categories.go | Patch | func (c *Category) Patch(src *Category) {
if src.Name != "" {
c.Name = src.Name
}
if src.Description != "" {
c.Description = src.Description
}
if src.Cardinality != "" {
c.Cardinality = src.Cardinality
}
// Note that in order to append to AssociableTypes any existing types must be included in their origina... | go | func (c *Category) Patch(src *Category) {
if src.Name != "" {
c.Name = src.Name
}
if src.Description != "" {
c.Description = src.Description
}
if src.Cardinality != "" {
c.Cardinality = src.Cardinality
}
// Note that in order to append to AssociableTypes any existing types must be included in their origina... | [
"func",
"(",
"c",
"*",
"Category",
")",
"Patch",
"(",
"src",
"*",
"Category",
")",
"{",
"if",
"src",
".",
"Name",
"!=",
"\"",
"\"",
"{",
"c",
".",
"Name",
"=",
"src",
".",
"Name",
"\n",
"}",
"\n",
"if",
"src",
".",
"Description",
"!=",
"\"",
... | // Patch merges Category changes from the given src.
// AssociableTypes can only be appended to and cannot shrink. | [
"Patch",
"merges",
"Category",
"changes",
"from",
"the",
"given",
"src",
".",
"AssociableTypes",
"can",
"only",
"be",
"appended",
"to",
"and",
"cannot",
"shrink",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/categories.go#L48-L64 | train |
vmware/govmomi | vapi/tags/categories.go | CreateCategory | func (c *Manager) CreateCategory(ctx context.Context, category *Category) (string, error) {
// create avoids the annoyance of CreateTag requiring field keys to be included in the request,
// even though the field value can be empty.
type create struct {
Name string `json:"name"`
Description stri... | go | func (c *Manager) CreateCategory(ctx context.Context, category *Category) (string, error) {
// create avoids the annoyance of CreateTag requiring field keys to be included in the request,
// even though the field value can be empty.
type create struct {
Name string `json:"name"`
Description stri... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"CreateCategory",
"(",
"ctx",
"context",
".",
"Context",
",",
"category",
"*",
"Category",
")",
"(",
"string",
",",
"error",
")",
"{",
"// create avoids the annoyance of CreateTag requiring field keys to be included in the request,... | // CreateCategory creates a new category and returns the category ID. | [
"CreateCategory",
"creates",
"a",
"new",
"category",
"and",
"returns",
"the",
"category",
"ID",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/categories.go#L67-L93 | train |
vmware/govmomi | vapi/tags/categories.go | UpdateCategory | func (c *Manager) UpdateCategory(ctx context.Context, category *Category) error {
spec := struct {
Category Category `json:"update_spec"`
}{
Category: Category{
AssociableTypes: category.AssociableTypes,
Cardinality: category.Cardinality,
Description: category.Description,
Name: cat... | go | func (c *Manager) UpdateCategory(ctx context.Context, category *Category) error {
spec := struct {
Category Category `json:"update_spec"`
}{
Category: Category{
AssociableTypes: category.AssociableTypes,
Cardinality: category.Cardinality,
Description: category.Description,
Name: cat... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"UpdateCategory",
"(",
"ctx",
"context",
".",
"Context",
",",
"category",
"*",
"Category",
")",
"error",
"{",
"spec",
":=",
"struct",
"{",
"Category",
"Category",
"`json:\"update_spec\"`",
"\n",
"}",
"{",
"Category",
... | // UpdateCategory can update one or more of the AssociableTypes, Cardinality, Description and Name fields. | [
"UpdateCategory",
"can",
"update",
"one",
"or",
"more",
"of",
"the",
"AssociableTypes",
"Cardinality",
"Description",
"and",
"Name",
"fields",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/categories.go#L96-L109 | train |
vmware/govmomi | vapi/tags/categories.go | DeleteCategory | func (c *Manager) DeleteCategory(ctx context.Context, category *Category) error {
url := internal.URL(c, internal.CategoryPath).WithID(category.ID)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | go | func (c *Manager) DeleteCategory(ctx context.Context, category *Category) error {
url := internal.URL(c, internal.CategoryPath).WithID(category.ID)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"DeleteCategory",
"(",
"ctx",
"context",
".",
"Context",
",",
"category",
"*",
"Category",
")",
"error",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"CategoryPath",
")",
".",
"WithID"... | // DeleteCategory deletes an existing category. | [
"DeleteCategory",
"deletes",
"an",
"existing",
"category",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/categories.go#L112-L115 | train |
vmware/govmomi | vapi/tags/categories.go | GetCategory | func (c *Manager) GetCategory(ctx context.Context, id string) (*Category, error) {
if isName(id) {
cat, err := c.GetCategories(ctx)
if err != nil {
return nil, err
}
for i := range cat {
if cat[i].Name == id {
return &cat[i], nil
}
}
}
url := internal.URL(c, internal.CategoryPath).WithID(id)
... | go | func (c *Manager) GetCategory(ctx context.Context, id string) (*Category, error) {
if isName(id) {
cat, err := c.GetCategories(ctx)
if err != nil {
return nil, err
}
for i := range cat {
if cat[i].Name == id {
return &cat[i], nil
}
}
}
url := internal.URL(c, internal.CategoryPath).WithID(id)
... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetCategory",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"*",
"Category",
",",
"error",
")",
"{",
"if",
"isName",
"(",
"id",
")",
"{",
"cat",
",",
"err",
":=",
"c",
".",
"GetCateg... | // GetCategory fetches the category information for the given identifier.
// The id parameter can be a Category ID or Category Name. | [
"GetCategory",
"fetches",
"the",
"category",
"information",
"for",
"the",
"given",
"identifier",
".",
"The",
"id",
"parameter",
"can",
"be",
"a",
"Category",
"ID",
"or",
"Category",
"Name",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/categories.go#L119-L135 | train |
vmware/govmomi | vapi/tags/categories.go | ListCategories | func (c *Manager) ListCategories(ctx context.Context) ([]string, error) {
url := internal.URL(c, internal.CategoryPath)
var res []string
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | func (c *Manager) ListCategories(ctx context.Context) ([]string, error) {
url := internal.URL(c, internal.CategoryPath)
var res []string
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"ListCategories",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"CategoryPath",
")",
"\n",
"v... | // ListCategories returns all category IDs in the system. | [
"ListCategories",
"returns",
"all",
"category",
"IDs",
"in",
"the",
"system",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/categories.go#L138-L142 | train |
vmware/govmomi | vapi/tags/categories.go | GetCategories | func (c *Manager) GetCategories(ctx context.Context) ([]Category, error) {
ids, err := c.ListCategories(ctx)
if err != nil {
return nil, fmt.Errorf("list categories: %s", err)
}
var categories []Category
for _, id := range ids {
category, err := c.GetCategory(ctx, id)
if err != nil {
return nil, fmt.Erro... | go | func (c *Manager) GetCategories(ctx context.Context) ([]Category, error) {
ids, err := c.ListCategories(ctx)
if err != nil {
return nil, fmt.Errorf("list categories: %s", err)
}
var categories []Category
for _, id := range ids {
category, err := c.GetCategory(ctx, id)
if err != nil {
return nil, fmt.Erro... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetCategories",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"Category",
",",
"error",
")",
"{",
"ids",
",",
"err",
":=",
"c",
".",
"ListCategories",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
... | // GetCategories fetches an array of category information in the system. | [
"GetCategories",
"fetches",
"an",
"array",
"of",
"category",
"information",
"in",
"the",
"system",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/categories.go#L145-L162 | train |
vmware/govmomi | vapi/simulator/simulator.go | New | func New(u *url.URL, settings []vim.BaseOptionValue) (string, http.Handler) {
s := &handler{
ServeMux: http.NewServeMux(),
URL: *u,
Category: make(map[string]*tags.Category),
Tag: make(map[string]*tags.Tag),
Association: make(map[string]map[internal.AssociatedObject]bool),
Session: ... | go | func New(u *url.URL, settings []vim.BaseOptionValue) (string, http.Handler) {
s := &handler{
ServeMux: http.NewServeMux(),
URL: *u,
Category: make(map[string]*tags.Category),
Tag: make(map[string]*tags.Tag),
Association: make(map[string]map[internal.AssociatedObject]bool),
Session: ... | [
"func",
"New",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"settings",
"[",
"]",
"vim",
".",
"BaseOptionValue",
")",
"(",
"string",
",",
"http",
".",
"Handler",
")",
"{",
"s",
":=",
"&",
"handler",
"{",
"ServeMux",
":",
"http",
".",
"NewServeMux",
"(",
... | // New creates a vAPI simulator. | [
"New",
"creates",
"a",
"vAPI",
"simulator",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L85-L140 | train |
vmware/govmomi | vapi/simulator/simulator.go | AttachedObjects | func (s *handler) AttachedObjects(tag vim.VslmTagEntry) ([]vim.ManagedObjectReference, vim.BaseMethodFault) {
t := s.findTag(tag)
if t == nil {
return nil, new(vim.NotFound)
}
var ids []vim.ManagedObjectReference
for id := range s.Association[t.ID] {
ids = append(ids, vim.ManagedObjectReference(id))
}
return... | go | func (s *handler) AttachedObjects(tag vim.VslmTagEntry) ([]vim.ManagedObjectReference, vim.BaseMethodFault) {
t := s.findTag(tag)
if t == nil {
return nil, new(vim.NotFound)
}
var ids []vim.ManagedObjectReference
for id := range s.Association[t.ID] {
ids = append(ids, vim.ManagedObjectReference(id))
}
return... | [
"func",
"(",
"s",
"*",
"handler",
")",
"AttachedObjects",
"(",
"tag",
"vim",
".",
"VslmTagEntry",
")",
"(",
"[",
"]",
"vim",
".",
"ManagedObjectReference",
",",
"vim",
".",
"BaseMethodFault",
")",
"{",
"t",
":=",
"s",
".",
"findTag",
"(",
"tag",
")",
... | // AttachedObjects is meant for internal use via simulator.Registry.tagManager | [
"AttachedObjects",
"is",
"meant",
"for",
"internal",
"use",
"via",
"simulator",
".",
"Registry",
".",
"tagManager"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L188-L198 | train |
vmware/govmomi | vapi/simulator/simulator.go | AttachedTags | func (s *handler) AttachedTags(ref vim.ManagedObjectReference) ([]vim.VslmTagEntry, vim.BaseMethodFault) {
oid := internal.AssociatedObject(ref)
var tags []vim.VslmTagEntry
for id, objs := range s.Association {
if objs[oid] {
tag := s.Tag[id]
cat := s.Category[tag.CategoryID]
tags = append(tags, vim.VslmT... | go | func (s *handler) AttachedTags(ref vim.ManagedObjectReference) ([]vim.VslmTagEntry, vim.BaseMethodFault) {
oid := internal.AssociatedObject(ref)
var tags []vim.VslmTagEntry
for id, objs := range s.Association {
if objs[oid] {
tag := s.Tag[id]
cat := s.Category[tag.CategoryID]
tags = append(tags, vim.VslmT... | [
"func",
"(",
"s",
"*",
"handler",
")",
"AttachedTags",
"(",
"ref",
"vim",
".",
"ManagedObjectReference",
")",
"(",
"[",
"]",
"vim",
".",
"VslmTagEntry",
",",
"vim",
".",
"BaseMethodFault",
")",
"{",
"oid",
":=",
"internal",
".",
"AssociatedObject",
"(",
... | // AttachedTags is meant for internal use via simulator.Registry.tagManager | [
"AttachedTags",
"is",
"meant",
"for",
"internal",
"use",
"via",
"simulator",
".",
"Registry",
".",
"tagManager"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L201-L215 | train |
vmware/govmomi | vapi/simulator/simulator.go | AttachTag | func (s *handler) AttachTag(ref vim.ManagedObjectReference, tag vim.VslmTagEntry) vim.BaseMethodFault {
t := s.findTag(tag)
if t == nil {
return new(vim.NotFound)
}
s.Association[t.ID][internal.AssociatedObject(ref)] = true
return nil
} | go | func (s *handler) AttachTag(ref vim.ManagedObjectReference, tag vim.VslmTagEntry) vim.BaseMethodFault {
t := s.findTag(tag)
if t == nil {
return new(vim.NotFound)
}
s.Association[t.ID][internal.AssociatedObject(ref)] = true
return nil
} | [
"func",
"(",
"s",
"*",
"handler",
")",
"AttachTag",
"(",
"ref",
"vim",
".",
"ManagedObjectReference",
",",
"tag",
"vim",
".",
"VslmTagEntry",
")",
"vim",
".",
"BaseMethodFault",
"{",
"t",
":=",
"s",
".",
"findTag",
"(",
"tag",
")",
"\n",
"if",
"t",
"... | // AttachTag is meant for internal use via simulator.Registry.tagManager | [
"AttachTag",
"is",
"meant",
"for",
"internal",
"use",
"via",
"simulator",
".",
"Registry",
".",
"tagManager"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L218-L225 | train |
vmware/govmomi | vapi/simulator/simulator.go | DetachTag | func (s *handler) DetachTag(id vim.ManagedObjectReference, tag vim.VslmTagEntry) vim.BaseMethodFault {
t := s.findTag(tag)
if t == nil {
return new(vim.NotFound)
}
delete(s.Association[t.ID], internal.AssociatedObject(id))
return nil
} | go | func (s *handler) DetachTag(id vim.ManagedObjectReference, tag vim.VslmTagEntry) vim.BaseMethodFault {
t := s.findTag(tag)
if t == nil {
return new(vim.NotFound)
}
delete(s.Association[t.ID], internal.AssociatedObject(id))
return nil
} | [
"func",
"(",
"s",
"*",
"handler",
")",
"DetachTag",
"(",
"id",
"vim",
".",
"ManagedObjectReference",
",",
"tag",
"vim",
".",
"VslmTagEntry",
")",
"vim",
".",
"BaseMethodFault",
"{",
"t",
":=",
"s",
".",
"findTag",
"(",
"tag",
")",
"\n",
"if",
"t",
"=... | // DetachTag is meant for internal use via simulator.Registry.tagManager | [
"DetachTag",
"is",
"meant",
"for",
"internal",
"use",
"via",
"simulator",
".",
"Registry",
".",
"tagManager"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L228-L235 | train |
vmware/govmomi | vapi/simulator/simulator.go | ok | func (s *handler) ok(w http.ResponseWriter, val ...interface{}) {
w.WriteHeader(http.StatusOK)
if len(val) == 0 {
return
}
err := json.NewEncoder(w).Encode(struct {
Value interface{} `json:"value,omitempty"`
}{
val[0],
})
if err != nil {
log.Panic(err)
}
} | go | func (s *handler) ok(w http.ResponseWriter, val ...interface{}) {
w.WriteHeader(http.StatusOK)
if len(val) == 0 {
return
}
err := json.NewEncoder(w).Encode(struct {
Value interface{} `json:"value,omitempty"`
}{
val[0],
})
if err != nil {
log.Panic(err)
}
} | [
"func",
"(",
"s",
"*",
"handler",
")",
"ok",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"val",
"...",
"interface",
"{",
"}",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusOK",
")",
"\n\n",
"if",
"len",
"(",
"val",
")",
"==",
"0",... | // ok responds with http.StatusOK and json encodes val if given. | [
"ok",
"responds",
"with",
"http",
".",
"StatusOK",
"and",
"json",
"encodes",
"val",
"if",
"given",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L238-L254 | train |
vmware/govmomi | vapi/simulator/simulator.go | ServeHTTP | func (s *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodPost, http.MethodDelete, http.MethodGet, http.MethodPatch, http.MethodPut:
default:
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
h, _ := s.Handler(r)
h.ServeHTTP(w, r)
} | go | func (s *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodPost, http.MethodDelete, http.MethodGet, http.MethodPatch, http.MethodPut:
default:
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
h, _ := s.Handler(r)
h.ServeHTTP(w, r)
} | [
"func",
"(",
"s",
"*",
"handler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"switch",
"r",
".",
"Method",
"{",
"case",
"http",
".",
"MethodPost",
",",
"http",
".",
"MethodDelete",
",",... | // ServeHTTP handles vAPI requests. | [
"ServeHTTP",
"handles",
"vAPI",
"requests",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L279-L289 | train |
vmware/govmomi | vapi/simulator/simulator.go | libraryPath | func libraryPath(l *library.Library, id string) string {
// DatastoreID (moref) format is "$local-path@$ds-folder-id",
// see simulator.HostDatastoreSystem.CreateLocalDatastore
ds := strings.SplitN(l.Storage[0].DatastoreID, "@", 2)[0]
return path.Join(append([]string{ds, "contentlib-" + l.ID}, id)...)
} | go | func libraryPath(l *library.Library, id string) string {
// DatastoreID (moref) format is "$local-path@$ds-folder-id",
// see simulator.HostDatastoreSystem.CreateLocalDatastore
ds := strings.SplitN(l.Storage[0].DatastoreID, "@", 2)[0]
return path.Join(append([]string{ds, "contentlib-" + l.ID}, id)...)
} | [
"func",
"libraryPath",
"(",
"l",
"*",
"library",
".",
"Library",
",",
"id",
"string",
")",
"string",
"{",
"// DatastoreID (moref) format is \"$local-path@$ds-folder-id\",",
"// see simulator.HostDatastoreSystem.CreateLocalDatastore",
"ds",
":=",
"strings",
".",
"SplitN",
"(... | // libraryPath returns the local Datastore fs path for a Library or Item if id is specified. | [
"libraryPath",
"returns",
"the",
"local",
"Datastore",
"fs",
"path",
"for",
"a",
"Library",
"or",
"Item",
"if",
"id",
"is",
"specified",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/simulator/simulator.go#L898-L903 | train |
vmware/govmomi | govc/library/ova.go | NewOVAFile | func NewOVAFile(filename string) (*OVAFile, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
tarFile := tar.NewReader(f)
return &OVAFile{filename: filename, file: f, tarFile: tarFile}, nil
} | go | func NewOVAFile(filename string) (*OVAFile, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
tarFile := tar.NewReader(f)
return &OVAFile{filename: filename, file: f, tarFile: tarFile}, nil
} | [
"func",
"NewOVAFile",
"(",
"filename",
"string",
")",
"(",
"*",
"OVAFile",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
... | // NewOVAFile creates a new OVA file reader | [
"NewOVAFile",
"creates",
"a",
"new",
"OVA",
"file",
"reader"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/library/ova.go#L87-L94 | train |
vmware/govmomi | govc/library/ova.go | Find | func (of *OVAFile) Find(filename string) (*tar.Header, error) {
for {
header, err := of.tarFile.Next()
if err == io.EOF {
return nil, err
}
if header.Name == filename {
return header, nil
}
}
} | go | func (of *OVAFile) Find(filename string) (*tar.Header, error) {
for {
header, err := of.tarFile.Next()
if err == io.EOF {
return nil, err
}
if header.Name == filename {
return header, nil
}
}
} | [
"func",
"(",
"of",
"*",
"OVAFile",
")",
"Find",
"(",
"filename",
"string",
")",
"(",
"*",
"tar",
".",
"Header",
",",
"error",
")",
"{",
"for",
"{",
"header",
",",
"err",
":=",
"of",
".",
"tarFile",
".",
"Next",
"(",
")",
"\n",
"if",
"err",
"=="... | // Find looks for a filename match in the OVA file | [
"Find",
"looks",
"for",
"a",
"filename",
"match",
"in",
"the",
"OVA",
"file"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/library/ova.go#L97-L107 | train |
vmware/govmomi | govc/library/ova.go | Read | func (of *OVAFile) Read(b []byte) (int, error) {
if of.tarFile == nil {
return 0, io.EOF
}
return of.tarFile.Read(b)
} | go | func (of *OVAFile) Read(b []byte) (int, error) {
if of.tarFile == nil {
return 0, io.EOF
}
return of.tarFile.Read(b)
} | [
"func",
"(",
"of",
"*",
"OVAFile",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"of",
".",
"tarFile",
"==",
"nil",
"{",
"return",
"0",
",",
"io",
".",
"EOF",
"\n",
"}",
"\n",
"return",
"of",
".",
"... | // Read reads from the current file in the OVA file | [
"Read",
"reads",
"from",
"the",
"current",
"file",
"in",
"the",
"OVA",
"file"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/library/ova.go#L115-L120 | train |
vmware/govmomi | govc/library/ova.go | getOVAFileInfo | func getOVAFileInfo(ovafile string, filename string) (int64, string, error) {
of, err := NewOVAFile(ovafile)
if err != nil {
return 0, "", err
}
hdr, err := of.Find(filename)
if err != nil {
return 0, "", err
}
hash := md5.New()
_, err = io.Copy(hash, of)
if err != nil {
return 0, "", err
}
md5String... | go | func getOVAFileInfo(ovafile string, filename string) (int64, string, error) {
of, err := NewOVAFile(ovafile)
if err != nil {
return 0, "", err
}
hdr, err := of.Find(filename)
if err != nil {
return 0, "", err
}
hash := md5.New()
_, err = io.Copy(hash, of)
if err != nil {
return 0, "", err
}
md5String... | [
"func",
"getOVAFileInfo",
"(",
"ovafile",
"string",
",",
"filename",
"string",
")",
"(",
"int64",
",",
"string",
",",
"error",
")",
"{",
"of",
",",
"err",
":=",
"NewOVAFile",
"(",
"ovafile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",... | // getOVAFileInfo opens an OVA, finds the file entry, and returns both the size and md5 checksum | [
"getOVAFileInfo",
"opens",
"an",
"OVA",
"finds",
"the",
"file",
"entry",
"and",
"returns",
"both",
"the",
"size",
"and",
"md5",
"checksum"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/library/ova.go#L128-L147 | train |
vmware/govmomi | govc/library/ova.go | uploadFile | func uploadFile(ctx context.Context, m *library.Manager, sessionID string, ovafile string, filename string) error {
var updateFileInfo library.UpdateFile
fmt.Printf("Uploading %s from %s\n", filename, ovafile)
size, md5String, _ := getOVAFileInfo(ovafile, filename)
// Get the URI for the file upload
updateFileI... | go | func uploadFile(ctx context.Context, m *library.Manager, sessionID string, ovafile string, filename string) error {
var updateFileInfo library.UpdateFile
fmt.Printf("Uploading %s from %s\n", filename, ovafile)
size, md5String, _ := getOVAFileInfo(ovafile, filename)
// Get the URI for the file upload
updateFileI... | [
"func",
"uploadFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"*",
"library",
".",
"Manager",
",",
"sessionID",
"string",
",",
"ovafile",
"string",
",",
"filename",
"string",
")",
"error",
"{",
"var",
"updateFileInfo",
"library",
".",
"UpdateFile",
... | // uploadFile will upload a single file from an OVA using the sessionID provided | [
"uploadFile",
"will",
"upload",
"a",
"single",
"file",
"from",
"an",
"OVA",
"using",
"the",
"sessionID",
"provided"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/library/ova.go#L150-L190 | train |
vmware/govmomi | simulator/folder.go | hostsWithDatastore | func hostsWithDatastore(hosts []types.ManagedObjectReference, path string) []types.ManagedObjectReference {
attached := hosts[:0]
var p object.DatastorePath
p.FromString(path)
for _, host := range hosts {
h := Map.Get(host).(*HostSystem)
if Map.FindByName(p.Datastore, h.Datastore) != nil {
attached = append... | go | func hostsWithDatastore(hosts []types.ManagedObjectReference, path string) []types.ManagedObjectReference {
attached := hosts[:0]
var p object.DatastorePath
p.FromString(path)
for _, host := range hosts {
h := Map.Get(host).(*HostSystem)
if Map.FindByName(p.Datastore, h.Datastore) != nil {
attached = append... | [
"func",
"hostsWithDatastore",
"(",
"hosts",
"[",
"]",
"types",
".",
"ManagedObjectReference",
",",
"path",
"string",
")",
"[",
"]",
"types",
".",
"ManagedObjectReference",
"{",
"attached",
":=",
"hosts",
"[",
":",
"0",
"]",
"\n",
"var",
"p",
"object",
".",... | // hostsWithDatastore returns hosts that have access to the given datastore path | [
"hostsWithDatastore",
"returns",
"hosts",
"that",
"have",
"access",
"to",
"the",
"given",
"datastore",
"path"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/folder.go#L260-L273 | train |
vmware/govmomi | ovf/env.go | Marshal | func (e Env) Marshal() (string, error) {
x, err := xml.Marshal(e)
if err != nil {
return "", err
}
return fmt.Sprintf("%s%s", xml.Header, x), nil
} | go | func (e Env) Marshal() (string, error) {
x, err := xml.Marshal(e)
if err != nil {
return "", err
}
return fmt.Sprintf("%s%s", xml.Header, x), nil
} | [
"func",
"(",
"e",
"Env",
")",
"Marshal",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"x",
",",
"err",
":=",
"xml",
".",
"Marshal",
"(",
"e",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
... | // Marshal marshals Env to xml by using xml.Marshal. | [
"Marshal",
"marshals",
"Env",
"to",
"xml",
"by",
"using",
"xml",
".",
"Marshal",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/ovf/env.go#L72-L79 | train |
vmware/govmomi | ovf/env.go | MarshalManual | func (e Env) MarshalManual() string {
var buffer bytes.Buffer
buffer.WriteString(xml.Header)
buffer.WriteString(fmt.Sprintf(ovfEnvHeader, e.EsxID))
buffer.WriteString(fmt.Sprintf(ovfEnvPlatformSection, e.Platform.Kind, e.Platform.Version, e.Platform.Vendor, e.Platform.Locale))
buffer.WriteString(fmt.Sprint(ovfEn... | go | func (e Env) MarshalManual() string {
var buffer bytes.Buffer
buffer.WriteString(xml.Header)
buffer.WriteString(fmt.Sprintf(ovfEnvHeader, e.EsxID))
buffer.WriteString(fmt.Sprintf(ovfEnvPlatformSection, e.Platform.Kind, e.Platform.Version, e.Platform.Vendor, e.Platform.Locale))
buffer.WriteString(fmt.Sprint(ovfEn... | [
"func",
"(",
"e",
"Env",
")",
"MarshalManual",
"(",
")",
"string",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n\n",
"buffer",
".",
"WriteString",
"(",
"xml",
".",
"Header",
")",
"\n",
"buffer",
".",
"WriteString",
"(",
"fmt",
".",
"Sprintf",
"(",
... | // MarshalManual manually marshals Env to xml suitable for a vApp guest.
// It exists to overcome the lack of expressiveness in Go's XML namespaces. | [
"MarshalManual",
"manually",
"marshals",
"Env",
"to",
"xml",
"suitable",
"for",
"a",
"vApp",
"guest",
".",
"It",
"exists",
"to",
"overcome",
"the",
"lack",
"of",
"expressiveness",
"in",
"Go",
"s",
"XML",
"namespaces",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/ovf/env.go#L83-L99 | train |
vmware/govmomi | vim25/xml/read.go | DecodeElement | func (d *Decoder) DecodeElement(v interface{}, start *StartElement) error {
val := reflect.ValueOf(v)
if val.Kind() != reflect.Ptr {
return errors.New("non-pointer passed to Unmarshal")
}
return d.unmarshal(val.Elem(), start)
} | go | func (d *Decoder) DecodeElement(v interface{}, start *StartElement) error {
val := reflect.ValueOf(v)
if val.Kind() != reflect.Ptr {
return errors.New("non-pointer passed to Unmarshal")
}
return d.unmarshal(val.Elem(), start)
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"DecodeElement",
"(",
"v",
"interface",
"{",
"}",
",",
"start",
"*",
"StartElement",
")",
"error",
"{",
"val",
":=",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
"\n",
"if",
"val",
".",
"Kind",
"(",
")",
"!=",
... | // DecodeElement works like xml.Unmarshal except that it takes
// a pointer to the start XML element to decode into v.
// It is useful when a client reads some raw XML tokens itself
// but also wants to defer to Unmarshal for some elements. | [
"DecodeElement",
"works",
"like",
"xml",
".",
"Unmarshal",
"except",
"that",
"it",
"takes",
"a",
"pointer",
"to",
"the",
"start",
"XML",
"element",
"to",
"decode",
"into",
"v",
".",
"It",
"is",
"useful",
"when",
"a",
"client",
"reads",
"some",
"raw",
"XM... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/read.go#L128-L134 | train |
vmware/govmomi | vim25/xml/read.go | receiverType | func receiverType(val interface{}) string {
t := reflect.TypeOf(val)
if t.Name() != "" {
return t.String()
}
return "(" + t.String() + ")"
} | go | func receiverType(val interface{}) string {
t := reflect.TypeOf(val)
if t.Name() != "" {
return t.String()
}
return "(" + t.String() + ")"
} | [
"func",
"receiverType",
"(",
"val",
"interface",
"{",
"}",
")",
"string",
"{",
"t",
":=",
"reflect",
".",
"TypeOf",
"(",
"val",
")",
"\n",
"if",
"t",
".",
"Name",
"(",
")",
"!=",
"\"",
"\"",
"{",
"return",
"t",
".",
"String",
"(",
")",
"\n",
"}... | // receiverType returns the receiver type to use in an expression like "%s.MethodName". | [
"receiverType",
"returns",
"the",
"receiver",
"type",
"to",
"use",
"in",
"an",
"expression",
"like",
"%s",
".",
"MethodName",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/read.go#L173-L179 | train |
vmware/govmomi | vim25/xml/read.go | typeForElement | func (p *Decoder) typeForElement(val reflect.Value, start *StartElement) reflect.Type {
t := ""
for i, a := range start.Attr {
if a.Name == xmlSchemaInstance || a.Name == xsiType {
t = a.Value
// HACK: ensure xsi:type is last in the list to avoid using that value for
// a "type" attribute, such as ManagedO... | go | func (p *Decoder) typeForElement(val reflect.Value, start *StartElement) reflect.Type {
t := ""
for i, a := range start.Attr {
if a.Name == xmlSchemaInstance || a.Name == xsiType {
t = a.Value
// HACK: ensure xsi:type is last in the list to avoid using that value for
// a "type" attribute, such as ManagedO... | [
"func",
"(",
"p",
"*",
"Decoder",
")",
"typeForElement",
"(",
"val",
"reflect",
".",
"Value",
",",
"start",
"*",
"StartElement",
")",
"reflect",
".",
"Type",
"{",
"t",
":=",
"\"",
"\"",
"\n",
"for",
"i",
",",
"a",
":=",
"range",
"start",
".",
"Attr... | // Find reflect.Type for an element's type attribute. | [
"Find",
"reflect",
".",
"Type",
"for",
"an",
"element",
"s",
"type",
"attribute",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/read.go#L272-L312 | train |
vmware/govmomi | vim25/xml/read.go | unmarshalPath | func (p *Decoder) unmarshalPath(tinfo *typeInfo, sv reflect.Value, parents []string, start *StartElement) (consumed bool, err error) {
recurse := false
Loop:
for i := range tinfo.fields {
finfo := &tinfo.fields[i]
if finfo.flags&fElement == 0 || len(finfo.parents) < len(parents) || finfo.xmlns != "" && finfo.xmln... | go | func (p *Decoder) unmarshalPath(tinfo *typeInfo, sv reflect.Value, parents []string, start *StartElement) (consumed bool, err error) {
recurse := false
Loop:
for i := range tinfo.fields {
finfo := &tinfo.fields[i]
if finfo.flags&fElement == 0 || len(finfo.parents) < len(parents) || finfo.xmlns != "" && finfo.xmln... | [
"func",
"(",
"p",
"*",
"Decoder",
")",
"unmarshalPath",
"(",
"tinfo",
"*",
"typeInfo",
",",
"sv",
"reflect",
".",
"Value",
",",
"parents",
"[",
"]",
"string",
",",
"start",
"*",
"StartElement",
")",
"(",
"consumed",
"bool",
",",
"err",
"error",
")",
... | // unmarshalPath walks down an XML structure looking for wanted
// paths, and calls unmarshal on them.
// The consumed result tells whether XML elements have been consumed
// from the Decoder until start's matching end element, or if it's
// still untouched because start is uninteresting for sv's fields. | [
"unmarshalPath",
"walks",
"down",
"an",
"XML",
"structure",
"looking",
"for",
"wanted",
"paths",
"and",
"calls",
"unmarshal",
"on",
"them",
".",
"The",
"consumed",
"result",
"tells",
"whether",
"XML",
"elements",
"have",
"been",
"consumed",
"from",
"the",
"Dec... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/read.go#L701-L758 | train |
vmware/govmomi | vim25/xml/read.go | Skip | func (d *Decoder) Skip() error {
for {
tok, err := d.Token()
if err != nil {
return err
}
switch tok.(type) {
case StartElement:
if err := d.Skip(); err != nil {
return err
}
case EndElement:
return nil
}
}
} | go | func (d *Decoder) Skip() error {
for {
tok, err := d.Token()
if err != nil {
return err
}
switch tok.(type) {
case StartElement:
if err := d.Skip(); err != nil {
return err
}
case EndElement:
return nil
}
}
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"Skip",
"(",
")",
"error",
"{",
"for",
"{",
"tok",
",",
"err",
":=",
"d",
".",
"Token",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"switch",
"tok",
".",
"(",
"type",... | // Skip reads tokens until it has consumed the end element
// matching the most recent start element already consumed.
// It recurs if it encounters a start element, so it can be used to
// skip nested structures.
// It returns nil if it finds an end element matching the start
// element; otherwise it returns an error ... | [
"Skip",
"reads",
"tokens",
"until",
"it",
"has",
"consumed",
"the",
"end",
"element",
"matching",
"the",
"most",
"recent",
"start",
"element",
"already",
"consumed",
".",
"It",
"recurs",
"if",
"it",
"encounters",
"a",
"start",
"element",
"so",
"it",
"can",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/read.go#L766-L781 | train |
vmware/govmomi | vapi/library/library_item_updatesession_file.go | AddLibraryItemFile | func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, updateFile UpdateFile) (*UpdateFileInfo, error) {
url := internal.URL(c, internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("add")
spec := struct {
FileSpec UpdateFile `json:"file_spec"`
}{updateFile}
var res UpdateFileIn... | go | func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, updateFile UpdateFile) (*UpdateFileInfo, error) {
url := internal.URL(c, internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("add")
spec := struct {
FileSpec UpdateFile `json:"file_spec"`
}{updateFile}
var res UpdateFileIn... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"AddLibraryItemFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"string",
",",
"updateFile",
"UpdateFile",
")",
"(",
"*",
"UpdateFileInfo",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
... | // AddLibraryItemFile adds a file | [
"AddLibraryItemFile",
"adds",
"a",
"file"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession_file.go#L59-L66 | train |
vmware/govmomi | vapi/library/library_item_updatesession_file.go | AddLibraryItemFileFromURI | func (c *Manager) AddLibraryItemFileFromURI(
ctx context.Context,
sessionID, fileName, uri string) (*UpdateFileInfo, error) {
n, fingerprint, err := GetContentLengthAndFingerprint(ctx, uri)
if err != nil {
return nil, err
}
info, err := c.AddLibraryItemFile(ctx, sessionID, UpdateFile{
Name: fileName,
... | go | func (c *Manager) AddLibraryItemFileFromURI(
ctx context.Context,
sessionID, fileName, uri string) (*UpdateFileInfo, error) {
n, fingerprint, err := GetContentLengthAndFingerprint(ctx, uri)
if err != nil {
return nil, err
}
info, err := c.AddLibraryItemFile(ctx, sessionID, UpdateFile{
Name: fileName,
... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"AddLibraryItemFileFromURI",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
",",
"fileName",
",",
"uri",
"string",
")",
"(",
"*",
"UpdateFileInfo",
",",
"error",
")",
"{",
"n",
",",
"fingerprint",
",",
"er... | // AddLibraryItemFileFromURI adds a file from a remote URI. | [
"AddLibraryItemFileFromURI",
"adds",
"a",
"file",
"from",
"a",
"remote",
"URI",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession_file.go#L69-L92 | train |
vmware/govmomi | vapi/library/library_item_updatesession_file.go | GetLibraryItemUpdateSessionFile | func (c *Manager) GetLibraryItemUpdateSessionFile(ctx context.Context, sessionID string, fileName string) (*UpdateFileInfo, error) {
url := internal.URL(c, internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("get")
spec := struct {
Name string `json:"file_name"`
}{fileName}
var res UpdateFileInfo
... | go | func (c *Manager) GetLibraryItemUpdateSessionFile(ctx context.Context, sessionID string, fileName string) (*UpdateFileInfo, error) {
url := internal.URL(c, internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("get")
spec := struct {
Name string `json:"file_name"`
}{fileName}
var res UpdateFileInfo
... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetLibraryItemUpdateSessionFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"string",
",",
"fileName",
"string",
")",
"(",
"*",
"UpdateFileInfo",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"... | // GetLibraryItemUpdateSessionFile retrieves information about a specific file
// that is a part of an update session. | [
"GetLibraryItemUpdateSessionFile",
"retrieves",
"information",
"about",
"a",
"specific",
"file",
"that",
"is",
"a",
"part",
"of",
"an",
"update",
"session",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession_file.go#L96-L103 | train |
vmware/govmomi | vapi/library/library_item_updatesession_file.go | GetContentLengthAndFingerprint | func GetContentLengthAndFingerprint(
ctx context.Context, uri string) (int64, string, error) {
resp, err := http.Head(uri)
if err != nil {
return 0, "", err
}
if resp.TLS == nil || len(resp.TLS.PeerCertificates) == 0 {
return resp.ContentLength, "", nil
}
fingerprint := &bytes.Buffer{}
sum := sha1.Sum(resp.... | go | func GetContentLengthAndFingerprint(
ctx context.Context, uri string) (int64, string, error) {
resp, err := http.Head(uri)
if err != nil {
return 0, "", err
}
if resp.TLS == nil || len(resp.TLS.PeerCertificates) == 0 {
return resp.ContentLength, "", nil
}
fingerprint := &bytes.Buffer{}
sum := sha1.Sum(resp.... | [
"func",
"GetContentLengthAndFingerprint",
"(",
"ctx",
"context",
".",
"Context",
",",
"uri",
"string",
")",
"(",
"int64",
",",
"string",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"http",
".",
"Head",
"(",
"uri",
")",
"\n",
"if",
"err",
"!=",
... | // GetContentLengthAndFingerprint gets the number of bytes returned
// by the URI as well as the SHA1 fingerprint of the peer certificate
// if the URI's scheme is https. | [
"GetContentLengthAndFingerprint",
"gets",
"the",
"number",
"of",
"bytes",
"returned",
"by",
"the",
"URI",
"as",
"well",
"as",
"the",
"SHA1",
"fingerprint",
"of",
"the",
"peer",
"certificate",
"if",
"the",
"URI",
"s",
"scheme",
"is",
"https",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession_file.go#L108-L126 | train |
vmware/govmomi | simulator/event_manager.go | formatMessage | func (m *EventManager) formatMessage(event types.BaseEvent) {
id := reflect.ValueOf(event).Elem().Type().Name()
e := event.GetEvent()
t, ok := m.templates[id]
if !ok {
for _, info := range m.Description.EventInfo {
if info.Key == id {
t = template.Must(template.New(id).Parse(info.FullFormat))
m.templa... | go | func (m *EventManager) formatMessage(event types.BaseEvent) {
id := reflect.ValueOf(event).Elem().Type().Name()
e := event.GetEvent()
t, ok := m.templates[id]
if !ok {
for _, info := range m.Description.EventInfo {
if info.Key == id {
t = template.Must(template.New(id).Parse(info.FullFormat))
m.templa... | [
"func",
"(",
"m",
"*",
"EventManager",
")",
"formatMessage",
"(",
"event",
"types",
".",
"BaseEvent",
")",
"{",
"id",
":=",
"reflect",
".",
"ValueOf",
"(",
"event",
")",
".",
"Elem",
"(",
")",
".",
"Type",
"(",
")",
".",
"Name",
"(",
")",
"\n",
"... | // formatMessage applies the EventDescriptionEventDetail.FullFormat template to the given event's FullFormattedMessage field. | [
"formatMessage",
"applies",
"the",
"EventDescriptionEventDetail",
".",
"FullFormat",
"template",
"to",
"the",
"given",
"event",
"s",
"FullFormattedMessage",
"field",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L126-L152 | train |
vmware/govmomi | simulator/event_manager.go | doEntityEventArgument | func doEntityEventArgument(event types.BaseEvent, f func(types.ManagedObjectReference, *types.EntityEventArgument) bool) bool {
e := event.GetEvent()
if arg := e.Vm; arg != nil {
if f(arg.Vm, &arg.EntityEventArgument) {
return true
}
}
if arg := e.Host; arg != nil {
if f(arg.Host, &arg.EntityEventArgumen... | go | func doEntityEventArgument(event types.BaseEvent, f func(types.ManagedObjectReference, *types.EntityEventArgument) bool) bool {
e := event.GetEvent()
if arg := e.Vm; arg != nil {
if f(arg.Vm, &arg.EntityEventArgument) {
return true
}
}
if arg := e.Host; arg != nil {
if f(arg.Host, &arg.EntityEventArgumen... | [
"func",
"doEntityEventArgument",
"(",
"event",
"types",
".",
"BaseEvent",
",",
"f",
"func",
"(",
"types",
".",
"ManagedObjectReference",
",",
"*",
"types",
".",
"EntityEventArgument",
")",
"bool",
")",
"bool",
"{",
"e",
":=",
"event",
".",
"GetEvent",
"(",
... | // doEntityEventArgument calls f for each entity argument in the event.
// If f returns true, the iteration stops. | [
"doEntityEventArgument",
"calls",
"f",
"for",
"each",
"entity",
"argument",
"in",
"the",
"event",
".",
"If",
"f",
"returns",
"true",
"the",
"iteration",
"stops",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L191-L237 | train |
vmware/govmomi | simulator/event_manager.go | eventFilterSelf | func eventFilterSelf(event types.BaseEvent, self types.ManagedObjectReference) bool {
return doEntityEventArgument(event, func(ref types.ManagedObjectReference, _ *types.EntityEventArgument) bool {
return self == ref
})
} | go | func eventFilterSelf(event types.BaseEvent, self types.ManagedObjectReference) bool {
return doEntityEventArgument(event, func(ref types.ManagedObjectReference, _ *types.EntityEventArgument) bool {
return self == ref
})
} | [
"func",
"eventFilterSelf",
"(",
"event",
"types",
".",
"BaseEvent",
",",
"self",
"types",
".",
"ManagedObjectReference",
")",
"bool",
"{",
"return",
"doEntityEventArgument",
"(",
"event",
",",
"func",
"(",
"ref",
"types",
".",
"ManagedObjectReference",
",",
"_",... | // eventFilterSelf returns true if self is one of the entity arguments in the event. | [
"eventFilterSelf",
"returns",
"true",
"if",
"self",
"is",
"one",
"of",
"the",
"entity",
"arguments",
"in",
"the",
"event",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L240-L244 | train |
vmware/govmomi | simulator/event_manager.go | eventFilterChildren | func eventFilterChildren(event types.BaseEvent, self types.ManagedObjectReference) bool {
return doEntityEventArgument(event, func(ref types.ManagedObjectReference, _ *types.EntityEventArgument) bool {
seen := false
var match func(types.ManagedObjectReference)
match = func(child types.ManagedObjectReference) {... | go | func eventFilterChildren(event types.BaseEvent, self types.ManagedObjectReference) bool {
return doEntityEventArgument(event, func(ref types.ManagedObjectReference, _ *types.EntityEventArgument) bool {
seen := false
var match func(types.ManagedObjectReference)
match = func(child types.ManagedObjectReference) {... | [
"func",
"eventFilterChildren",
"(",
"event",
"types",
".",
"BaseEvent",
",",
"self",
"types",
".",
"ManagedObjectReference",
")",
"bool",
"{",
"return",
"doEntityEventArgument",
"(",
"event",
",",
"func",
"(",
"ref",
"types",
".",
"ManagedObjectReference",
",",
... | // eventFilterChildren returns true if a child of self is one of the entity arguments in the event. | [
"eventFilterChildren",
"returns",
"true",
"if",
"a",
"child",
"of",
"self",
"is",
"one",
"of",
"the",
"entity",
"arguments",
"in",
"the",
"event",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L247-L266 | train |
vmware/govmomi | simulator/event_manager.go | entityMatches | func (c *EventHistoryCollector) entityMatches(event types.BaseEvent, spec *types.EventFilterSpec) bool {
e := spec.Entity
if e == nil {
return true
}
isRootFolder := c.m.root == e.Entity
switch e.Recursion {
case types.EventFilterSpecRecursionOptionSelf:
return isRootFolder || eventFilterSelf(event, e.Entit... | go | func (c *EventHistoryCollector) entityMatches(event types.BaseEvent, spec *types.EventFilterSpec) bool {
e := spec.Entity
if e == nil {
return true
}
isRootFolder := c.m.root == e.Entity
switch e.Recursion {
case types.EventFilterSpecRecursionOptionSelf:
return isRootFolder || eventFilterSelf(event, e.Entit... | [
"func",
"(",
"c",
"*",
"EventHistoryCollector",
")",
"entityMatches",
"(",
"event",
"types",
".",
"BaseEvent",
",",
"spec",
"*",
"types",
".",
"EventFilterSpec",
")",
"bool",
"{",
"e",
":=",
"spec",
".",
"Entity",
"\n",
"if",
"e",
"==",
"nil",
"{",
"re... | // entityMatches returns true if the spec Entity filter matches the event. | [
"entityMatches",
"returns",
"true",
"if",
"the",
"spec",
"Entity",
"filter",
"matches",
"the",
"event",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L269-L290 | train |
vmware/govmomi | simulator/event_manager.go | typeMatches | func (c *EventHistoryCollector) typeMatches(event types.BaseEvent, spec *types.EventFilterSpec) bool {
if len(spec.EventTypeId) == 0 {
return true
}
matches := func(name string) bool {
for _, id := range spec.EventTypeId {
if id == name {
return true
}
}
return false
}
kind := reflect.ValueOf(ev... | go | func (c *EventHistoryCollector) typeMatches(event types.BaseEvent, spec *types.EventFilterSpec) bool {
if len(spec.EventTypeId) == 0 {
return true
}
matches := func(name string) bool {
for _, id := range spec.EventTypeId {
if id == name {
return true
}
}
return false
}
kind := reflect.ValueOf(ev... | [
"func",
"(",
"c",
"*",
"EventHistoryCollector",
")",
"typeMatches",
"(",
"event",
"types",
".",
"BaseEvent",
",",
"spec",
"*",
"types",
".",
"EventFilterSpec",
")",
"bool",
"{",
"if",
"len",
"(",
"spec",
".",
"EventTypeId",
")",
"==",
"0",
"{",
"return",... | // typeMatches returns true if one of the spec EventTypeId types matches the event. | [
"typeMatches",
"returns",
"true",
"if",
"one",
"of",
"the",
"spec",
"EventTypeId",
"types",
"matches",
"the",
"event",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L293-L317 | train |
vmware/govmomi | simulator/event_manager.go | eventMatches | func (c *EventHistoryCollector) eventMatches(event types.BaseEvent) bool {
spec := c.Filter.(types.EventFilterSpec)
if !c.typeMatches(event, &spec) {
return false
}
// TODO: spec.Time, spec.UserName, etc
return c.entityMatches(event, &spec)
} | go | func (c *EventHistoryCollector) eventMatches(event types.BaseEvent) bool {
spec := c.Filter.(types.EventFilterSpec)
if !c.typeMatches(event, &spec) {
return false
}
// TODO: spec.Time, spec.UserName, etc
return c.entityMatches(event, &spec)
} | [
"func",
"(",
"c",
"*",
"EventHistoryCollector",
")",
"eventMatches",
"(",
"event",
"types",
".",
"BaseEvent",
")",
"bool",
"{",
"spec",
":=",
"c",
".",
"Filter",
".",
"(",
"types",
".",
"EventFilterSpec",
")",
"\n\n",
"if",
"!",
"c",
".",
"typeMatches",
... | // eventMatches returns true one of the filters matches the event. | [
"eventMatches",
"returns",
"true",
"one",
"of",
"the",
"filters",
"matches",
"the",
"event",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L320-L330 | train |
vmware/govmomi | simulator/event_manager.go | fillPage | func (c *EventHistoryCollector) fillPage(size int) {
c.pos = 0
l := c.page.Len()
delta := size - l
if delta < 0 {
// Shrink ring size
c.page = c.page.Unlink(-delta)
return
}
matches := 0
mpage := c.m.page
page := c.page
if delta != 0 {
// Grow ring size
c.page = c.page.Link(ring.New(delta))
}
f... | go | func (c *EventHistoryCollector) fillPage(size int) {
c.pos = 0
l := c.page.Len()
delta := size - l
if delta < 0 {
// Shrink ring size
c.page = c.page.Unlink(-delta)
return
}
matches := 0
mpage := c.m.page
page := c.page
if delta != 0 {
// Grow ring size
c.page = c.page.Link(ring.New(delta))
}
f... | [
"func",
"(",
"c",
"*",
"EventHistoryCollector",
")",
"fillPage",
"(",
"size",
"int",
")",
"{",
"c",
".",
"pos",
"=",
"0",
"\n",
"l",
":=",
"c",
".",
"page",
".",
"Len",
"(",
")",
"\n",
"delta",
":=",
"size",
"-",
"l",
"\n\n",
"if",
"delta",
"<"... | // filePage copies the manager's latest events into the collector's page with Filter applied. | [
"filePage",
"copies",
"the",
"manager",
"s",
"latest",
"events",
"into",
"the",
"collector",
"s",
"page",
"with",
"Filter",
"applied",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/event_manager.go#L333-L369 | train |
vmware/govmomi | object/virtual_disk_manager.go | CopyVirtualDisk | func (m VirtualDiskManager) CopyVirtualDisk(
ctx context.Context,
sourceName string, sourceDatacenter *Datacenter,
destName string, destDatacenter *Datacenter,
destSpec *types.VirtualDiskSpec, force bool) (*Task, error) {
req := types.CopyVirtualDisk_Task{
This: m.Reference(),
SourceName: sourceName,
... | go | func (m VirtualDiskManager) CopyVirtualDisk(
ctx context.Context,
sourceName string, sourceDatacenter *Datacenter,
destName string, destDatacenter *Datacenter,
destSpec *types.VirtualDiskSpec, force bool) (*Task, error) {
req := types.CopyVirtualDisk_Task{
This: m.Reference(),
SourceName: sourceName,
... | [
"func",
"(",
"m",
"VirtualDiskManager",
")",
"CopyVirtualDisk",
"(",
"ctx",
"context",
".",
"Context",
",",
"sourceName",
"string",
",",
"sourceDatacenter",
"*",
"Datacenter",
",",
"destName",
"string",
",",
"destDatacenter",
"*",
"Datacenter",
",",
"destSpec",
... | // CopyVirtualDisk copies a virtual disk, performing conversions as specified in the spec. | [
"CopyVirtualDisk",
"copies",
"a",
"virtual",
"disk",
"performing",
"conversions",
"as",
"specified",
"in",
"the",
"spec",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_disk_manager.go#L40-L70 | train |
vmware/govmomi | object/virtual_disk_manager.go | CreateVirtualDisk | func (m VirtualDiskManager) CreateVirtualDisk(
ctx context.Context,
name string, datacenter *Datacenter,
spec types.BaseVirtualDiskSpec) (*Task, error) {
req := types.CreateVirtualDisk_Task{
This: m.Reference(),
Name: name,
Spec: spec,
}
if datacenter != nil {
ref := datacenter.Reference()
req.Datacen... | go | func (m VirtualDiskManager) CreateVirtualDisk(
ctx context.Context,
name string, datacenter *Datacenter,
spec types.BaseVirtualDiskSpec) (*Task, error) {
req := types.CreateVirtualDisk_Task{
This: m.Reference(),
Name: name,
Spec: spec,
}
if datacenter != nil {
ref := datacenter.Reference()
req.Datacen... | [
"func",
"(",
"m",
"VirtualDiskManager",
")",
"CreateVirtualDisk",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"datacenter",
"*",
"Datacenter",
",",
"spec",
"types",
".",
"BaseVirtualDiskSpec",
")",
"(",
"*",
"Task",
",",
"error",
")",
... | // CreateVirtualDisk creates a new virtual disk. | [
"CreateVirtualDisk",
"creates",
"a",
"new",
"virtual",
"disk",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_disk_manager.go#L73-L95 | train |
vmware/govmomi | object/virtual_disk_manager.go | ShrinkVirtualDisk | func (m VirtualDiskManager) ShrinkVirtualDisk(ctx context.Context, name string, dc *Datacenter, copy *bool) (*Task, error) {
req := types.ShrinkVirtualDisk_Task{
This: m.Reference(),
Name: name,
Copy: copy,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.ShrinkVirtual... | go | func (m VirtualDiskManager) ShrinkVirtualDisk(ctx context.Context, name string, dc *Datacenter, copy *bool) (*Task, error) {
req := types.ShrinkVirtualDisk_Task{
This: m.Reference(),
Name: name,
Copy: copy,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.ShrinkVirtual... | [
"func",
"(",
"m",
"VirtualDiskManager",
")",
"ShrinkVirtualDisk",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"dc",
"*",
"Datacenter",
",",
"copy",
"*",
"bool",
")",
"(",
"*",
"Task",
",",
"error",
")",
"{",
"req",
":=",
"types",... | // ShrinkVirtualDisk shrinks a virtual disk. | [
"ShrinkVirtualDisk",
"shrinks",
"a",
"virtual",
"disk",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_disk_manager.go#L169-L187 | train |
vmware/govmomi | object/virtual_disk_manager.go | QueryVirtualDiskUuid | func (m VirtualDiskManager) QueryVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter) (string, error) {
req := types.QueryVirtualDiskUuid{
This: m.Reference(),
Name: name,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.QueryVirtualDiskUuid(ctx, m.c, &req)
... | go | func (m VirtualDiskManager) QueryVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter) (string, error) {
req := types.QueryVirtualDiskUuid{
This: m.Reference(),
Name: name,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.QueryVirtualDiskUuid(ctx, m.c, &req)
... | [
"func",
"(",
"m",
"VirtualDiskManager",
")",
"QueryVirtualDiskUuid",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"dc",
"*",
"Datacenter",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
"QueryVirtualDiskUuid",
... | // Queries virtual disk uuid | [
"Queries",
"virtual",
"disk",
"uuid"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/virtual_disk_manager.go#L190-L211 | train |
vmware/govmomi | toolbox/service.go | NewService | func NewService(rpcIn Channel, rpcOut Channel) *Service {
s := &Service{
name: "toolbox", // Same name used by vmtoolsd
in: NewTraceChannel(rpcIn),
out: &ChannelOut{NewTraceChannel(rpcOut)},
handlers: make(map[string]Handler),
wg: new(sync.WaitGroup),
stop: make(chan struct{}),
... | go | func NewService(rpcIn Channel, rpcOut Channel) *Service {
s := &Service{
name: "toolbox", // Same name used by vmtoolsd
in: NewTraceChannel(rpcIn),
out: &ChannelOut{NewTraceChannel(rpcOut)},
handlers: make(map[string]Handler),
wg: new(sync.WaitGroup),
stop: make(chan struct{}),
... | [
"func",
"NewService",
"(",
"rpcIn",
"Channel",
",",
"rpcOut",
"Channel",
")",
"*",
"Service",
"{",
"s",
":=",
"&",
"Service",
"{",
"name",
":",
"\"",
"\"",
",",
"// Same name used by vmtoolsd",
"in",
":",
"NewTraceChannel",
"(",
"rpcIn",
")",
",",
"out",
... | // NewService initializes a Service instance | [
"NewService",
"initializes",
"a",
"Service",
"instance"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L75-L100 | train |
vmware/govmomi | toolbox/service.go | backoff | func (s *Service) backoff() {
if s.delay < maxDelay {
if s.delay > 0 {
d := s.delay * 2
if d > s.delay && d < maxDelay {
s.delay = d
} else {
s.delay = maxDelay
}
} else {
s.delay = 1
}
}
} | go | func (s *Service) backoff() {
if s.delay < maxDelay {
if s.delay > 0 {
d := s.delay * 2
if d > s.delay && d < maxDelay {
s.delay = d
} else {
s.delay = maxDelay
}
} else {
s.delay = 1
}
}
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"backoff",
"(",
")",
"{",
"if",
"s",
".",
"delay",
"<",
"maxDelay",
"{",
"if",
"s",
".",
"delay",
">",
"0",
"{",
"d",
":=",
"s",
".",
"delay",
"*",
"2",
"\n",
"if",
"d",
">",
"s",
".",
"delay",
"&&",
... | // backoff exponentially increases the RPC poll delay up to maxDelay | [
"backoff",
"exponentially",
"increases",
"the",
"RPC",
"poll",
"delay",
"up",
"to",
"maxDelay"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L103-L116 | train |
vmware/govmomi | toolbox/service.go | Start | func (s *Service) Start() error {
err := s.startChannel()
if err != nil {
return err
}
s.wg.Add(1)
go func() {
defer s.wg.Done()
// Same polling interval and backoff logic as vmtoolsd.
// Required in our case at startup at least, otherwise it is possible
// we miss the 1 Capabilities_Register call for ... | go | func (s *Service) Start() error {
err := s.startChannel()
if err != nil {
return err
}
s.wg.Add(1)
go func() {
defer s.wg.Done()
// Same polling interval and backoff logic as vmtoolsd.
// Required in our case at startup at least, otherwise it is possible
// we miss the 1 Capabilities_Register call for ... | [
"func",
"(",
"s",
"*",
"Service",
")",
"Start",
"(",
")",
"error",
"{",
"err",
":=",
"s",
".",
"startChannel",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"s",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",... | // Start initializes the RPC channels and starts a goroutine to listen for incoming RPC requests | [
"Start",
"initializes",
"the",
"RPC",
"channels",
"and",
"starts",
"a",
"goroutine",
"to",
"listen",
"for",
"incoming",
"RPC",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L147-L196 | train |
vmware/govmomi | toolbox/service.go | RegisterHandler | func (s *Service) RegisterHandler(name string, handler Handler) {
s.handlers[name] = handler
} | go | func (s *Service) RegisterHandler(name string, handler Handler) {
s.handlers[name] = handler
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"RegisterHandler",
"(",
"name",
"string",
",",
"handler",
"Handler",
")",
"{",
"s",
".",
"handlers",
"[",
"name",
"]",
"=",
"handler",
"\n",
"}"
] | // RegisterHandler for the given RPC name | [
"RegisterHandler",
"for",
"the",
"given",
"RPC",
"name"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L212-L214 | train |
vmware/govmomi | toolbox/service.go | Dispatch | func (s *Service) Dispatch(request []byte) []byte {
msg := bytes.SplitN(request, []byte{' '}, 2)
name := msg[0]
// Trim NULL byte terminator
name = bytes.TrimRight(name, "\x00")
handler, ok := s.handlers[string(name)]
if !ok {
log.Printf("unknown command: %q\n", name)
return []byte("Unknown Command")
}
... | go | func (s *Service) Dispatch(request []byte) []byte {
msg := bytes.SplitN(request, []byte{' '}, 2)
name := msg[0]
// Trim NULL byte terminator
name = bytes.TrimRight(name, "\x00")
handler, ok := s.handlers[string(name)]
if !ok {
log.Printf("unknown command: %q\n", name)
return []byte("Unknown Command")
}
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"Dispatch",
"(",
"request",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"msg",
":=",
"bytes",
".",
"SplitN",
"(",
"request",
",",
"[",
"]",
"byte",
"{",
"' '",
"}",
",",
"2",
")",
"\n",
"name",
":=",
"... | // Dispatch an incoming RPC request to a Handler | [
"Dispatch",
"an",
"incoming",
"RPC",
"request",
"to",
"a",
"Handler"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L217-L245 | train |
vmware/govmomi | toolbox/service.go | Reset | func (s *Service) Reset([]byte) ([]byte, error) {
s.SendGuestInfo() // Send the IP info ASAP
return []byte("ATR " + s.name), nil
} | go | func (s *Service) Reset([]byte) ([]byte, error) {
s.SendGuestInfo() // Send the IP info ASAP
return []byte("ATR " + s.name), nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"Reset",
"(",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"s",
".",
"SendGuestInfo",
"(",
")",
"// Send the IP info ASAP",
"\n\n",
"return",
"[",
"]",
"byte",
"(",
"\"",
"\"",
"+",
... | // Reset is the default Handler for reset requests | [
"Reset",
"is",
"the",
"default",
"Handler",
"for",
"reset",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L248-L252 | train |
vmware/govmomi | toolbox/service.go | SetOption | func (s *Service) SetOption(args []byte) ([]byte, error) {
opts := bytes.SplitN(args, []byte{' '}, 2)
key := string(opts[0])
val := string(opts[1])
if Trace {
fmt.Fprintf(os.Stderr, "set option %q=%q\n", key, val)
}
switch key {
case "broadcastIP": // TODO: const-ify
if val == "1" {
ip := s.PrimaryIP()
... | go | func (s *Service) SetOption(args []byte) ([]byte, error) {
opts := bytes.SplitN(args, []byte{' '}, 2)
key := string(opts[0])
val := string(opts[1])
if Trace {
fmt.Fprintf(os.Stderr, "set option %q=%q\n", key, val)
}
switch key {
case "broadcastIP": // TODO: const-ify
if val == "1" {
ip := s.PrimaryIP()
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"SetOption",
"(",
"args",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"opts",
":=",
"bytes",
".",
"SplitN",
"(",
"args",
",",
"[",
"]",
"byte",
"{",
"' '",
"}",
",",
"2",
")",
... | // SetOption is the default Handler for Set_Option requests | [
"SetOption",
"is",
"the",
"default",
"Handler",
"for",
"Set_Option",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L260-L290 | train |
vmware/govmomi | toolbox/service.go | DefaultIP | func DefaultIP() string {
addrs, err := netInterfaceAddrs()
if err == nil {
for _, addr := range addrs {
if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
if ip.IP.To4() != nil {
return ip.IP.String()
}
}
}
}
return ""
} | go | func DefaultIP() string {
addrs, err := netInterfaceAddrs()
if err == nil {
for _, addr := range addrs {
if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
if ip.IP.To4() != nil {
return ip.IP.String()
}
}
}
}
return ""
} | [
"func",
"DefaultIP",
"(",
")",
"string",
"{",
"addrs",
",",
"err",
":=",
"netInterfaceAddrs",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"for",
"_",
",",
"addr",
":=",
"range",
"addrs",
"{",
"if",
"ip",
",",
"ok",
":=",
"addr",
".",
"(",
"*",... | // DefaultIP is used by default when responding to a Set_Option broadcastIP request
// It can be overridden with the Service.PrimaryIP field | [
"DefaultIP",
"is",
"used",
"by",
"default",
"when",
"responding",
"to",
"a",
"Set_Option",
"broadcastIP",
"request",
"It",
"can",
"be",
"overridden",
"with",
"the",
"Service",
".",
"PrimaryIP",
"field"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/service.go#L294-L307 | train |
vmware/govmomi | object/namespace_manager.go | CreateDirectory | func (nm DatastoreNamespaceManager) CreateDirectory(ctx context.Context, ds *Datastore, displayName string, policy string) (string, error) {
req := &types.CreateDirectory{
This: nm.Reference(),
Datastore: ds.Reference(),
DisplayName: displayName,
Policy: policy,
}
resp, err := methods.CreateD... | go | func (nm DatastoreNamespaceManager) CreateDirectory(ctx context.Context, ds *Datastore, displayName string, policy string) (string, error) {
req := &types.CreateDirectory{
This: nm.Reference(),
Datastore: ds.Reference(),
DisplayName: displayName,
Policy: policy,
}
resp, err := methods.CreateD... | [
"func",
"(",
"nm",
"DatastoreNamespaceManager",
")",
"CreateDirectory",
"(",
"ctx",
"context",
".",
"Context",
",",
"ds",
"*",
"Datastore",
",",
"displayName",
"string",
",",
"policy",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
":=",
"&",... | // CreateDirectory creates a top-level directory on the given vsan datastore, using
// the given user display name hint and opaque storage policy. | [
"CreateDirectory",
"creates",
"a",
"top",
"-",
"level",
"directory",
"on",
"the",
"given",
"vsan",
"datastore",
"using",
"the",
"given",
"user",
"display",
"name",
"hint",
"and",
"opaque",
"storage",
"policy",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/namespace_manager.go#L41-L56 | train |
vmware/govmomi | object/namespace_manager.go | DeleteDirectory | func (nm DatastoreNamespaceManager) DeleteDirectory(ctx context.Context, dc *Datacenter, datastorePath string) error {
req := &types.DeleteDirectory{
This: nm.Reference(),
DatastorePath: datastorePath,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
if _, err := methods.DeleteDir... | go | func (nm DatastoreNamespaceManager) DeleteDirectory(ctx context.Context, dc *Datacenter, datastorePath string) error {
req := &types.DeleteDirectory{
This: nm.Reference(),
DatastorePath: datastorePath,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
if _, err := methods.DeleteDir... | [
"func",
"(",
"nm",
"DatastoreNamespaceManager",
")",
"DeleteDirectory",
"(",
"ctx",
"context",
".",
"Context",
",",
"dc",
"*",
"Datacenter",
",",
"datastorePath",
"string",
")",
"error",
"{",
"req",
":=",
"&",
"types",
".",
"DeleteDirectory",
"{",
"This",
":... | // DeleteDirectory deletes the given top-level directory from a vsan datastore. | [
"DeleteDirectory",
"deletes",
"the",
"given",
"top",
"-",
"level",
"directory",
"from",
"a",
"vsan",
"datastore",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/namespace_manager.go#L59-L76 | train |
vmware/govmomi | performance/manager.go | NewManager | func NewManager(client *vim25.Client) *Manager {
m := Manager{
Common: object.NewCommon(client, *client.ServiceContent.PerfManager),
}
m.pm.PerformanceManager = new(mo.PerformanceManager)
return &m
} | go | func NewManager(client *vim25.Client) *Manager {
m := Manager{
Common: object.NewCommon(client, *client.ServiceContent.PerfManager),
}
m.pm.PerformanceManager = new(mo.PerformanceManager)
return &m
} | [
"func",
"NewManager",
"(",
"client",
"*",
"vim25",
".",
"Client",
")",
"*",
"Manager",
"{",
"m",
":=",
"Manager",
"{",
"Common",
":",
"object",
".",
"NewCommon",
"(",
"client",
",",
"*",
"client",
".",
"ServiceContent",
".",
"PerfManager",
")",
",",
"}... | // NewManager creates a new Manager instance. | [
"NewManager",
"creates",
"a",
"new",
"Manager",
"instance",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L58-L66 | train |
vmware/govmomi | performance/manager.go | HistoricalInterval | func (m *Manager) HistoricalInterval(ctx context.Context) (IntervalList, error) {
var pm mo.PerformanceManager
err := m.Properties(ctx, m.Reference(), []string{"historicalInterval"}, &pm)
if err != nil {
return nil, err
}
return IntervalList(pm.HistoricalInterval), nil
} | go | func (m *Manager) HistoricalInterval(ctx context.Context) (IntervalList, error) {
var pm mo.PerformanceManager
err := m.Properties(ctx, m.Reference(), []string{"historicalInterval"}, &pm)
if err != nil {
return nil, err
}
return IntervalList(pm.HistoricalInterval), nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"HistoricalInterval",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"IntervalList",
",",
"error",
")",
"{",
"var",
"pm",
"mo",
".",
"PerformanceManager",
"\n\n",
"err",
":=",
"m",
".",
"Properties",
"(",
"ctx",
... | // HistoricalInterval gets the PerformanceManager.HistoricalInterval property and wraps as an IntervalList. | [
"HistoricalInterval",
"gets",
"the",
"PerformanceManager",
".",
"HistoricalInterval",
"property",
"and",
"wraps",
"as",
"an",
"IntervalList",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L91-L100 | train |
vmware/govmomi | performance/manager.go | CounterInfo | func (m *Manager) CounterInfo(ctx context.Context) ([]types.PerfCounterInfo, error) {
m.pm.Lock()
defer m.pm.Unlock()
if len(m.pm.PerfCounter) == 0 {
err := m.Properties(ctx, m.Reference(), []string{"perfCounter"}, m.pm.PerformanceManager)
if err != nil {
return nil, err
}
}
return m.pm.PerfCounter, nil... | go | func (m *Manager) CounterInfo(ctx context.Context) ([]types.PerfCounterInfo, error) {
m.pm.Lock()
defer m.pm.Unlock()
if len(m.pm.PerfCounter) == 0 {
err := m.Properties(ctx, m.Reference(), []string{"perfCounter"}, m.pm.PerformanceManager)
if err != nil {
return nil, err
}
}
return m.pm.PerfCounter, nil... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"CounterInfo",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"types",
".",
"PerfCounterInfo",
",",
"error",
")",
"{",
"m",
".",
"pm",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"pm",
".",
... | // CounterInfo gets the PerformanceManager.PerfCounter property.
// The property value is only collected once, subsequent calls return the cached value. | [
"CounterInfo",
"gets",
"the",
"PerformanceManager",
".",
"PerfCounter",
"property",
".",
"The",
"property",
"value",
"is",
"only",
"collected",
"once",
"subsequent",
"calls",
"return",
"the",
"cached",
"value",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L104-L116 | train |
vmware/govmomi | performance/manager.go | CounterInfoByKey | func (m *Manager) CounterInfoByKey(ctx context.Context) (map[int32]*types.PerfCounterInfo, error) {
m.infoByKey.Lock()
defer m.infoByKey.Unlock()
if m.infoByKey.m != nil {
return m.infoByKey.m, nil
}
info, err := m.CounterInfo(ctx)
if err != nil {
return nil, err
}
m.infoByKey.m = make(map[int32]*types.P... | go | func (m *Manager) CounterInfoByKey(ctx context.Context) (map[int32]*types.PerfCounterInfo, error) {
m.infoByKey.Lock()
defer m.infoByKey.Unlock()
if m.infoByKey.m != nil {
return m.infoByKey.m, nil
}
info, err := m.CounterInfo(ctx)
if err != nil {
return nil, err
}
m.infoByKey.m = make(map[int32]*types.P... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"CounterInfoByKey",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"int32",
"]",
"*",
"types",
".",
"PerfCounterInfo",
",",
"error",
")",
"{",
"m",
".",
"infoByKey",
".",
"Lock",
"(",
")",
"\n",
... | // CounterInfoByKey converts the PerformanceManager.PerfCounter property to a map,
// where key is types.PerfCounterInfo.Key. | [
"CounterInfoByKey",
"converts",
"the",
"PerformanceManager",
".",
"PerfCounter",
"property",
"to",
"a",
"map",
"where",
"key",
"is",
"types",
".",
"PerfCounterInfo",
".",
"Key",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L146-L168 | train |
vmware/govmomi | performance/manager.go | ProviderSummary | func (m *Manager) ProviderSummary(ctx context.Context, entity types.ManagedObjectReference) (*types.PerfProviderSummary, error) {
req := types.QueryPerfProviderSummary{
This: m.Reference(),
Entity: entity,
}
res, err := methods.QueryPerfProviderSummary(ctx, m.Client(), &req)
if err != nil {
return nil, err... | go | func (m *Manager) ProviderSummary(ctx context.Context, entity types.ManagedObjectReference) (*types.PerfProviderSummary, error) {
req := types.QueryPerfProviderSummary{
This: m.Reference(),
Entity: entity,
}
res, err := methods.QueryPerfProviderSummary(ctx, m.Client(), &req)
if err != nil {
return nil, err... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ProviderSummary",
"(",
"ctx",
"context",
".",
"Context",
",",
"entity",
"types",
".",
"ManagedObjectReference",
")",
"(",
"*",
"types",
".",
"PerfProviderSummary",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
... | // ProviderSummary wraps the QueryPerfProviderSummary method, caching the value based on entity.Type. | [
"ProviderSummary",
"wraps",
"the",
"QueryPerfProviderSummary",
"method",
"caching",
"the",
"value",
"based",
"on",
"entity",
".",
"Type",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L171-L183 | train |
vmware/govmomi | performance/manager.go | AvailableMetric | func (m *Manager) AvailableMetric(ctx context.Context, entity types.ManagedObjectReference, interval int32) (MetricList, error) {
req := types.QueryAvailablePerfMetric{
This: m.Reference(),
Entity: entity.Reference(),
IntervalId: interval,
}
res, err := methods.QueryAvailablePerfMetric(ctx, m.Client... | go | func (m *Manager) AvailableMetric(ctx context.Context, entity types.ManagedObjectReference, interval int32) (MetricList, error) {
req := types.QueryAvailablePerfMetric{
This: m.Reference(),
Entity: entity.Reference(),
IntervalId: interval,
}
res, err := methods.QueryAvailablePerfMetric(ctx, m.Client... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"AvailableMetric",
"(",
"ctx",
"context",
".",
"Context",
",",
"entity",
"types",
".",
"ManagedObjectReference",
",",
"interval",
"int32",
")",
"(",
"MetricList",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
"... | // AvailableMetric wraps the QueryAvailablePerfMetric method.
// The MetricList is sorted by PerfCounterInfo.GroupInfo.Key if Manager.Sort == true. | [
"AvailableMetric",
"wraps",
"the",
"QueryAvailablePerfMetric",
"method",
".",
"The",
"MetricList",
"is",
"sorted",
"by",
"PerfCounterInfo",
".",
"GroupInfo",
".",
"Key",
"if",
"Manager",
".",
"Sort",
"==",
"true",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L224-L246 | train |
vmware/govmomi | performance/manager.go | Query | func (m *Manager) Query(ctx context.Context, spec []types.PerfQuerySpec) ([]types.BasePerfEntityMetricBase, error) {
req := types.QueryPerf{
This: m.Reference(),
QuerySpec: spec,
}
res, err := methods.QueryPerf(ctx, m.Client(), &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
} | go | func (m *Manager) Query(ctx context.Context, spec []types.PerfQuerySpec) ([]types.BasePerfEntityMetricBase, error) {
req := types.QueryPerf{
This: m.Reference(),
QuerySpec: spec,
}
res, err := methods.QueryPerf(ctx, m.Client(), &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"spec",
"[",
"]",
"types",
".",
"PerfQuerySpec",
")",
"(",
"[",
"]",
"types",
".",
"BasePerfEntityMetricBase",
",",
"error",
")",
"{",
"req",
":=",
"types",
"... | // Query wraps the QueryPerf method. | [
"Query",
"wraps",
"the",
"QueryPerf",
"method",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L249-L261 | train |
vmware/govmomi | performance/manager.go | ValueCSV | func (s *MetricSeries) ValueCSV() string {
vals := make([]string, len(s.Value))
for i := range s.Value {
vals[i] = s.Format(s.Value[i])
}
return strings.Join(vals, ",")
} | go | func (s *MetricSeries) ValueCSV() string {
vals := make([]string, len(s.Value))
for i := range s.Value {
vals[i] = s.Format(s.Value[i])
}
return strings.Join(vals, ",")
} | [
"func",
"(",
"s",
"*",
"MetricSeries",
")",
"ValueCSV",
"(",
")",
"string",
"{",
"vals",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"s",
".",
"Value",
")",
")",
"\n\n",
"for",
"i",
":=",
"range",
"s",
".",
"Value",
"{",
"vals",
"["... | // ValueCSV converts the Value field to a CSV string | [
"ValueCSV",
"converts",
"the",
"Value",
"field",
"to",
"a",
"CSV",
"string"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L341-L349 | train |
vmware/govmomi | performance/manager.go | SampleInfoCSV | func (m *EntityMetric) SampleInfoCSV() string {
vals := make([]string, len(m.SampleInfo)*2)
i := 0
for _, s := range m.SampleInfo {
vals[i] = s.Timestamp.Format(time.RFC3339)
i++
vals[i] = strconv.Itoa(int(s.Interval))
i++
}
return strings.Join(vals, ",")
} | go | func (m *EntityMetric) SampleInfoCSV() string {
vals := make([]string, len(m.SampleInfo)*2)
i := 0
for _, s := range m.SampleInfo {
vals[i] = s.Timestamp.Format(time.RFC3339)
i++
vals[i] = strconv.Itoa(int(s.Interval))
i++
}
return strings.Join(vals, ",")
} | [
"func",
"(",
"m",
"*",
"EntityMetric",
")",
"SampleInfoCSV",
"(",
")",
"string",
"{",
"vals",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"m",
".",
"SampleInfo",
")",
"*",
"2",
")",
"\n\n",
"i",
":=",
"0",
"\n\n",
"for",
"_",
",",
"... | // SampleInfoCSV converts the SampleInfo field to a CSV string | [
"SampleInfoCSV",
"converts",
"the",
"SampleInfo",
"field",
"to",
"a",
"CSV",
"string"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/performance/manager.go#L360-L373 | train |
vmware/govmomi | govc/flags/host_connect.go | Spec | func (flag *HostConnectFlag) Spec(c *vim25.Client) types.HostConnectSpec {
spec := flag.HostConnectSpec
if spec.SslThumbprint == "" {
spec.SslThumbprint = c.Thumbprint(spec.HostName)
if spec.SslThumbprint == "" && flag.noverify {
var info object.HostCertificateInfo
t := c.Transport.(*http.Transport)
_ ... | go | func (flag *HostConnectFlag) Spec(c *vim25.Client) types.HostConnectSpec {
spec := flag.HostConnectSpec
if spec.SslThumbprint == "" {
spec.SslThumbprint = c.Thumbprint(spec.HostName)
if spec.SslThumbprint == "" && flag.noverify {
var info object.HostCertificateInfo
t := c.Transport.(*http.Transport)
_ ... | [
"func",
"(",
"flag",
"*",
"HostConnectFlag",
")",
"Spec",
"(",
"c",
"*",
"vim25",
".",
"Client",
")",
"types",
".",
"HostConnectSpec",
"{",
"spec",
":=",
"flag",
".",
"HostConnectSpec",
"\n\n",
"if",
"spec",
".",
"SslThumbprint",
"==",
"\"",
"\"",
"{",
... | // Spec attempts to fill in SslThumbprint if empty.
// First checks GOVC_TLS_KNOWN_HOSTS, if not found and noverify=true then
// use object.HostCertificateInfo to get the thumbprint. | [
"Spec",
"attempts",
"to",
"fill",
"in",
"SslThumbprint",
"if",
"empty",
".",
"First",
"checks",
"GOVC_TLS_KNOWN_HOSTS",
"if",
"not",
"found",
"and",
"noverify",
"=",
"true",
"then",
"use",
"object",
".",
"HostCertificateInfo",
"to",
"get",
"the",
"thumbprint",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/host_connect.go#L70-L85 | train |
vmware/govmomi | govc/flags/host_connect.go | Fault | func (flag *HostConnectFlag) Fault(err error) error {
if err == nil {
return nil
}
if f, ok := err.(types.HasFault); ok {
switch fault := f.Fault().(type) {
case *types.SSLVerifyFault:
return fmt.Errorf("%s thumbprint=%s", err, fault.Thumbprint)
}
}
return err
} | go | func (flag *HostConnectFlag) Fault(err error) error {
if err == nil {
return nil
}
if f, ok := err.(types.HasFault); ok {
switch fault := f.Fault().(type) {
case *types.SSLVerifyFault:
return fmt.Errorf("%s thumbprint=%s", err, fault.Thumbprint)
}
}
return err
} | [
"func",
"(",
"flag",
"*",
"HostConnectFlag",
")",
"Fault",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"f",
",",
"ok",
":=",
"err",
".",
"(",
"types",
".",
"HasFault",
")",
";",... | // Fault checks if error is SSLVerifyFault, including the thumbprint if so | [
"Fault",
"checks",
"if",
"error",
"is",
"SSLVerifyFault",
"including",
"the",
"thumbprint",
"if",
"so"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/host_connect.go#L88-L101 | train |
vmware/govmomi | guest/toolbox/client.go | Run | func (c *Client) Run(ctx context.Context, cmd *exec.Cmd) error {
vc := c.ProcessManager.Client()
spec := types.GuestProgramSpec{
ProgramPath: cmd.Path,
Arguments: strings.Join(cmd.Args, " "),
EnvVariables: cmd.Env,
WorkingDirectory: cmd.Dir,
}
pid, serr := c.ProcessManager.StartProgram(ctx... | go | func (c *Client) Run(ctx context.Context, cmd *exec.Cmd) error {
vc := c.ProcessManager.Client()
spec := types.GuestProgramSpec{
ProgramPath: cmd.Path,
Arguments: strings.Join(cmd.Args, " "),
EnvVariables: cmd.Env,
WorkingDirectory: cmd.Dir,
}
pid, serr := c.ProcessManager.StartProgram(ctx... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"cmd",
"*",
"exec",
".",
"Cmd",
")",
"error",
"{",
"vc",
":=",
"c",
".",
"ProcessManager",
".",
"Client",
"(",
")",
"\n\n",
"spec",
":=",
"types",
".",
"Gues... | // Run implements exec.Cmd.Run over vmx guest RPC. | [
"Run",
"implements",
"exec",
".",
"Cmd",
".",
"Run",
"over",
"vmx",
"guest",
"RPC",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/guest/toolbox/client.go#L141-L230 | train |
vmware/govmomi | guest/toolbox/client.go | Download | func (c *Client) Download(ctx context.Context, src string) (io.ReadCloser, int64, error) {
vc := c.ProcessManager.Client()
info, err := c.FileManager.InitiateFileTransferFromGuest(ctx, c.Authentication, src)
if err != nil {
return nil, 0, err
}
u, err := c.FileManager.TransferURL(ctx, info.Url)
if err != nil ... | go | func (c *Client) Download(ctx context.Context, src string) (io.ReadCloser, int64, error) {
vc := c.ProcessManager.Client()
info, err := c.FileManager.InitiateFileTransferFromGuest(ctx, c.Authentication, src)
if err != nil {
return nil, 0, err
}
u, err := c.FileManager.TransferURL(ctx, info.Url)
if err != nil ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Download",
"(",
"ctx",
"context",
".",
"Context",
",",
"src",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"int64",
",",
"error",
")",
"{",
"vc",
":=",
"c",
".",
"ProcessManager",
".",
"Client",
"(",
")",... | // Download initiates a file transfer from the guest | [
"Download",
"initiates",
"a",
"file",
"transfer",
"from",
"the",
"guest"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/guest/toolbox/client.go#L272-L297 | train |
vmware/govmomi | guest/toolbox/client.go | Upload | func (c *Client) Upload(ctx context.Context, src io.Reader, dst string, p soap.Upload, attr types.BaseGuestFileAttributes, force bool) error {
vc := c.ProcessManager.Client()
var err error
if p.ContentLength == 0 { // Content-Length is required
switch r := src.(type) {
case *bytes.Buffer:
p.ContentLength = ... | go | func (c *Client) Upload(ctx context.Context, src io.Reader, dst string, p soap.Upload, attr types.BaseGuestFileAttributes, force bool) error {
vc := c.ProcessManager.Client()
var err error
if p.ContentLength == 0 { // Content-Length is required
switch r := src.(type) {
case *bytes.Buffer:
p.ContentLength = ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Upload",
"(",
"ctx",
"context",
".",
"Context",
",",
"src",
"io",
".",
"Reader",
",",
"dst",
"string",
",",
"p",
"soap",
".",
"Upload",
",",
"attr",
"types",
".",
"BaseGuestFileAttributes",
",",
"force",
"bool",
... | // Upload transfers a file to the guest | [
"Upload",
"transfers",
"a",
"file",
"to",
"the",
"guest"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/guest/toolbox/client.go#L300-L345 | train |
vmware/govmomi | object/host_firewall_system.go | ByRule | func (l HostFirewallRulesetList) ByRule(rule types.HostFirewallRule) HostFirewallRulesetList {
var matches HostFirewallRulesetList
for _, rs := range l {
for _, r := range rs.Rule {
if r.PortType != rule.PortType ||
r.Protocol != rule.Protocol ||
r.Direction != rule.Direction {
continue
}
if ... | go | func (l HostFirewallRulesetList) ByRule(rule types.HostFirewallRule) HostFirewallRulesetList {
var matches HostFirewallRulesetList
for _, rs := range l {
for _, r := range rs.Rule {
if r.PortType != rule.PortType ||
r.Protocol != rule.Protocol ||
r.Direction != rule.Direction {
continue
}
if ... | [
"func",
"(",
"l",
"HostFirewallRulesetList",
")",
"ByRule",
"(",
"rule",
"types",
".",
"HostFirewallRule",
")",
"HostFirewallRulesetList",
"{",
"var",
"matches",
"HostFirewallRulesetList",
"\n\n",
"for",
"_",
",",
"rs",
":=",
"range",
"l",
"{",
"for",
"_",
","... | // ByRule returns a HostFirewallRulesetList where Direction, PortType and Protocol are equal and Port is within range | [
"ByRule",
"returns",
"a",
"HostFirewallRulesetList",
"where",
"Direction",
"PortType",
"and",
"Protocol",
"are",
"equal",
"and",
"Port",
"is",
"within",
"range"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_firewall_system.go#L85-L105 | train |
vmware/govmomi | object/host_firewall_system.go | Enabled | func (l HostFirewallRulesetList) Enabled() HostFirewallRulesetList {
var matches HostFirewallRulesetList
for _, rs := range l {
if rs.Enabled {
matches = append(matches, rs)
}
}
return matches
} | go | func (l HostFirewallRulesetList) Enabled() HostFirewallRulesetList {
var matches HostFirewallRulesetList
for _, rs := range l {
if rs.Enabled {
matches = append(matches, rs)
}
}
return matches
} | [
"func",
"(",
"l",
"HostFirewallRulesetList",
")",
"Enabled",
"(",
")",
"HostFirewallRulesetList",
"{",
"var",
"matches",
"HostFirewallRulesetList",
"\n\n",
"for",
"_",
",",
"rs",
":=",
"range",
"l",
"{",
"if",
"rs",
".",
"Enabled",
"{",
"matches",
"=",
"appe... | // Enabled returns a HostFirewallRulesetList with enabled rules | [
"Enabled",
"returns",
"a",
"HostFirewallRulesetList",
"with",
"enabled",
"rules"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_firewall_system.go#L147-L157 | train |
vmware/govmomi | object/host_firewall_system.go | Keys | func (l HostFirewallRulesetList) Keys() []string {
var keys []string
for _, rs := range l {
keys = append(keys, rs.Key)
}
return keys
} | go | func (l HostFirewallRulesetList) Keys() []string {
var keys []string
for _, rs := range l {
keys = append(keys, rs.Key)
}
return keys
} | [
"func",
"(",
"l",
"HostFirewallRulesetList",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"keys",
"[",
"]",
"string",
"\n\n",
"for",
"_",
",",
"rs",
":=",
"range",
"l",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"rs",
".",
"Key",
")"... | // Keys returns the HostFirewallRuleset.Key for each ruleset in the list | [
"Keys",
"returns",
"the",
"HostFirewallRuleset",
".",
"Key",
"for",
"each",
"ruleset",
"in",
"the",
"list"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_firewall_system.go#L173-L181 | train |
vmware/govmomi | vim25/xml/xml.go | CopyToken | func CopyToken(t Token) Token {
switch v := t.(type) {
case CharData:
return v.Copy()
case Comment:
return v.Copy()
case Directive:
return v.Copy()
case ProcInst:
return v.Copy()
case StartElement:
return v.Copy()
}
return t
} | go | func CopyToken(t Token) Token {
switch v := t.(type) {
case CharData:
return v.Copy()
case Comment:
return v.Copy()
case Directive:
return v.Copy()
case ProcInst:
return v.Copy()
case StartElement:
return v.Copy()
}
return t
} | [
"func",
"CopyToken",
"(",
"t",
"Token",
")",
"Token",
"{",
"switch",
"v",
":=",
"t",
".",
"(",
"type",
")",
"{",
"case",
"CharData",
":",
"return",
"v",
".",
"Copy",
"(",
")",
"\n",
"case",
"Comment",
":",
"return",
"v",
".",
"Copy",
"(",
")",
... | // CopyToken returns a copy of a Token. | [
"CopyToken",
"returns",
"a",
"copy",
"of",
"a",
"Token",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L118-L132 | train |
vmware/govmomi | vim25/xml/xml.go | NewDecoder | func NewDecoder(r io.Reader) *Decoder {
d := &Decoder{
ns: make(map[string]string),
nextByte: -1,
line: 1,
Strict: true,
}
d.switchToReader(r)
return d
} | go | func NewDecoder(r io.Reader) *Decoder {
d := &Decoder{
ns: make(map[string]string),
nextByte: -1,
line: 1,
Strict: true,
}
d.switchToReader(r)
return d
} | [
"func",
"NewDecoder",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Decoder",
"{",
"d",
":=",
"&",
"Decoder",
"{",
"ns",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
",",
"nextByte",
":",
"-",
"1",
",",
"line",
":",
"1",
",",
"Strict... | // NewDecoder creates a new XML parser reading from r.
// If r does not implement io.ByteReader, NewDecoder will
// do its own buffering. | [
"NewDecoder",
"creates",
"a",
"new",
"XML",
"parser",
"reading",
"from",
"r",
".",
"If",
"r",
"does",
"not",
"implement",
"io",
".",
"ByteReader",
"NewDecoder",
"will",
"do",
"its",
"own",
"buffering",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L209-L218 | train |
vmware/govmomi | vim25/xml/xml.go | popEOF | func (d *Decoder) popEOF() bool {
if d.stk == nil || d.stk.kind != stkEOF {
return false
}
d.pop()
return true
} | go | func (d *Decoder) popEOF() bool {
if d.stk == nil || d.stk.kind != stkEOF {
return false
}
d.pop()
return true
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"popEOF",
"(",
")",
"bool",
"{",
"if",
"d",
".",
"stk",
"==",
"nil",
"||",
"d",
".",
"stk",
".",
"kind",
"!=",
"stkEOF",
"{",
"return",
"false",
"\n",
"}",
"\n",
"d",
".",
"pop",
"(",
")",
"\n",
"return"... | // Undo a pushEOF.
// The element must have been finished, so the EOF should be at the top of the stack. | [
"Undo",
"a",
"pushEOF",
".",
"The",
"element",
"must",
"have",
"been",
"finished",
"so",
"the",
"EOF",
"should",
"be",
"at",
"the",
"top",
"of",
"the",
"stack",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L401-L407 | train |
vmware/govmomi | vim25/xml/xml.go | pushElement | func (d *Decoder) pushElement(name Name) {
s := d.push(stkStart)
s.name = name
} | go | func (d *Decoder) pushElement(name Name) {
s := d.push(stkStart)
s.name = name
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"pushElement",
"(",
"name",
"Name",
")",
"{",
"s",
":=",
"d",
".",
"push",
"(",
"stkStart",
")",
"\n",
"s",
".",
"name",
"=",
"name",
"\n",
"}"
] | // Record that we are starting an element with the given name. | [
"Record",
"that",
"we",
"are",
"starting",
"an",
"element",
"with",
"the",
"given",
"name",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L410-L413 | train |
vmware/govmomi | vim25/xml/xml.go | syntaxError | func (d *Decoder) syntaxError(msg string) error {
return &SyntaxError{Msg: msg, Line: d.line}
} | go | func (d *Decoder) syntaxError(msg string) error {
return &SyntaxError{Msg: msg, Line: d.line}
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"syntaxError",
"(",
"msg",
"string",
")",
"error",
"{",
"return",
"&",
"SyntaxError",
"{",
"Msg",
":",
"msg",
",",
"Line",
":",
"d",
".",
"line",
"}",
"\n",
"}"
] | // Creates a SyntaxError with the current line number. | [
"Creates",
"a",
"SyntaxError",
"with",
"the",
"current",
"line",
"number",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L425-L427 | train |
vmware/govmomi | vim25/xml/xml.go | popElement | func (d *Decoder) popElement(t *EndElement) bool {
s := d.pop()
name := t.Name
switch {
case s == nil || s.kind != stkStart:
d.err = d.syntaxError("unexpected end element </" + name.Local + ">")
return false
case s.name.Local != name.Local:
if !d.Strict {
d.needClose = true
d.toClose = t.Name
t.Name... | go | func (d *Decoder) popElement(t *EndElement) bool {
s := d.pop()
name := t.Name
switch {
case s == nil || s.kind != stkStart:
d.err = d.syntaxError("unexpected end element </" + name.Local + ">")
return false
case s.name.Local != name.Local:
if !d.Strict {
d.needClose = true
d.toClose = t.Name
t.Name... | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"popElement",
"(",
"t",
"*",
"EndElement",
")",
"bool",
"{",
"s",
":=",
"d",
".",
"pop",
"(",
")",
"\n",
"name",
":=",
"t",
".",
"Name",
"\n",
"switch",
"{",
"case",
"s",
"==",
"nil",
"||",
"s",
".",
"ki... | // Record that we are ending an element with the given name.
// The name must match the record at the top of the stack,
// which must be a pushElement record.
// After popping the element, apply any undo records from
// the stack to restore the name translations that existed
// before we saw this element. | [
"Record",
"that",
"we",
"are",
"ending",
"an",
"element",
"with",
"the",
"given",
"name",
".",
"The",
"name",
"must",
"match",
"the",
"record",
"at",
"the",
"top",
"of",
"the",
"stack",
"which",
"must",
"be",
"a",
"pushElement",
"record",
".",
"After",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L435-L469 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.