id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
21,400 | vmware/govmomi | toolbox/process.go | Open | func (m *ProcessManager) Open(u *url.URL, mode int32) (hgfs.File, error) {
info, err := m.Stat(u)
if err != nil {
return nil, err
}
pinfo, ok := info.(*ProcessFile)
if !ok {
return nil, os.ErrNotExist // fall through to default os.Open
}
switch path.Base(u.Path) {
case "stdin":
if mode != hgfs.OpenMode... | go | func (m *ProcessManager) Open(u *url.URL, mode int32) (hgfs.File, error) {
info, err := m.Stat(u)
if err != nil {
return nil, err
}
pinfo, ok := info.(*ProcessFile)
if !ok {
return nil, os.ErrNotExist // fall through to default os.Open
}
switch path.Base(u.Path) {
case "stdin":
if mode != hgfs.OpenMode... | [
"func",
"(",
"m",
"*",
"ProcessManager",
")",
"Open",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"mode",
"int32",
")",
"(",
"hgfs",
".",
"File",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"m",
".",
"Stat",
"(",
"u",
")",
"\n",
"if",
"err",... | // Open implements hgfs.FileHandler.Open | [
"Open",
"implements",
"hgfs",
".",
"FileHandler",
".",
"Open"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/process.go#L427-L451 |
21,401 | vmware/govmomi | toolbox/process.go | NewProcessFunc | func NewProcessFunc(run func(ctx context.Context, args string) error) *Process {
f := &processFunc{run: run}
return &Process{
Start: f.start,
Wait: f.wait,
}
} | go | func NewProcessFunc(run func(ctx context.Context, args string) error) *Process {
f := &processFunc{run: run}
return &Process{
Start: f.start,
Wait: f.wait,
}
} | [
"func",
"NewProcessFunc",
"(",
"run",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"string",
")",
"error",
")",
"*",
"Process",
"{",
"f",
":=",
"&",
"processFunc",
"{",
"run",
":",
"run",
"}",
"\n\n",
"return",
"&",
"Process",
"{",
"St... | // NewProcessFunc creates a new Process, where the Start function calls the given run function within a goroutine.
// The Wait function waits for the goroutine to finish and returns the error returned by run.
// The run ctx param may be used to return early via the ProcessManager.Kill method.
// The run args command is... | [
"NewProcessFunc",
"creates",
"a",
"new",
"Process",
"where",
"the",
"Start",
"function",
"calls",
"the",
"given",
"run",
"function",
"within",
"a",
"goroutine",
".",
"The",
"Wait",
"function",
"waits",
"for",
"the",
"goroutine",
"to",
"finish",
"and",
"returns... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/process.go#L465-L472 |
21,402 | vmware/govmomi | toolbox/process.go | NewProcessRoundTrip | func NewProcessRoundTrip() *Process {
return NewProcessFunc(func(ctx context.Context, host string) error {
p, _ := ctx.Value(ProcessFuncIO).(*ProcessIO)
closers := []io.Closer{p.In.Closer}
defer func() {
for _, c := range closers {
_ = c.Close()
}
}()
c, err := new(net.Dialer).DialContext(ctx, "... | go | func NewProcessRoundTrip() *Process {
return NewProcessFunc(func(ctx context.Context, host string) error {
p, _ := ctx.Value(ProcessFuncIO).(*ProcessIO)
closers := []io.Closer{p.In.Closer}
defer func() {
for _, c := range closers {
_ = c.Close()
}
}()
c, err := new(net.Dialer).DialContext(ctx, "... | [
"func",
"NewProcessRoundTrip",
"(",
")",
"*",
"Process",
"{",
"return",
"NewProcessFunc",
"(",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"host",
"string",
")",
"error",
"{",
"p",
",",
"_",
":=",
"ctx",
".",
"Value",
"(",
"ProcessFuncIO",
")",
... | // NewProcessRoundTrip starts a Go function to implement a toolbox backed http.RoundTripper | [
"NewProcessRoundTrip",
"starts",
"a",
"Go",
"function",
"to",
"implement",
"a",
"toolbox",
"backed",
"http",
".",
"RoundTripper"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/process.go#L593-L631 |
21,403 | vmware/govmomi | vim25/progress/reader.go | Read | func (r *reader) Read(b []byte) (int, error) {
n, err := r.r.Read(b)
r.pos += int64(n)
if err != nil && err != io.EOF {
return n, err
}
q := readerReport{
t: time.Now(),
pos: r.pos,
size: r.size,
bps: &r.bps,
}
select {
case r.ch <- q:
case <-r.ctx.Done():
}
return n, err
} | go | func (r *reader) Read(b []byte) (int, error) {
n, err := r.r.Read(b)
r.pos += int64(n)
if err != nil && err != io.EOF {
return n, err
}
q := readerReport{
t: time.Now(),
pos: r.pos,
size: r.size,
bps: &r.bps,
}
select {
case r.ch <- q:
case <-r.ctx.Done():
}
return n, err
} | [
"func",
"(",
"r",
"*",
"reader",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"r",
".",
"r",
".",
"Read",
"(",
"b",
")",
"\n",
"r",
".",
"pos",
"+=",
"int64",
"(",
"n",
")",
"\... | // Read calls the Read function on the underlying io.Reader. Additionally,
// every read causes a progress report to be sent to the progress reader's
// underlying channel. | [
"Read",
"calls",
"the",
"Read",
"function",
"on",
"the",
"underlying",
"io",
".",
"Reader",
".",
"Additionally",
"every",
"read",
"causes",
"a",
"progress",
"report",
"to",
"be",
"sent",
"to",
"the",
"progress",
"reader",
"s",
"underlying",
"channel",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/progress/reader.go#L101-L122 |
21,404 | vmware/govmomi | vim25/progress/reader.go | Done | func (r *reader) Done(err error) {
q := readerReport{
t: time.Now(),
pos: r.pos,
size: r.size,
bps: &r.bps,
err: err,
}
select {
case r.ch <- q:
close(r.ch)
case <-r.ctx.Done():
}
} | go | func (r *reader) Done(err error) {
q := readerReport{
t: time.Now(),
pos: r.pos,
size: r.size,
bps: &r.bps,
err: err,
}
select {
case r.ch <- q:
close(r.ch)
case <-r.ctx.Done():
}
} | [
"func",
"(",
"r",
"*",
"reader",
")",
"Done",
"(",
"err",
"error",
")",
"{",
"q",
":=",
"readerReport",
"{",
"t",
":",
"time",
".",
"Now",
"(",
")",
",",
"pos",
":",
"r",
".",
"pos",
",",
"size",
":",
"r",
".",
"size",
",",
"bps",
":",
"&",... | // Done marks the progress reader as done, optionally including an error in the
// progress report. After sending it, the underlying channel is closed. | [
"Done",
"marks",
"the",
"progress",
"reader",
"as",
"done",
"optionally",
"including",
"an",
"error",
"in",
"the",
"progress",
"report",
".",
"After",
"sending",
"it",
"the",
"underlying",
"channel",
"is",
"closed",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/progress/reader.go#L126-L140 |
21,405 | vmware/govmomi | vim25/progress/reader.go | newBpsLoop | func newBpsLoop(dst *uint64) SinkFunc {
fn := func() chan<- Report {
sink := make(chan Report)
go bpsLoop(sink, dst)
return sink
}
return fn
} | go | func newBpsLoop(dst *uint64) SinkFunc {
fn := func() chan<- Report {
sink := make(chan Report)
go bpsLoop(sink, dst)
return sink
}
return fn
} | [
"func",
"newBpsLoop",
"(",
"dst",
"*",
"uint64",
")",
"SinkFunc",
"{",
"fn",
":=",
"func",
"(",
")",
"chan",
"<-",
"Report",
"{",
"sink",
":=",
"make",
"(",
"chan",
"Report",
")",
"\n",
"go",
"bpsLoop",
"(",
"sink",
",",
"dst",
")",
"\n",
"return",... | // newBpsLoop returns a sink that monitors and stores throughput. | [
"newBpsLoop",
"returns",
"a",
"sink",
"that",
"monitors",
"and",
"stores",
"throughput",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/progress/reader.go#L143-L151 |
21,406 | vmware/govmomi | vmdk/import.go | stat | func stat(name string) (*info, error) {
f, err := os.Open(filepath.Clean(name))
if err != nil {
return nil, err
}
var di info
var buf bytes.Buffer
_, err = io.CopyN(&buf, f, int64(binary.Size(di.Header)))
if err != nil {
return nil, err
}
fi, err := f.Stat()
if err != nil {
return nil, err
}
err ... | go | func stat(name string) (*info, error) {
f, err := os.Open(filepath.Clean(name))
if err != nil {
return nil, err
}
var di info
var buf bytes.Buffer
_, err = io.CopyN(&buf, f, int64(binary.Size(di.Header)))
if err != nil {
return nil, err
}
fi, err := f.Stat()
if err != nil {
return nil, err
}
err ... | [
"func",
"stat",
"(",
"name",
"string",
")",
"(",
"*",
"info",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filepath",
".",
"Clean",
"(",
"name",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"... | // stat looks at the vmdk header to make sure the format is streamOptimized and
// extracts the disk capacity required to properly generate the ovf descriptor. | [
"stat",
"looks",
"at",
"the",
"vmdk",
"header",
"to",
"make",
"sure",
"the",
"format",
"is",
"streamOptimized",
"and",
"extracts",
"the",
"disk",
"capacity",
"required",
"to",
"properly",
"generate",
"the",
"ovf",
"descriptor",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vmdk/import.go#L61-L108 |
21,407 | vmware/govmomi | vmdk/import.go | ovf | func (di *info) ovf() (string, error) {
var buf bytes.Buffer
tmpl, err := template.New("ovf").Parse(ovfenv)
if err != nil {
return "", err
}
err = tmpl.Execute(&buf, di)
if err != nil {
return "", err
}
return buf.String(), nil
} | go | func (di *info) ovf() (string, error) {
var buf bytes.Buffer
tmpl, err := template.New("ovf").Parse(ovfenv)
if err != nil {
return "", err
}
err = tmpl.Execute(&buf, di)
if err != nil {
return "", err
}
return buf.String(), nil
} | [
"func",
"(",
"di",
"*",
"info",
")",
"ovf",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n\n",
"tmpl",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"",
"\"",
")",
".",
"Parse",
"(",
"ovfenv",
")",... | // ovf returns an expanded descriptor template | [
"ovf",
"returns",
"an",
"expanded",
"descriptor",
"template"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vmdk/import.go#L178-L192 |
21,408 | vmware/govmomi | examples/examples.go | getEnvString | func getEnvString(v string, def string) string {
r := os.Getenv(v)
if r == "" {
return def
}
return r
} | go | func getEnvString(v string, def string) string {
r := os.Getenv(v)
if r == "" {
return def
}
return r
} | [
"func",
"getEnvString",
"(",
"v",
"string",
",",
"def",
"string",
")",
"string",
"{",
"r",
":=",
"os",
".",
"Getenv",
"(",
"v",
")",
"\n",
"if",
"r",
"==",
"\"",
"\"",
"{",
"return",
"def",
"\n",
"}",
"\n\n",
"return",
"r",
"\n",
"}"
] | // getEnvString returns string from environment variable. | [
"getEnvString",
"returns",
"string",
"from",
"environment",
"variable",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/examples/examples.go#L33-L40 |
21,409 | vmware/govmomi | examples/examples.go | getEnvBool | func getEnvBool(v string, def bool) bool {
r := os.Getenv(v)
if r == "" {
return def
}
switch strings.ToLower(r[0:1]) {
case "t", "y", "1":
return true
}
return false
} | go | func getEnvBool(v string, def bool) bool {
r := os.Getenv(v)
if r == "" {
return def
}
switch strings.ToLower(r[0:1]) {
case "t", "y", "1":
return true
}
return false
} | [
"func",
"getEnvBool",
"(",
"v",
"string",
",",
"def",
"bool",
")",
"bool",
"{",
"r",
":=",
"os",
".",
"Getenv",
"(",
"v",
")",
"\n",
"if",
"r",
"==",
"\"",
"\"",
"{",
"return",
"def",
"\n",
"}",
"\n\n",
"switch",
"strings",
".",
"ToLower",
"(",
... | // getEnvBool returns boolean from environment variable. | [
"getEnvBool",
"returns",
"boolean",
"from",
"environment",
"variable",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/examples/examples.go#L43-L55 |
21,410 | vmware/govmomi | examples/examples.go | NewClient | func NewClient(ctx context.Context) (*govmomi.Client, error) {
flag.Parse()
// Parse URL from string
u, err := soap.ParseURL(*urlFlag)
if err != nil {
return nil, err
}
// Override username and/or password as required
processOverride(u)
// Connect and log in to ESX or vCenter
return govmomi.NewClient(ctx,... | go | func NewClient(ctx context.Context) (*govmomi.Client, error) {
flag.Parse()
// Parse URL from string
u, err := soap.ParseURL(*urlFlag)
if err != nil {
return nil, err
}
// Override username and/or password as required
processOverride(u)
// Connect and log in to ESX or vCenter
return govmomi.NewClient(ctx,... | [
"func",
"NewClient",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"govmomi",
".",
"Client",
",",
"error",
")",
"{",
"flag",
".",
"Parse",
"(",
")",
"\n\n",
"// Parse URL from string",
"u",
",",
"err",
":=",
"soap",
".",
"ParseURL",
"(",
"*",
... | // NewClient creates a govmomi.Client for use in the examples | [
"NewClient",
"creates",
"a",
"govmomi",
".",
"Client",
"for",
"use",
"in",
"the",
"examples"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/examples/examples.go#L103-L117 |
21,411 | vmware/govmomi | task/wait.go | Wait | func Wait(ctx context.Context, ref types.ManagedObjectReference, pc *property.Collector, s progress.Sinker) (*types.TaskInfo, error) {
cb := &taskCallback{}
// Include progress sink if specified
if s != nil {
cb.ch = s.Sink()
defer close(cb.ch)
}
err := property.Wait(ctx, pc, ref, []string{"info"}, cb.fn)
i... | go | func Wait(ctx context.Context, ref types.ManagedObjectReference, pc *property.Collector, s progress.Sinker) (*types.TaskInfo, error) {
cb := &taskCallback{}
// Include progress sink if specified
if s != nil {
cb.ch = s.Sink()
defer close(cb.ch)
}
err := property.Wait(ctx, pc, ref, []string{"info"}, cb.fn)
i... | [
"func",
"Wait",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"types",
".",
"ManagedObjectReference",
",",
"pc",
"*",
"property",
".",
"Collector",
",",
"s",
"progress",
".",
"Sinker",
")",
"(",
"*",
"types",
".",
"TaskInfo",
",",
"error",
")",
"{... | // Wait waits for a task to finish with either success or failure. It does so
// by waiting for the "info" property of task managed object to change. The
// function returns when it finds the task in the "success" or "error" state.
// In the former case, the return value is nil. In the latter case the return
// value i... | [
"Wait",
"waits",
"for",
"a",
"task",
"to",
"finish",
"with",
"either",
"success",
"or",
"failure",
".",
"It",
"does",
"so",
"by",
"waiting",
"for",
"the",
"info",
"property",
"of",
"task",
"managed",
"object",
"to",
"change",
".",
"The",
"function",
"ret... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/task/wait.go#L117-L132 |
21,412 | vmware/govmomi | object/datastore_file.go | Open | func (d Datastore) Open(ctx context.Context, name string) (*DatastoreFile, error) {
return &DatastoreFile{
d: d,
name: name,
length: -1,
ctx: ctx,
}, nil
} | go | func (d Datastore) Open(ctx context.Context, name string) (*DatastoreFile, error) {
return &DatastoreFile{
d: d,
name: name,
length: -1,
ctx: ctx,
}, nil
} | [
"func",
"(",
"d",
"Datastore",
")",
"Open",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"*",
"DatastoreFile",
",",
"error",
")",
"{",
"return",
"&",
"DatastoreFile",
"{",
"d",
":",
"d",
",",
"name",
":",
"name",
",",
"le... | // Open opens the named file relative to the Datastore. | [
"Open",
"opens",
"the",
"named",
"file",
"relative",
"to",
"the",
"Datastore",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L49-L56 |
21,413 | vmware/govmomi | object/datastore_file.go | Close | func (f *DatastoreFile) Close() error {
var err error
if f.body != nil {
err = f.body.Close()
f.body = nil
}
f.buf = nil
return err
} | go | func (f *DatastoreFile) Close() error {
var err error
if f.body != nil {
err = f.body.Close()
f.body = nil
}
f.buf = nil
return err
} | [
"func",
"(",
"f",
"*",
"DatastoreFile",
")",
"Close",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"if",
"f",
".",
"body",
"!=",
"nil",
"{",
"err",
"=",
"f",
".",
"body",
".",
"Close",
"(",
")",
"\n",
"f",
".",
"body",
"=",
"nil",
"... | // Close closes the DatastoreFile. | [
"Close",
"closes",
"the",
"DatastoreFile",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L90-L101 |
21,414 | vmware/govmomi | object/datastore_file.go | Seek | func (f *DatastoreFile) Seek(offset int64, whence int) (int64, error) {
switch whence {
case io.SeekStart:
case io.SeekCurrent:
offset += f.offset.seek
case io.SeekEnd:
if f.length < 0 {
_, err := f.Stat()
if err != nil {
return 0, err
}
}
offset += f.length
default:
return 0, errors.New("Se... | go | func (f *DatastoreFile) Seek(offset int64, whence int) (int64, error) {
switch whence {
case io.SeekStart:
case io.SeekCurrent:
offset += f.offset.seek
case io.SeekEnd:
if f.length < 0 {
_, err := f.Stat()
if err != nil {
return 0, err
}
}
offset += f.length
default:
return 0, errors.New("Se... | [
"func",
"(",
"f",
"*",
"DatastoreFile",
")",
"Seek",
"(",
"offset",
"int64",
",",
"whence",
"int",
")",
"(",
"int64",
",",
"error",
")",
"{",
"switch",
"whence",
"{",
"case",
"io",
".",
"SeekStart",
":",
"case",
"io",
".",
"SeekCurrent",
":",
"offset... | // Seek sets the offset for the next Read on the DatastoreFile. | [
"Seek",
"sets",
"the",
"offset",
"for",
"the",
"next",
"Read",
"on",
"the",
"DatastoreFile",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L104-L129 |
21,415 | vmware/govmomi | object/datastore_file.go | Stat | func (f *DatastoreFile) Stat() (os.FileInfo, error) {
// TODO: consider using Datastore.Stat() instead
u, p, err := f.d.downloadTicket(f.ctx, f.name, &soap.Download{Method: "HEAD"})
if err != nil {
return nil, err
}
res, err := f.d.Client().DownloadRequest(f.ctx, u, p)
if err != nil {
return nil, err
}
if... | go | func (f *DatastoreFile) Stat() (os.FileInfo, error) {
// TODO: consider using Datastore.Stat() instead
u, p, err := f.d.downloadTicket(f.ctx, f.name, &soap.Download{Method: "HEAD"})
if err != nil {
return nil, err
}
res, err := f.d.Client().DownloadRequest(f.ctx, u, p)
if err != nil {
return nil, err
}
if... | [
"func",
"(",
"f",
"*",
"DatastoreFile",
")",
"Stat",
"(",
")",
"(",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"// TODO: consider using Datastore.Stat() instead",
"u",
",",
"p",
",",
"err",
":=",
"f",
".",
"d",
".",
"downloadTicket",
"(",
"f",
".",
... | // Stat returns the os.FileInfo interface describing file. | [
"Stat",
"returns",
"the",
"os",
".",
"FileInfo",
"interface",
"describing",
"file",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L168-L187 |
21,416 | vmware/govmomi | object/datastore_file.go | Tail | func (f *DatastoreFile) Tail(n int) error {
return f.TailFunc(n, func(line int, _ string) bool { return n > line })
} | go | func (f *DatastoreFile) Tail(n int) error {
return f.TailFunc(n, func(line int, _ string) bool { return n > line })
} | [
"func",
"(",
"f",
"*",
"DatastoreFile",
")",
"Tail",
"(",
"n",
"int",
")",
"error",
"{",
"return",
"f",
".",
"TailFunc",
"(",
"n",
",",
"func",
"(",
"line",
"int",
",",
"_",
"string",
")",
"bool",
"{",
"return",
"n",
">",
"line",
"}",
")",
"\n"... | // Tail seeks to the position of the last N lines of the file. | [
"Tail",
"seeks",
"to",
"the",
"position",
"of",
"the",
"last",
"N",
"lines",
"of",
"the",
"file",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L260-L262 |
21,417 | vmware/govmomi | object/datastore_file.go | TailFunc | func (f *DatastoreFile) TailFunc(lines int, include func(line int, message string) bool) error {
// Read the file in reverse using bsize chunks
const bsize = int64(1024 * 16)
fsize, err := f.Seek(0, io.SeekEnd)
if err != nil {
return err
}
if lines == 0 {
return nil
}
chunk := int64(-1)
buf := bytes.Ne... | go | func (f *DatastoreFile) TailFunc(lines int, include func(line int, message string) bool) error {
// Read the file in reverse using bsize chunks
const bsize = int64(1024 * 16)
fsize, err := f.Seek(0, io.SeekEnd)
if err != nil {
return err
}
if lines == 0 {
return nil
}
chunk := int64(-1)
buf := bytes.Ne... | [
"func",
"(",
"f",
"*",
"DatastoreFile",
")",
"TailFunc",
"(",
"lines",
"int",
",",
"include",
"func",
"(",
"line",
"int",
",",
"message",
"string",
")",
"bool",
")",
"error",
"{",
"// Read the file in reverse using bsize chunks",
"const",
"bsize",
"=",
"int64"... | // TailFunc will seek backwards in the datastore file until it hits a line that does
// not satisfy the supplied `include` function. | [
"TailFunc",
"will",
"seek",
"backwards",
"in",
"the",
"datastore",
"file",
"until",
"it",
"hits",
"a",
"line",
"that",
"does",
"not",
"satisfy",
"the",
"supplied",
"include",
"function",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L266-L343 |
21,418 | vmware/govmomi | object/datastore_file.go | Close | func (f *followDatastoreFile) Close() error {
f.o.Do(func() { close(f.c) })
return nil
} | go | func (f *followDatastoreFile) Close() error {
f.o.Do(func() { close(f.c) })
return nil
} | [
"func",
"(",
"f",
"*",
"followDatastoreFile",
")",
"Close",
"(",
")",
"error",
"{",
"f",
".",
"o",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"f",
".",
"c",
")",
"}",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Close will stop Follow polling and close the underlying DatastoreFile. | [
"Close",
"will",
"stop",
"Follow",
"polling",
"and",
"close",
"the",
"underlying",
"DatastoreFile",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L400-L403 |
21,419 | vmware/govmomi | object/datastore_file.go | Follow | func (f *DatastoreFile) Follow(interval time.Duration) io.ReadCloser {
return &followDatastoreFile{
r: f,
c: make(chan struct{}),
i: interval,
}
} | go | func (f *DatastoreFile) Follow(interval time.Duration) io.ReadCloser {
return &followDatastoreFile{
r: f,
c: make(chan struct{}),
i: interval,
}
} | [
"func",
"(",
"f",
"*",
"DatastoreFile",
")",
"Follow",
"(",
"interval",
"time",
".",
"Duration",
")",
"io",
".",
"ReadCloser",
"{",
"return",
"&",
"followDatastoreFile",
"{",
"r",
":",
"f",
",",
"c",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",... | // Follow returns an io.ReadCloser to stream the file contents as data is appended. | [
"Follow",
"returns",
"an",
"io",
".",
"ReadCloser",
"to",
"stream",
"the",
"file",
"contents",
"as",
"data",
"is",
"appended",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/datastore_file.go#L406-L412 |
21,420 | vmware/govmomi | object/host_certificate_info.go | FromCertificate | func (info *HostCertificateInfo) FromCertificate(cert *x509.Certificate) *HostCertificateInfo {
info.Certificate = cert
info.subjectName = &cert.Subject
info.issuerName = &cert.Issuer
info.Issuer = info.fromName(info.issuerName)
info.NotBefore = &cert.NotBefore
info.NotAfter = &cert.NotAfter
info.Subject = info... | go | func (info *HostCertificateInfo) FromCertificate(cert *x509.Certificate) *HostCertificateInfo {
info.Certificate = cert
info.subjectName = &cert.Subject
info.issuerName = &cert.Issuer
info.Issuer = info.fromName(info.issuerName)
info.NotBefore = &cert.NotBefore
info.NotAfter = &cert.NotAfter
info.Subject = info... | [
"func",
"(",
"info",
"*",
"HostCertificateInfo",
")",
"FromCertificate",
"(",
"cert",
"*",
"x509",
".",
"Certificate",
")",
"*",
"HostCertificateInfo",
"{",
"info",
".",
"Certificate",
"=",
"cert",
"\n",
"info",
".",
"subjectName",
"=",
"&",
"cert",
".",
"... | // FromCertificate converts x509.Certificate to HostCertificateInfo | [
"FromCertificate",
"converts",
"x509",
".",
"Certificate",
"to",
"HostCertificateInfo"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_certificate_info.go#L50-L75 |
21,421 | vmware/govmomi | object/host_certificate_info.go | FromURL | func (info *HostCertificateInfo) FromURL(u *url.URL, config *tls.Config) error {
addr := u.Host
if !(strings.LastIndex(addr, ":") > strings.LastIndex(addr, "]")) {
addr += ":443"
}
conn, err := tls.Dial("tcp", addr, config)
if err != nil {
switch err.(type) {
case x509.UnknownAuthorityError:
case x509.Hos... | go | func (info *HostCertificateInfo) FromURL(u *url.URL, config *tls.Config) error {
addr := u.Host
if !(strings.LastIndex(addr, ":") > strings.LastIndex(addr, "]")) {
addr += ":443"
}
conn, err := tls.Dial("tcp", addr, config)
if err != nil {
switch err.(type) {
case x509.UnknownAuthorityError:
case x509.Hos... | [
"func",
"(",
"info",
"*",
"HostCertificateInfo",
")",
"FromURL",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"config",
"*",
"tls",
".",
"Config",
")",
"error",
"{",
"addr",
":=",
"u",
".",
"Host",
"\n",
"if",
"!",
"(",
"strings",
".",
"LastIndex",
"(",
... | // FromURL connects to the given URL.Host via tls.Dial with the given tls.Config and populates the HostCertificateInfo
// via tls.ConnectionState. If the certificate was verified with the given tls.Config, the Err field will be nil.
// Otherwise, Err will be set to the x509.UnknownAuthorityError or x509.HostnameError.... | [
"FromURL",
"connects",
"to",
"the",
"given",
"URL",
".",
"Host",
"via",
"tls",
".",
"Dial",
"with",
"the",
"given",
"tls",
".",
"Config",
"and",
"populates",
"the",
"HostCertificateInfo",
"via",
"tls",
".",
"ConnectionState",
".",
"If",
"the",
"certificate",... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_certificate_info.go#L81-L111 |
21,422 | vmware/govmomi | object/host_certificate_info.go | SubjectName | func (info *HostCertificateInfo) SubjectName() *pkix.Name {
if info.subjectName != nil {
return info.subjectName
}
return info.toName(info.Subject)
} | go | func (info *HostCertificateInfo) SubjectName() *pkix.Name {
if info.subjectName != nil {
return info.subjectName
}
return info.toName(info.Subject)
} | [
"func",
"(",
"info",
"*",
"HostCertificateInfo",
")",
"SubjectName",
"(",
")",
"*",
"pkix",
".",
"Name",
"{",
"if",
"info",
".",
"subjectName",
"!=",
"nil",
"{",
"return",
"info",
".",
"subjectName",
"\n",
"}",
"\n\n",
"return",
"info",
".",
"toName",
... | // SubjectName parses Subject into a pkix.Name | [
"SubjectName",
"parses",
"Subject",
"into",
"a",
"pkix",
".",
"Name"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_certificate_info.go#L187-L193 |
21,423 | vmware/govmomi | object/host_certificate_info.go | IssuerName | func (info *HostCertificateInfo) IssuerName() *pkix.Name {
if info.issuerName != nil {
return info.issuerName
}
return info.toName(info.Issuer)
} | go | func (info *HostCertificateInfo) IssuerName() *pkix.Name {
if info.issuerName != nil {
return info.issuerName
}
return info.toName(info.Issuer)
} | [
"func",
"(",
"info",
"*",
"HostCertificateInfo",
")",
"IssuerName",
"(",
")",
"*",
"pkix",
".",
"Name",
"{",
"if",
"info",
".",
"issuerName",
"!=",
"nil",
"{",
"return",
"info",
".",
"issuerName",
"\n",
"}",
"\n\n",
"return",
"info",
".",
"toName",
"("... | // IssuerName parses Issuer into a pkix.Name | [
"IssuerName",
"parses",
"Issuer",
"into",
"a",
"pkix",
".",
"Name"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_certificate_info.go#L196-L202 |
21,424 | vmware/govmomi | object/host_certificate_info.go | Write | func (info *HostCertificateInfo) Write(w io.Writer) error {
tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)
s := func(val string) string {
if val != "" {
return val
}
return "<Not Part Of Certificate>"
}
ss := func(val []string) string {
return s(strings.Join(val, ","))
}
name := func(n *pkix.Name) {
... | go | func (info *HostCertificateInfo) Write(w io.Writer) error {
tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)
s := func(val string) string {
if val != "" {
return val
}
return "<Not Part Of Certificate>"
}
ss := func(val []string) string {
return s(strings.Join(val, ","))
}
name := func(n *pkix.Name) {
... | [
"func",
"(",
"info",
"*",
"HostCertificateInfo",
")",
"Write",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"tw",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"w",
",",
"2",
",",
"0",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n\n",
"s",
":=",
"f... | // Write outputs info similar to the Chrome Certificate Viewer. | [
"Write",
"outputs",
"info",
"similar",
"to",
"the",
"Chrome",
"Certificate",
"Viewer",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_certificate_info.go#L205-L250 |
21,425 | vmware/govmomi | toolbox/hgfs/encoding.go | MarshalBinary | func MarshalBinary(fields ...interface{}) ([]byte, error) {
buf := new(bytes.Buffer)
for _, p := range fields {
switch m := p.(type) {
case encoding.BinaryMarshaler:
data, err := m.MarshalBinary()
if err != nil {
return nil, ProtocolError(err)
}
_, _ = buf.Write(data)
case []byte:
_, _ = bu... | go | func MarshalBinary(fields ...interface{}) ([]byte, error) {
buf := new(bytes.Buffer)
for _, p := range fields {
switch m := p.(type) {
case encoding.BinaryMarshaler:
data, err := m.MarshalBinary()
if err != nil {
return nil, ProtocolError(err)
}
_, _ = buf.Write(data)
case []byte:
_, _ = bu... | [
"func",
"MarshalBinary",
"(",
"fields",
"...",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n\n",
"for",
"_",
",",
"p",
":=",
"range",
"fields",
"{",
"switch",
... | // MarshalBinary is a wrapper around binary.Write | [
"MarshalBinary",
"is",
"a",
"wrapper",
"around",
"binary",
".",
"Write"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/encoding.go#L26-L51 |
21,426 | vmware/govmomi | toolbox/hgfs/encoding.go | UnmarshalBinary | func UnmarshalBinary(data []byte, fields ...interface{}) error {
buf := bytes.NewBuffer(data)
for _, p := range fields {
switch m := p.(type) {
case encoding.BinaryUnmarshaler:
return m.UnmarshalBinary(buf.Bytes())
case *[]byte:
*m = buf.Bytes()
return nil
default:
err := binary.Read(buf, binary.... | go | func UnmarshalBinary(data []byte, fields ...interface{}) error {
buf := bytes.NewBuffer(data)
for _, p := range fields {
switch m := p.(type) {
case encoding.BinaryUnmarshaler:
return m.UnmarshalBinary(buf.Bytes())
case *[]byte:
*m = buf.Bytes()
return nil
default:
err := binary.Read(buf, binary.... | [
"func",
"UnmarshalBinary",
"(",
"data",
"[",
"]",
"byte",
",",
"fields",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"data",
")",
"\n\n",
"for",
"_",
",",
"p",
":=",
"range",
"fields",
"{",
"switch",
... | // UnmarshalBinary is a wrapper around binary.Read | [
"UnmarshalBinary",
"is",
"a",
"wrapper",
"around",
"binary",
".",
"Read"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/encoding.go#L54-L73 |
21,427 | vmware/govmomi | ssoadmin/methods/role.go | C14N | func (b *LoginBody) C14N() string {
req, err := xml.Marshal(b.Req)
if err != nil {
panic(err)
}
return string(req)
} | go | func (b *LoginBody) C14N() string {
req, err := xml.Marshal(b.Req)
if err != nil {
panic(err)
}
return string(req)
} | [
"func",
"(",
"b",
"*",
"LoginBody",
")",
"C14N",
"(",
")",
"string",
"{",
"req",
",",
"err",
":=",
"xml",
".",
"Marshal",
"(",
"b",
".",
"Req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"st... | // C14N returns the canonicalized form of LoginBody.Req, for use by sts.Signer | [
"C14N",
"returns",
"the",
"canonicalized",
"form",
"of",
"LoginBody",
".",
"Req",
"for",
"use",
"by",
"sts",
".",
"Signer"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/ssoadmin/methods/role.go#L70-L76 |
21,428 | vmware/govmomi | simulator/model.go | ESX | func ESX() *Model {
return &Model{
ServiceContent: esx.ServiceContent,
RootFolder: esx.RootFolder,
Autostart: true,
Datastore: 1,
Machine: 2,
DelayConfig: DelayConfig{
Delay: 0,
DelayJitter: 0,
MethodDelay: nil,
},
}
} | go | func ESX() *Model {
return &Model{
ServiceContent: esx.ServiceContent,
RootFolder: esx.RootFolder,
Autostart: true,
Datastore: 1,
Machine: 2,
DelayConfig: DelayConfig{
Delay: 0,
DelayJitter: 0,
MethodDelay: nil,
},
}
} | [
"func",
"ESX",
"(",
")",
"*",
"Model",
"{",
"return",
"&",
"Model",
"{",
"ServiceContent",
":",
"esx",
".",
"ServiceContent",
",",
"RootFolder",
":",
"esx",
".",
"RootFolder",
",",
"Autostart",
":",
"true",
",",
"Datastore",
":",
"1",
",",
"Machine",
"... | // ESX is the default Model for a standalone ESX instance | [
"ESX",
"is",
"the",
"default",
"Model",
"for",
"a",
"standalone",
"ESX",
"instance"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/model.go#L107-L120 |
21,429 | vmware/govmomi | simulator/model.go | VPX | func VPX() *Model {
return &Model{
ServiceContent: vpx.ServiceContent,
RootFolder: vpx.RootFolder,
Autostart: true,
Datacenter: 1,
Portgroup: 1,
Host: 1,
Cluster: 1,
ClusterHost: 3,
Datastore: 1,
Machine: 2,
DelayConfig: DelayConfig{
Delay: ... | go | func VPX() *Model {
return &Model{
ServiceContent: vpx.ServiceContent,
RootFolder: vpx.RootFolder,
Autostart: true,
Datacenter: 1,
Portgroup: 1,
Host: 1,
Cluster: 1,
ClusterHost: 3,
Datastore: 1,
Machine: 2,
DelayConfig: DelayConfig{
Delay: ... | [
"func",
"VPX",
"(",
")",
"*",
"Model",
"{",
"return",
"&",
"Model",
"{",
"ServiceContent",
":",
"vpx",
".",
"ServiceContent",
",",
"RootFolder",
":",
"vpx",
".",
"RootFolder",
",",
"Autostart",
":",
"true",
",",
"Datacenter",
":",
"1",
",",
"Portgroup",
... | // VPX is the default Model for a vCenter instance | [
"VPX",
"is",
"the",
"default",
"Model",
"for",
"a",
"vCenter",
"instance"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/model.go#L123-L141 |
21,430 | vmware/govmomi | simulator/model.go | Count | func (m *Model) Count() Model {
count := Model{}
for ref, obj := range Map.objects {
if _, ok := obj.(mo.Entity); !ok {
continue
}
count.total++
switch ref.Type {
case "Datacenter":
count.Datacenter++
case "DistributedVirtualPortgroup":
count.Portgroup++
case "ClusterComputeResource":
cou... | go | func (m *Model) Count() Model {
count := Model{}
for ref, obj := range Map.objects {
if _, ok := obj.(mo.Entity); !ok {
continue
}
count.total++
switch ref.Type {
case "Datacenter":
count.Datacenter++
case "DistributedVirtualPortgroup":
count.Portgroup++
case "ClusterComputeResource":
cou... | [
"func",
"(",
"m",
"*",
"Model",
")",
"Count",
"(",
")",
"Model",
"{",
"count",
":=",
"Model",
"{",
"}",
"\n\n",
"for",
"ref",
",",
"obj",
":=",
"range",
"Map",
".",
"objects",
"{",
"if",
"_",
",",
"ok",
":=",
"obj",
".",
"(",
"mo",
".",
"Enti... | // Count returns a Model with total number of each existing type | [
"Count",
"returns",
"a",
"Model",
"with",
"total",
"number",
"of",
"each",
"existing",
"type"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/model.go#L144-L179 |
21,431 | vmware/govmomi | simulator/model.go | Remove | func (m *Model) Remove() {
for _, dir := range m.dirs {
_ = os.RemoveAll(dir)
}
} | go | func (m *Model) Remove() {
for _, dir := range m.dirs {
_ = os.RemoveAll(dir)
}
} | [
"func",
"(",
"m",
"*",
"Model",
")",
"Remove",
"(",
")",
"{",
"for",
"_",
",",
"dir",
":=",
"range",
"m",
".",
"dirs",
"{",
"_",
"=",
"os",
".",
"RemoveAll",
"(",
"dir",
")",
"\n",
"}",
"\n",
"}"
] | // Remove cleans up items created by the Model, such as local datastore directories | [
"Remove",
"cleans",
"up",
"items",
"created",
"by",
"the",
"Model",
"such",
"as",
"local",
"datastore",
"directories"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/model.go#L516-L520 |
21,432 | vmware/govmomi | govc/host/autostart/autostart.go | VirtualMachines | func (f *AutostartFlag) VirtualMachines(args []string) ([]*object.VirtualMachine, error) {
ctx := context.TODO()
if len(args) == 0 {
return nil, errors.New("no argument")
}
finder, err := f.Finder()
if err != nil {
return nil, err
}
var out []*object.VirtualMachine
for _, arg := range args {
vms, err :=... | go | func (f *AutostartFlag) VirtualMachines(args []string) ([]*object.VirtualMachine, error) {
ctx := context.TODO()
if len(args) == 0 {
return nil, errors.New("no argument")
}
finder, err := f.Finder()
if err != nil {
return nil, err
}
var out []*object.VirtualMachine
for _, arg := range args {
vms, err :=... | [
"func",
"(",
"f",
"*",
"AutostartFlag",
")",
"VirtualMachines",
"(",
"args",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"object",
".",
"VirtualMachine",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n",
"if",
"len",
"("... | // VirtualMachines returns list of virtual machine objects based on the
// arguments specified on the command line. This helper is defined in
// flags.SearchFlag as well, but that pulls in other virtual machine flags that
// are not relevant here. | [
"VirtualMachines",
"returns",
"list",
"of",
"virtual",
"machine",
"objects",
"based",
"on",
"the",
"arguments",
"specified",
"on",
"the",
"command",
"line",
".",
"This",
"helper",
"is",
"defined",
"in",
"flags",
".",
"SearchFlag",
"as",
"well",
"but",
"that",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/host/autostart/autostart.go#L68-L90 |
21,433 | vmware/govmomi | vim25/retry.go | Retry | func Retry(roundTripper soap.RoundTripper, fn RetryFunc) soap.RoundTripper {
r := &retry{
roundTripper: roundTripper,
fn: fn,
}
return r
} | go | func Retry(roundTripper soap.RoundTripper, fn RetryFunc) soap.RoundTripper {
r := &retry{
roundTripper: roundTripper,
fn: fn,
}
return r
} | [
"func",
"Retry",
"(",
"roundTripper",
"soap",
".",
"RoundTripper",
",",
"fn",
"RetryFunc",
")",
"soap",
".",
"RoundTripper",
"{",
"r",
":=",
"&",
"retry",
"{",
"roundTripper",
":",
"roundTripper",
",",
"fn",
":",
"fn",
",",
"}",
"\n\n",
"return",
"r",
... | // Retry wraps the specified soap.RoundTripper and invokes the
// specified RetryFunc. The RetryFunc returns whether or not to
// retry the call, and if so, how long to wait before retrying. If
// the result of this function is to not retry, the original error
// is returned from the RoundTrip function. | [
"Retry",
"wraps",
"the",
"specified",
"soap",
".",
"RoundTripper",
"and",
"invokes",
"the",
"specified",
"RetryFunc",
".",
"The",
"RetryFunc",
"returns",
"whether",
"or",
"not",
"to",
"retry",
"the",
"call",
"and",
"if",
"so",
"how",
"long",
"to",
"wait",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/retry.go#L77-L84 |
21,434 | vmware/govmomi | object/custom_fields_manager.go | GetCustomFieldsManager | func GetCustomFieldsManager(c *vim25.Client) (*CustomFieldsManager, error) {
if c.ServiceContent.CustomFieldsManager == nil {
return nil, ErrNotSupported
}
return NewCustomFieldsManager(c), nil
} | go | func GetCustomFieldsManager(c *vim25.Client) (*CustomFieldsManager, error) {
if c.ServiceContent.CustomFieldsManager == nil {
return nil, ErrNotSupported
}
return NewCustomFieldsManager(c), nil
} | [
"func",
"GetCustomFieldsManager",
"(",
"c",
"*",
"vim25",
".",
"Client",
")",
"(",
"*",
"CustomFieldsManager",
",",
"error",
")",
"{",
"if",
"c",
".",
"ServiceContent",
".",
"CustomFieldsManager",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrNotSupported",
"\... | // GetCustomFieldsManager wraps NewCustomFieldsManager, returning ErrNotSupported
// when the client is not connected to a vCenter instance. | [
"GetCustomFieldsManager",
"wraps",
"NewCustomFieldsManager",
"returning",
"ErrNotSupported",
"when",
"the",
"client",
"is",
"not",
"connected",
"to",
"a",
"vCenter",
"instance",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/custom_fields_manager.go#L40-L45 |
21,435 | vmware/govmomi | object/diagnostic_log.go | Seek | func (l *DiagnosticLog) Seek(ctx context.Context, nlines int32) error {
h, err := l.m.BrowseLog(ctx, l.Host, l.Key, math.MaxInt32, 0)
if err != nil {
return err
}
l.Start = h.LineEnd - nlines
return nil
} | go | func (l *DiagnosticLog) Seek(ctx context.Context, nlines int32) error {
h, err := l.m.BrowseLog(ctx, l.Host, l.Key, math.MaxInt32, 0)
if err != nil {
return err
}
l.Start = h.LineEnd - nlines
return nil
} | [
"func",
"(",
"l",
"*",
"DiagnosticLog",
")",
"Seek",
"(",
"ctx",
"context",
".",
"Context",
",",
"nlines",
"int32",
")",
"error",
"{",
"h",
",",
"err",
":=",
"l",
".",
"m",
".",
"BrowseLog",
"(",
"ctx",
",",
"l",
".",
"Host",
",",
"l",
".",
"Ke... | // Seek to log position starting at the last nlines of the log | [
"Seek",
"to",
"log",
"position",
"starting",
"at",
"the",
"last",
"nlines",
"of",
"the",
"log"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/diagnostic_log.go#L37-L46 |
21,436 | vmware/govmomi | object/diagnostic_log.go | Copy | func (l *DiagnosticLog) Copy(ctx context.Context, w io.Writer) (int, error) {
const max = 500 // VC max == 500, ESX max == 1000
written := 0
for {
h, err := l.m.BrowseLog(ctx, l.Host, l.Key, l.Start, max)
if err != nil {
return 0, err
}
for _, line := range h.LineText {
n, err := fmt.Fprintln(w, line... | go | func (l *DiagnosticLog) Copy(ctx context.Context, w io.Writer) (int, error) {
const max = 500 // VC max == 500, ESX max == 1000
written := 0
for {
h, err := l.m.BrowseLog(ctx, l.Host, l.Key, l.Start, max)
if err != nil {
return 0, err
}
for _, line := range h.LineText {
n, err := fmt.Fprintln(w, line... | [
"func",
"(",
"l",
"*",
"DiagnosticLog",
")",
"Copy",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"io",
".",
"Writer",
")",
"(",
"int",
",",
"error",
")",
"{",
"const",
"max",
"=",
"500",
"// VC max == 500, ESX max == 1000",
"\n",
"written",
":=",
... | // Copy log starting from l.Start to the given io.Writer
// Returns on error or when end of log is reached. | [
"Copy",
"log",
"starting",
"from",
"l",
".",
"Start",
"to",
"the",
"given",
"io",
".",
"Writer",
"Returns",
"on",
"error",
"or",
"when",
"end",
"of",
"log",
"is",
"reached",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/diagnostic_log.go#L50-L76 |
21,437 | vmware/govmomi | object/search_index.go | FindByDatastorePath | func (s SearchIndex) FindByDatastorePath(ctx context.Context, dc *Datacenter, path string) (Reference, error) {
req := types.FindByDatastorePath{
This: s.Reference(),
Datacenter: dc.Reference(),
Path: path,
}
res, err := methods.FindByDatastorePath(ctx, s.c, &req)
if err != nil {
return nil, er... | go | func (s SearchIndex) FindByDatastorePath(ctx context.Context, dc *Datacenter, path string) (Reference, error) {
req := types.FindByDatastorePath{
This: s.Reference(),
Datacenter: dc.Reference(),
Path: path,
}
res, err := methods.FindByDatastorePath(ctx, s.c, &req)
if err != nil {
return nil, er... | [
"func",
"(",
"s",
"SearchIndex",
")",
"FindByDatastorePath",
"(",
"ctx",
"context",
".",
"Context",
",",
"dc",
"*",
"Datacenter",
",",
"path",
"string",
")",
"(",
"Reference",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
"FindByDatastorePath",
"{",
... | // FindByDatastorePath finds a virtual machine by its location on a datastore. | [
"FindByDatastorePath",
"finds",
"a",
"virtual",
"machine",
"by",
"its",
"location",
"on",
"a",
"datastore",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/search_index.go#L40-L56 |
21,438 | vmware/govmomi | object/search_index.go | FindByDnsName | func (s SearchIndex) FindByDnsName(ctx context.Context, dc *Datacenter, dnsName string, vmSearch bool) (Reference, error) {
req := types.FindByDnsName{
This: s.Reference(),
DnsName: dnsName,
VmSearch: vmSearch,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.FindB... | go | func (s SearchIndex) FindByDnsName(ctx context.Context, dc *Datacenter, dnsName string, vmSearch bool) (Reference, error) {
req := types.FindByDnsName{
This: s.Reference(),
DnsName: dnsName,
VmSearch: vmSearch,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.FindB... | [
"func",
"(",
"s",
"SearchIndex",
")",
"FindByDnsName",
"(",
"ctx",
"context",
".",
"Context",
",",
"dc",
"*",
"Datacenter",
",",
"dnsName",
"string",
",",
"vmSearch",
"bool",
")",
"(",
"Reference",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
"Fi... | // FindByDnsName finds a virtual machine or host by DNS name. | [
"FindByDnsName",
"finds",
"a",
"virtual",
"machine",
"or",
"host",
"by",
"DNS",
"name",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/search_index.go#L59-L79 |
21,439 | vmware/govmomi | object/search_index.go | FindByInventoryPath | func (s SearchIndex) FindByInventoryPath(ctx context.Context, path string) (Reference, error) {
req := types.FindByInventoryPath{
This: s.Reference(),
InventoryPath: path,
}
res, err := methods.FindByInventoryPath(ctx, s.c, &req)
if err != nil {
return nil, err
}
if res.Returnval == nil {
retur... | go | func (s SearchIndex) FindByInventoryPath(ctx context.Context, path string) (Reference, error) {
req := types.FindByInventoryPath{
This: s.Reference(),
InventoryPath: path,
}
res, err := methods.FindByInventoryPath(ctx, s.c, &req)
if err != nil {
return nil, err
}
if res.Returnval == nil {
retur... | [
"func",
"(",
"s",
"SearchIndex",
")",
"FindByInventoryPath",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"Reference",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
"FindByInventoryPath",
"{",
"This",
":",
"s",
".",
"Refer... | // FindByInventoryPath finds a managed entity based on its location in the inventory. | [
"FindByInventoryPath",
"finds",
"a",
"managed",
"entity",
"based",
"on",
"its",
"location",
"in",
"the",
"inventory",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/search_index.go#L82-L97 |
21,440 | vmware/govmomi | object/search_index.go | FindByUuid | func (s SearchIndex) FindByUuid(ctx context.Context, dc *Datacenter, uuid string, vmSearch bool, instanceUuid *bool) (Reference, error) {
req := types.FindByUuid{
This: s.Reference(),
Uuid: uuid,
VmSearch: vmSearch,
InstanceUuid: instanceUuid,
}
if dc != nil {
ref := dc.Reference()
re... | go | func (s SearchIndex) FindByUuid(ctx context.Context, dc *Datacenter, uuid string, vmSearch bool, instanceUuid *bool) (Reference, error) {
req := types.FindByUuid{
This: s.Reference(),
Uuid: uuid,
VmSearch: vmSearch,
InstanceUuid: instanceUuid,
}
if dc != nil {
ref := dc.Reference()
re... | [
"func",
"(",
"s",
"SearchIndex",
")",
"FindByUuid",
"(",
"ctx",
"context",
".",
"Context",
",",
"dc",
"*",
"Datacenter",
",",
"uuid",
"string",
",",
"vmSearch",
"bool",
",",
"instanceUuid",
"*",
"bool",
")",
"(",
"Reference",
",",
"error",
")",
"{",
"r... | // FindByUuid finds a virtual machine or host by UUID. | [
"FindByUuid",
"finds",
"a",
"virtual",
"machine",
"or",
"host",
"by",
"UUID",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/search_index.go#L123-L144 |
21,441 | vmware/govmomi | object/search_index.go | FindChild | func (s SearchIndex) FindChild(ctx context.Context, entity Reference, name string) (Reference, error) {
req := types.FindChild{
This: s.Reference(),
Entity: entity.Reference(),
Name: name,
}
res, err := methods.FindChild(ctx, s.c, &req)
if err != nil {
return nil, err
}
if res.Returnval == nil {
r... | go | func (s SearchIndex) FindChild(ctx context.Context, entity Reference, name string) (Reference, error) {
req := types.FindChild{
This: s.Reference(),
Entity: entity.Reference(),
Name: name,
}
res, err := methods.FindChild(ctx, s.c, &req)
if err != nil {
return nil, err
}
if res.Returnval == nil {
r... | [
"func",
"(",
"s",
"SearchIndex",
")",
"FindChild",
"(",
"ctx",
"context",
".",
"Context",
",",
"entity",
"Reference",
",",
"name",
"string",
")",
"(",
"Reference",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
"FindChild",
"{",
"This",
":",
"s",
... | // FindChild finds a particular child based on a managed entity name. | [
"FindChild",
"finds",
"a",
"particular",
"child",
"based",
"on",
"a",
"managed",
"entity",
"name",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/search_index.go#L147-L163 |
21,442 | vmware/govmomi | toolbox/toolbox/main.go | main | func main() {
flag.Parse()
in := toolbox.NewBackdoorChannelIn()
out := toolbox.NewBackdoorChannelOut()
service := toolbox.NewService(in, out)
if os.Getuid() == 0 {
service.Power.Halt.Handler = toolbox.Halt
service.Power.Reboot.Handler = toolbox.Reboot
}
err := service.Start()
if err != nil {
log.Fatal... | go | func main() {
flag.Parse()
in := toolbox.NewBackdoorChannelIn()
out := toolbox.NewBackdoorChannelOut()
service := toolbox.NewService(in, out)
if os.Getuid() == 0 {
service.Power.Halt.Handler = toolbox.Halt
service.Power.Reboot.Handler = toolbox.Reboot
}
err := service.Start()
if err != nil {
log.Fatal... | [
"func",
"main",
"(",
")",
"{",
"flag",
".",
"Parse",
"(",
")",
"\n\n",
"in",
":=",
"toolbox",
".",
"NewBackdoorChannelIn",
"(",
")",
"\n",
"out",
":=",
"toolbox",
".",
"NewBackdoorChannelOut",
"(",
")",
"\n\n",
"service",
":=",
"toolbox",
".",
"NewServic... | // This example can be run on a VM hosted by ESX, Fusion or Workstation | [
"This",
"example",
"can",
"be",
"run",
"on",
"a",
"VM",
"hosted",
"by",
"ESX",
"Fusion",
"or",
"Workstation"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/toolbox/main.go#L43-L71 |
21,443 | vmware/govmomi | govc/flags/client.go | configure | func (flag *ClientFlag) configure(sc *soap.Client) (soap.RoundTripper, error) {
if flag.cert != "" {
cert, err := tls.LoadX509KeyPair(flag.cert, flag.key)
if err != nil {
return nil, err
}
sc.SetCertificate(cert)
}
// Set namespace and version
sc.Namespace = "urn:" + flag.vimNamespace
sc.Version = fla... | go | func (flag *ClientFlag) configure(sc *soap.Client) (soap.RoundTripper, error) {
if flag.cert != "" {
cert, err := tls.LoadX509KeyPair(flag.cert, flag.key)
if err != nil {
return nil, err
}
sc.SetCertificate(cert)
}
// Set namespace and version
sc.Namespace = "urn:" + flag.vimNamespace
sc.Version = fla... | [
"func",
"(",
"flag",
"*",
"ClientFlag",
")",
"configure",
"(",
"sc",
"*",
"soap",
".",
"Client",
")",
"(",
"soap",
".",
"RoundTripper",
",",
"error",
")",
"{",
"if",
"flag",
".",
"cert",
"!=",
"\"",
"\"",
"{",
"cert",
",",
"err",
":=",
"tls",
"."... | // configure TLS and retry settings before making any connections | [
"configure",
"TLS",
"and",
"retry",
"settings",
"before",
"making",
"any",
"connections"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/client.go#L277-L316 |
21,444 | vmware/govmomi | govc/flags/client.go | apiVersionValid | func apiVersionValid(c *vim25.Client, minVersionString string) error {
if minVersionString == "-" {
// Disable version check
return nil
}
apiVersion := c.ServiceContent.About.ApiVersion
if isDevelopmentVersion(apiVersion) {
return nil
}
realVersion, err := ParseVersion(apiVersion)
if err != nil {
retur... | go | func apiVersionValid(c *vim25.Client, minVersionString string) error {
if minVersionString == "-" {
// Disable version check
return nil
}
apiVersion := c.ServiceContent.About.ApiVersion
if isDevelopmentVersion(apiVersion) {
return nil
}
realVersion, err := ParseVersion(apiVersion)
if err != nil {
retur... | [
"func",
"apiVersionValid",
"(",
"c",
"*",
"vim25",
".",
"Client",
",",
"minVersionString",
"string",
")",
"error",
"{",
"if",
"minVersionString",
"==",
"\"",
"\"",
"{",
"// Disable version check",
"return",
"nil",
"\n",
"}",
"\n\n",
"apiVersion",
":=",
"c",
... | // apiVersionValid returns whether or not the API version supported by the
// server the client is connected to is not recent enough. | [
"apiVersionValid",
"returns",
"whether",
"or",
"not",
"the",
"API",
"version",
"supported",
"by",
"the",
"server",
"the",
"client",
"is",
"connected",
"to",
"is",
"not",
"recent",
"enough",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/client.go#L494-L524 |
21,445 | vmware/govmomi | govc/flags/client.go | Environ | func (flag *ClientFlag) Environ(extra bool) []string {
var env []string
add := func(k, v string) {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
u := *flag.url
if u.User != nil {
add(envUsername, u.User.Username())
if p, ok := u.User.Password(); ok {
add(envPassword, p)
}
u.User = nil
}
if u.P... | go | func (flag *ClientFlag) Environ(extra bool) []string {
var env []string
add := func(k, v string) {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
u := *flag.url
if u.User != nil {
add(envUsername, u.User.Username())
if p, ok := u.User.Password(); ok {
add(envPassword, p)
}
u.User = nil
}
if u.P... | [
"func",
"(",
"flag",
"*",
"ClientFlag",
")",
"Environ",
"(",
"extra",
"bool",
")",
"[",
"]",
"string",
"{",
"var",
"env",
"[",
"]",
"string",
"\n",
"add",
":=",
"func",
"(",
"k",
",",
"v",
"string",
")",
"{",
"env",
"=",
"append",
"(",
"env",
"... | // Environ returns the govc environment variables for this connection | [
"Environ",
"returns",
"the",
"govc",
"environment",
"variables",
"for",
"this",
"connection"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/client.go#L606-L668 |
21,446 | vmware/govmomi | govc/flags/client.go | WithCancel | func (flag *ClientFlag) WithCancel(ctx context.Context, f func(context.Context) error) error {
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT)
wctx, cancel := context.WithCancel(ctx)
defer cancel()
done := make(chan bool)
var werr error
go func() {
defer close(done)
werr = f(wctx)
}()
... | go | func (flag *ClientFlag) WithCancel(ctx context.Context, f func(context.Context) error) error {
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT)
wctx, cancel := context.WithCancel(ctx)
defer cancel()
done := make(chan bool)
var werr error
go func() {
defer close(done)
werr = f(wctx)
}()
... | [
"func",
"(",
"flag",
"*",
"ClientFlag",
")",
"WithCancel",
"(",
"ctx",
"context",
".",
"Context",
",",
"f",
"func",
"(",
"context",
".",
"Context",
")",
"error",
")",
"error",
"{",
"sig",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")... | // WithCancel calls the given function, returning when complete or canceled via SIGINT. | [
"WithCancel",
"calls",
"the",
"given",
"function",
"returning",
"when",
"complete",
"or",
"canceled",
"via",
"SIGINT",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/client.go#L671-L694 |
21,447 | vmware/govmomi | vim25/progress/tee.go | Tee | func Tee(s1, s2 Sinker) Sinker {
fn := func() chan<- Report {
d1 := s1.Sink()
d2 := s2.Sink()
u := make(chan Report)
go tee(u, d1, d2)
return u
}
return SinkFunc(fn)
} | go | func Tee(s1, s2 Sinker) Sinker {
fn := func() chan<- Report {
d1 := s1.Sink()
d2 := s2.Sink()
u := make(chan Report)
go tee(u, d1, d2)
return u
}
return SinkFunc(fn)
} | [
"func",
"Tee",
"(",
"s1",
",",
"s2",
"Sinker",
")",
"Sinker",
"{",
"fn",
":=",
"func",
"(",
")",
"chan",
"<-",
"Report",
"{",
"d1",
":=",
"s1",
".",
"Sink",
"(",
")",
"\n",
"d2",
":=",
"s2",
".",
"Sink",
"(",
")",
"\n",
"u",
":=",
"make",
"... | // Tee works like Unix tee; it forwards all progress reports it receives to the
// specified sinks | [
"Tee",
"works",
"like",
"Unix",
"tee",
";",
"it",
"forwards",
"all",
"progress",
"reports",
"it",
"receives",
"to",
"the",
"specified",
"sinks"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/progress/tee.go#L21-L31 |
21,448 | vmware/govmomi | simulator/host_system.go | CreateStandaloneHost | func CreateStandaloneHost(f *Folder, spec types.HostConnectSpec) (*HostSystem, types.BaseMethodFault) {
if spec.HostName == "" {
return nil, &types.NoHost{}
}
pool := NewResourcePool()
host := NewHostSystem(esx.HostSystem)
host.Summary.Config.Name = spec.HostName
host.Name = host.Summary.Config.Name
host.Run... | go | func CreateStandaloneHost(f *Folder, spec types.HostConnectSpec) (*HostSystem, types.BaseMethodFault) {
if spec.HostName == "" {
return nil, &types.NoHost{}
}
pool := NewResourcePool()
host := NewHostSystem(esx.HostSystem)
host.Summary.Config.Name = spec.HostName
host.Name = host.Summary.Config.Name
host.Run... | [
"func",
"CreateStandaloneHost",
"(",
"f",
"*",
"Folder",
",",
"spec",
"types",
".",
"HostConnectSpec",
")",
"(",
"*",
"HostSystem",
",",
"types",
".",
"BaseMethodFault",
")",
"{",
"if",
"spec",
".",
"HostName",
"==",
"\"",
"\"",
"{",
"return",
"nil",
","... | // CreateStandaloneHost uses esx.HostSystem as a template, applying the given spec
// and creating the ComputeResource parent and ResourcePool sibling. | [
"CreateStandaloneHost",
"uses",
"esx",
".",
"HostSystem",
"as",
"a",
"template",
"applying",
"the",
"given",
"spec",
"and",
"creating",
"the",
"ComputeResource",
"parent",
"and",
"ResourcePool",
"sibling",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/host_system.go#L165-L203 |
21,449 | vmware/govmomi | vapi/library/library_item_updatesession.go | CreateLibraryItemUpdateSession | func (c *Manager) CreateLibraryItemUpdateSession(ctx context.Context, session UpdateSession) (string, error) {
url := internal.URL(c, internal.LibraryItemUpdateSession)
spec := struct {
CreateSpec UpdateSession `json:"create_spec"`
}{session}
var res string
return res, c.Do(ctx, url.Request(http.MethodPost, spec... | go | func (c *Manager) CreateLibraryItemUpdateSession(ctx context.Context, session UpdateSession) (string, error) {
url := internal.URL(c, internal.LibraryItemUpdateSession)
spec := struct {
CreateSpec UpdateSession `json:"create_spec"`
}{session}
var res string
return res, c.Do(ctx, url.Request(http.MethodPost, spec... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"CreateLibraryItemUpdateSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"session",
"UpdateSession",
")",
"(",
"string",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
"... | // CreateLibraryItemUpdateSession creates a new library item | [
"CreateLibraryItemUpdateSession",
"creates",
"a",
"new",
"library",
"item"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession.go#L43-L50 |
21,450 | vmware/govmomi | vapi/library/library_item_updatesession.go | GetLibraryItemUpdateSession | func (c *Manager) GetLibraryItemUpdateSession(ctx context.Context, id string) (*UpdateSession, error) {
url := internal.URL(c, internal.LibraryItemUpdateSession).WithID(id)
var res UpdateSession
return &res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | func (c *Manager) GetLibraryItemUpdateSession(ctx context.Context, id string) (*UpdateSession, error) {
url := internal.URL(c, internal.LibraryItemUpdateSession).WithID(id)
var res UpdateSession
return &res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetLibraryItemUpdateSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"*",
"UpdateSession",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".... | // GetLibraryItemUpdateSession gets the update session information with status | [
"GetLibraryItemUpdateSession",
"gets",
"the",
"update",
"session",
"information",
"with",
"status"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession.go#L53-L57 |
21,451 | vmware/govmomi | vapi/library/library_item_updatesession.go | ListLibraryItemUpdateSession | func (c *Manager) ListLibraryItemUpdateSession(ctx context.Context) (*[]string, error) {
url := internal.URL(c, internal.LibraryItemUpdateSession)
var res []string
return &res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | func (c *Manager) ListLibraryItemUpdateSession(ctx context.Context) (*[]string, error) {
url := internal.URL(c, internal.LibraryItemUpdateSession)
var res []string
return &res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"ListLibraryItemUpdateSession",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"[",
"]",
"string",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"LibraryItemUp... | // ListLibraryItemUpdateSession gets the list of update sessions | [
"ListLibraryItemUpdateSession",
"gets",
"the",
"list",
"of",
"update",
"sessions"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession.go#L60-L64 |
21,452 | vmware/govmomi | vapi/library/library_item_updatesession.go | DeleteLibraryItemUpdateSession | func (c *Manager) DeleteLibraryItemUpdateSession(ctx context.Context, id string) error {
url := internal.URL(c, internal.LibraryItemUpdateSession).WithID(id)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | go | func (c *Manager) DeleteLibraryItemUpdateSession(ctx context.Context, id string) error {
url := internal.URL(c, internal.LibraryItemUpdateSession).WithID(id)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"DeleteLibraryItemUpdateSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"error",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"LibraryItemUpdateSession",
")",
".... | // DeleteLibraryItemUpdateSession deletes an update session | [
"DeleteLibraryItemUpdateSession",
"deletes",
"an",
"update",
"session"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession.go#L79-L82 |
21,453 | vmware/govmomi | vapi/library/library_item_updatesession.go | FailLibraryItemUpdateSession | func (c *Manager) FailLibraryItemUpdateSession(ctx context.Context, id string) error {
url := internal.URL(c, internal.LibraryItemUpdateSession).WithID(id).WithAction("fail")
return c.Do(ctx, url.Request(http.MethodPost), nil)
} | go | func (c *Manager) FailLibraryItemUpdateSession(ctx context.Context, id string) error {
url := internal.URL(c, internal.LibraryItemUpdateSession).WithID(id).WithAction("fail")
return c.Do(ctx, url.Request(http.MethodPost), nil)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"FailLibraryItemUpdateSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"error",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"LibraryItemUpdateSession",
")",
".",... | // FailLibraryItemUpdateSession fails an update session | [
"FailLibraryItemUpdateSession",
"fails",
"an",
"update",
"session"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession.go#L85-L88 |
21,454 | vmware/govmomi | vapi/library/library_item_updatesession.go | WaitOnLibraryItemUpdateSession | func (c *Manager) WaitOnLibraryItemUpdateSession(
ctx context.Context, sessionID string,
interval time.Duration, intervalCallback func()) error {
// Wait until the upload operation is complete to return.
for {
session, err := c.GetLibraryItemUpdateSession(ctx, sessionID)
if err != nil {
return err
}
if ... | go | func (c *Manager) WaitOnLibraryItemUpdateSession(
ctx context.Context, sessionID string,
interval time.Duration, intervalCallback func()) error {
// Wait until the upload operation is complete to return.
for {
session, err := c.GetLibraryItemUpdateSession(ctx, sessionID)
if err != nil {
return err
}
if ... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"WaitOnLibraryItemUpdateSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionID",
"string",
",",
"interval",
"time",
".",
"Duration",
",",
"intervalCallback",
"func",
"(",
")",
")",
"error",
"{",
"// Wait until t... | // WaitOnLibraryItemUpdateSession blocks until the update session is no longer
// in the ACTIVE state. | [
"WaitOnLibraryItemUpdateSession",
"blocks",
"until",
"the",
"update",
"session",
"is",
"no",
"longer",
"in",
"the",
"ACTIVE",
"state",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item_updatesession.go#L98-L116 |
21,455 | vmware/govmomi | sts/internal/types.go | toString | func (r *RequestSecurityToken) toString(c14n bool) string {
actas := ""
if r.ActAs != nil {
token := r.ActAs.Token
if c14n {
var a Assertion
err := Unmarshal([]byte(r.ActAs.Token), &a)
if err != nil {
log.Printf("decode ActAs: %s", err)
}
token = a.C14N()
}
actas = fmt.Sprintf(`<wst:ActAs ... | go | func (r *RequestSecurityToken) toString(c14n bool) string {
actas := ""
if r.ActAs != nil {
token := r.ActAs.Token
if c14n {
var a Assertion
err := Unmarshal([]byte(r.ActAs.Token), &a)
if err != nil {
log.Printf("decode ActAs: %s", err)
}
token = a.C14N()
}
actas = fmt.Sprintf(`<wst:ActAs ... | [
"func",
"(",
"r",
"*",
"RequestSecurityToken",
")",
"toString",
"(",
"c14n",
"bool",
")",
"string",
"{",
"actas",
":=",
"\"",
"\"",
"\n",
"if",
"r",
".",
"ActAs",
"!=",
"nil",
"{",
"token",
":=",
"r",
".",
"ActAs",
".",
"Token",
"\n",
"if",
"c14n",... | // toString returns an XML encoded RequestSecurityToken.
// When c14n is true, returns the canonicalized ActAs.Assertion which is required to sign the Issue request.
// When c14n is false, returns the original content of the ActAs.Assertion.
// The original content must be used within the request Body, as it has its ow... | [
"toString",
"returns",
"an",
"XML",
"encoded",
"RequestSecurityToken",
".",
"When",
"c14n",
"is",
"true",
"returns",
"the",
"canonicalized",
"ActAs",
".",
"Assertion",
"which",
"is",
"required",
"to",
"sign",
"the",
"Issue",
"request",
".",
"When",
"c14n",
"is... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/internal/types.go#L552-L600 |
21,456 | vmware/govmomi | sts/internal/types.go | Marshal | func Marshal(val interface{}) string {
b, err := xml.Marshal(val)
if err != nil {
panic(err)
}
return string(b)
} | go | func Marshal(val interface{}) string {
b, err := xml.Marshal(val)
if err != nil {
panic(err)
}
return string(b)
} | [
"func",
"Marshal",
"(",
"val",
"interface",
"{",
"}",
")",
"string",
"{",
"b",
",",
"err",
":=",
"xml",
".",
"Marshal",
"(",
"val",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
"b... | // Marshal panics if xml.Marshal returns an error | [
"Marshal",
"panics",
"if",
"xml",
".",
"Marshal",
"returns",
"an",
"error"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/internal/types.go#L673-L679 |
21,457 | vmware/govmomi | sts/internal/types.go | mkns | func mkns(ns string, obj interface{}, name ...*xml.Name) string {
ns += ":"
for i := range name {
name[i].Space = ""
if !strings.HasPrefix(name[i].Local, ns) {
name[i].Local = ns + name[i].Local
}
}
return Marshal(obj)
} | go | func mkns(ns string, obj interface{}, name ...*xml.Name) string {
ns += ":"
for i := range name {
name[i].Space = ""
if !strings.HasPrefix(name[i].Local, ns) {
name[i].Local = ns + name[i].Local
}
}
return Marshal(obj)
} | [
"func",
"mkns",
"(",
"ns",
"string",
",",
"obj",
"interface",
"{",
"}",
",",
"name",
"...",
"*",
"xml",
".",
"Name",
")",
"string",
"{",
"ns",
"+=",
"\"",
"\"",
"\n",
"for",
"i",
":=",
"range",
"name",
"{",
"name",
"[",
"i",
"]",
".",
"Space",
... | // mkns prepends the given namespace to xml.Name.Local and returns obj encoded as xml.
// Note that the namespace is required when encoding, but the namespace prefix must not be
// present when decoding as Go's decoding does not handle namespace prefix. | [
"mkns",
"prepends",
"the",
"given",
"namespace",
"to",
"xml",
".",
"Name",
".",
"Local",
"and",
"returns",
"obj",
"encoded",
"as",
"xml",
".",
"Note",
"that",
"the",
"namespace",
"is",
"required",
"when",
"encoding",
"but",
"the",
"namespace",
"prefix",
"m... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/sts/internal/types.go#L684-L694 |
21,458 | vmware/govmomi | view/container_view.go | Retrieve | func (v ContainerView) Retrieve(ctx context.Context, kind []string, ps []string, dst interface{}) error {
pc := property.DefaultCollector(v.Client())
ospec := types.ObjectSpec{
Obj: v.Reference(),
Skip: types.NewBool(true),
SelectSet: []types.BaseSelectionSpec{
&types.TraversalSpec{
Type: v.Reference()... | go | func (v ContainerView) Retrieve(ctx context.Context, kind []string, ps []string, dst interface{}) error {
pc := property.DefaultCollector(v.Client())
ospec := types.ObjectSpec{
Obj: v.Reference(),
Skip: types.NewBool(true),
SelectSet: []types.BaseSelectionSpec{
&types.TraversalSpec{
Type: v.Reference()... | [
"func",
"(",
"v",
"ContainerView",
")",
"Retrieve",
"(",
"ctx",
"context",
".",
"Context",
",",
"kind",
"[",
"]",
"string",
",",
"ps",
"[",
"]",
"string",
",",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"pc",
":=",
"property",
".",
"DefaultColl... | // Retrieve populates dst as property.Collector.Retrieve does, for all entities in the view of types specified by kind. | [
"Retrieve",
"populates",
"dst",
"as",
"property",
".",
"Collector",
".",
"Retrieve",
"does",
"for",
"all",
"entities",
"in",
"the",
"view",
"of",
"types",
"specified",
"by",
"kind",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/view/container_view.go#L39-L93 |
21,459 | vmware/govmomi | view/container_view.go | Find | func (v ContainerView) Find(ctx context.Context, kind []string, filter property.Filter) ([]types.ManagedObjectReference, error) {
if len(filter) == 0 {
// Ensure we have at least 1 filter to avoid retrieving all properties.
filter = property.Filter{"name": "*"}
}
var content []types.ObjectContent
err := v.Ret... | go | func (v ContainerView) Find(ctx context.Context, kind []string, filter property.Filter) ([]types.ManagedObjectReference, error) {
if len(filter) == 0 {
// Ensure we have at least 1 filter to avoid retrieving all properties.
filter = property.Filter{"name": "*"}
}
var content []types.ObjectContent
err := v.Ret... | [
"func",
"(",
"v",
"ContainerView",
")",
"Find",
"(",
"ctx",
"context",
".",
"Context",
",",
"kind",
"[",
"]",
"string",
",",
"filter",
"property",
".",
"Filter",
")",
"(",
"[",
"]",
"types",
".",
"ManagedObjectReference",
",",
"error",
")",
"{",
"if",
... | // Find returns object references for entities of type kind, matching the given filter. | [
"Find",
"returns",
"object",
"references",
"for",
"entities",
"of",
"type",
"kind",
"matching",
"the",
"given",
"filter",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/view/container_view.go#L116-L130 |
21,460 | vmware/govmomi | simulator/virtual_machine.go | updateDiskLayouts | func (vm *VirtualMachine) updateDiskLayouts() types.BaseMethodFault {
var disksLayout []types.VirtualMachineFileLayoutDiskLayout
var disksLayoutEx []types.VirtualMachineFileLayoutExDiskLayout
disks := object.VirtualDeviceList(vm.Config.Hardware.Device).SelectByType((*types.VirtualDisk)(nil))
for _, disk := range d... | go | func (vm *VirtualMachine) updateDiskLayouts() types.BaseMethodFault {
var disksLayout []types.VirtualMachineFileLayoutDiskLayout
var disksLayoutEx []types.VirtualMachineFileLayoutExDiskLayout
disks := object.VirtualDeviceList(vm.Config.Hardware.Device).SelectByType((*types.VirtualDisk)(nil))
for _, disk := range d... | [
"func",
"(",
"vm",
"*",
"VirtualMachine",
")",
"updateDiskLayouts",
"(",
")",
"types",
".",
"BaseMethodFault",
"{",
"var",
"disksLayout",
"[",
"]",
"types",
".",
"VirtualMachineFileLayoutDiskLayout",
"\n",
"var",
"disksLayoutEx",
"[",
"]",
"types",
".",
"Virtual... | // Updates both vm.Layout.Disk and vm.LayoutEx.Disk | [
"Updates",
"both",
"vm",
".",
"Layout",
".",
"Disk",
"and",
"vm",
".",
"LayoutEx",
".",
"Disk"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/virtual_machine.go#L519-L583 |
21,461 | vmware/govmomi | govc/flags/output.go | Log | func (flag *OutputFlag) Log(s string) (int, error) {
if len(s) > 0 && s[0] == '\r' {
flag.Write([]byte{'\r', 033, '[', 'K'})
s = s[1:]
}
return flag.WriteString(time.Now().Format("[02-01-06 15:04:05] ") + s)
} | go | func (flag *OutputFlag) Log(s string) (int, error) {
if len(s) > 0 && s[0] == '\r' {
flag.Write([]byte{'\r', 033, '[', 'K'})
s = s[1:]
}
return flag.WriteString(time.Now().Format("[02-01-06 15:04:05] ") + s)
} | [
"func",
"(",
"flag",
"*",
"OutputFlag",
")",
"Log",
"(",
"s",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
">",
"0",
"&&",
"s",
"[",
"0",
"]",
"==",
"'\\r'",
"{",
"flag",
".",
"Write",
"(",
"[",
"]",
"byte"... | // Log outputs the specified string, prefixed with the current time.
// A newline is not automatically added. If the specified string
// starts with a '\r', the current line is cleared first. | [
"Log",
"outputs",
"the",
"specified",
"string",
"prefixed",
"with",
"the",
"current",
"time",
".",
"A",
"newline",
"is",
"not",
"automatically",
"added",
".",
"If",
"the",
"specified",
"string",
"starts",
"with",
"a",
"\\",
"r",
"the",
"current",
"line",
"... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/flags/output.go#L80-L87 |
21,462 | vmware/govmomi | vim25/mo/retrieve.go | ObjectContentToType | func ObjectContentToType(o types.ObjectContent) (interface{}, error) {
// Expect no properties in the missing set
for _, p := range o.MissingSet {
if ignoreMissingProperty(o.Obj, p) {
continue
}
return nil, soap.WrapVimFault(p.Fault.Fault)
}
ti := typeInfoForType(o.Obj.Type)
v, err := ti.LoadFromObjectC... | go | func ObjectContentToType(o types.ObjectContent) (interface{}, error) {
// Expect no properties in the missing set
for _, p := range o.MissingSet {
if ignoreMissingProperty(o.Obj, p) {
continue
}
return nil, soap.WrapVimFault(p.Fault.Fault)
}
ti := typeInfoForType(o.Obj.Type)
v, err := ti.LoadFromObjectC... | [
"func",
"ObjectContentToType",
"(",
"o",
"types",
".",
"ObjectContent",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// Expect no properties in the missing set",
"for",
"_",
",",
"p",
":=",
"range",
"o",
".",
"MissingSet",
"{",
"if",
"ignoreMissin... | // ObjectContentToType loads an ObjectContent value into the value it
// represents. If the ObjectContent value has a non-empty 'MissingSet' field,
// it returns the first fault it finds there as error. If the 'MissingSet'
// field is empty, it returns a pointer to a reflect.Value. It handles contain
// nested properti... | [
"ObjectContentToType",
"loads",
"an",
"ObjectContent",
"value",
"into",
"the",
"value",
"it",
"represents",
".",
"If",
"the",
"ObjectContent",
"value",
"has",
"a",
"non",
"-",
"empty",
"MissingSet",
"field",
"it",
"returns",
"the",
"first",
"fault",
"it",
"fin... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/mo/retrieve.go#L49-L66 |
21,463 | vmware/govmomi | vim25/mo/retrieve.go | ApplyPropertyChange | func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) {
t := typeInfoForType(obj.Reference().Type)
v := reflect.ValueOf(obj)
for _, p := range changes {
rv, ok := t.props[p.Name]
if !ok {
continue
}
assignValue(v, rv, reflect.ValueOf(p.Val))
}
} | go | func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) {
t := typeInfoForType(obj.Reference().Type)
v := reflect.ValueOf(obj)
for _, p := range changes {
rv, ok := t.props[p.Name]
if !ok {
continue
}
assignValue(v, rv, reflect.ValueOf(p.Val))
}
} | [
"func",
"ApplyPropertyChange",
"(",
"obj",
"Reference",
",",
"changes",
"[",
"]",
"types",
".",
"PropertyChange",
")",
"{",
"t",
":=",
"typeInfoForType",
"(",
"obj",
".",
"Reference",
"(",
")",
".",
"Type",
")",
"\n",
"v",
":=",
"reflect",
".",
"ValueOf"... | // ApplyPropertyChange converts the response of a call to WaitForUpdates
// and applies it to the given managed object. | [
"ApplyPropertyChange",
"converts",
"the",
"response",
"of",
"a",
"call",
"to",
"WaitForUpdates",
"and",
"applies",
"it",
"to",
"the",
"given",
"managed",
"object",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/mo/retrieve.go#L70-L82 |
21,464 | vmware/govmomi | vim25/mo/retrieve.go | LoadRetrievePropertiesResponse | func LoadRetrievePropertiesResponse(res *types.RetrievePropertiesResponse, dst interface{}) error {
rt := reflect.TypeOf(dst)
if rt == nil || rt.Kind() != reflect.Ptr {
panic("need pointer")
}
rv := reflect.ValueOf(dst).Elem()
if !rv.CanSet() {
panic("cannot set dst")
}
isSlice := false
switch rt.Elem().K... | go | func LoadRetrievePropertiesResponse(res *types.RetrievePropertiesResponse, dst interface{}) error {
rt := reflect.TypeOf(dst)
if rt == nil || rt.Kind() != reflect.Ptr {
panic("need pointer")
}
rv := reflect.ValueOf(dst).Elem()
if !rv.CanSet() {
panic("cannot set dst")
}
isSlice := false
switch rt.Elem().K... | [
"func",
"LoadRetrievePropertiesResponse",
"(",
"res",
"*",
"types",
".",
"RetrievePropertiesResponse",
",",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"rt",
":=",
"reflect",
".",
"TypeOf",
"(",
"dst",
")",
"\n",
"if",
"rt",
"==",
"nil",
"||",
"rt",
... | // LoadRetrievePropertiesResponse converts the response of a call to
// RetrieveProperties to one or more managed objects. | [
"LoadRetrievePropertiesResponse",
"converts",
"the",
"response",
"of",
"a",
"call",
"to",
"RetrieveProperties",
"to",
"one",
"or",
"more",
"managed",
"objects",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/mo/retrieve.go#L86-L152 |
21,465 | vmware/govmomi | vim25/mo/retrieve.go | RetrievePropertiesForRequest | func RetrievePropertiesForRequest(ctx context.Context, r soap.RoundTripper, req types.RetrieveProperties, dst interface{}) error {
res, err := methods.RetrieveProperties(ctx, r, &req)
if err != nil {
return err
}
return LoadRetrievePropertiesResponse(res, dst)
} | go | func RetrievePropertiesForRequest(ctx context.Context, r soap.RoundTripper, req types.RetrieveProperties, dst interface{}) error {
res, err := methods.RetrieveProperties(ctx, r, &req)
if err != nil {
return err
}
return LoadRetrievePropertiesResponse(res, dst)
} | [
"func",
"RetrievePropertiesForRequest",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"soap",
".",
"RoundTripper",
",",
"req",
"types",
".",
"RetrieveProperties",
",",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"res",
",",
"err",
":=",
"methods",
... | // RetrievePropertiesForRequest calls the RetrieveProperties method with the
// specified request and decodes the response struct into the value pointed to
// by dst. | [
"RetrievePropertiesForRequest",
"calls",
"the",
"RetrieveProperties",
"method",
"with",
"the",
"specified",
"request",
"and",
"decodes",
"the",
"response",
"struct",
"into",
"the",
"value",
"pointed",
"to",
"by",
"dst",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/mo/retrieve.go#L157-L164 |
21,466 | vmware/govmomi | vim25/mo/retrieve.go | RetrieveProperties | func RetrieveProperties(ctx context.Context, r soap.RoundTripper, pc, obj types.ManagedObjectReference, dst interface{}) error {
req := types.RetrieveProperties{
This: pc,
SpecSet: []types.PropertyFilterSpec{
{
ObjectSet: []types.ObjectSpec{
{
Obj: obj,
Skip: types.NewBool(false),
},
... | go | func RetrieveProperties(ctx context.Context, r soap.RoundTripper, pc, obj types.ManagedObjectReference, dst interface{}) error {
req := types.RetrieveProperties{
This: pc,
SpecSet: []types.PropertyFilterSpec{
{
ObjectSet: []types.ObjectSpec{
{
Obj: obj,
Skip: types.NewBool(false),
},
... | [
"func",
"RetrieveProperties",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"soap",
".",
"RoundTripper",
",",
"pc",
",",
"obj",
"types",
".",
"ManagedObjectReference",
",",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"req",
":=",
"types",
".",
"R... | // RetrieveProperties retrieves the properties of the managed object specified
// as obj and decodes the response struct into the value pointed to by dst. | [
"RetrieveProperties",
"retrieves",
"the",
"properties",
"of",
"the",
"managed",
"object",
"specified",
"as",
"obj",
"and",
"decodes",
"the",
"response",
"struct",
"into",
"the",
"value",
"pointed",
"to",
"by",
"dst",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/mo/retrieve.go#L168-L190 |
21,467 | vmware/govmomi | toolbox/hgfs/server.go | NewServer | func NewServer() *Server {
if f := flag.Lookup("toolbox.trace"); f != nil {
Trace, _ = strconv.ParseBool(f.Value.String())
}
s := &Server{
sessions: make(map[uint64]*session),
schemes: make(map[string]FileHandler),
chmod: os.Chmod,
chown: os.Chown,
}
s.handlers = map[int32]func(*Packet) (interfa... | go | func NewServer() *Server {
if f := flag.Lookup("toolbox.trace"); f != nil {
Trace, _ = strconv.ParseBool(f.Value.String())
}
s := &Server{
sessions: make(map[uint64]*session),
schemes: make(map[string]FileHandler),
chmod: os.Chmod,
chown: os.Chown,
}
s.handlers = map[int32]func(*Packet) (interfa... | [
"func",
"NewServer",
"(",
")",
"*",
"Server",
"{",
"if",
"f",
":=",
"flag",
".",
"Lookup",
"(",
"\"",
"\"",
")",
";",
"f",
"!=",
"nil",
"{",
"Trace",
",",
"_",
"=",
"strconv",
".",
"ParseBool",
"(",
"f",
".",
"Value",
".",
"String",
"(",
")",
... | // NewServer creates a new Server instance with the default handlers | [
"NewServer",
"creates",
"a",
"new",
"Server",
"instance",
"with",
"the",
"default",
"handlers"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L57-L86 |
21,468 | vmware/govmomi | toolbox/hgfs/server.go | RegisterFileHandler | func (s *Server) RegisterFileHandler(scheme string, handler FileHandler) {
if handler == nil {
delete(s.schemes, scheme)
return
}
s.schemes[scheme] = handler
} | go | func (s *Server) RegisterFileHandler(scheme string, handler FileHandler) {
if handler == nil {
delete(s.schemes, scheme)
return
}
s.schemes[scheme] = handler
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"RegisterFileHandler",
"(",
"scheme",
"string",
",",
"handler",
"FileHandler",
")",
"{",
"if",
"handler",
"==",
"nil",
"{",
"delete",
"(",
"s",
".",
"schemes",
",",
"scheme",
")",
"\n",
"return",
"\n",
"}",
"\n",
... | // RegisterFileHandler enables dispatch to handler for the given scheme. | [
"RegisterFileHandler",
"enables",
"dispatch",
"to",
"handler",
"for",
"the",
"given",
"scheme",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L89-L95 |
21,469 | vmware/govmomi | toolbox/hgfs/server.go | Dispatch | func (s *Server) Dispatch(packet []byte) ([]byte, error) {
req := &Packet{}
err := req.UnmarshalBinary(packet)
if err != nil {
return nil, err
}
if Trace {
fmt.Fprintf(os.Stderr, "[hgfs] request %#v\n", req.Header)
}
var res interface{}
handler, ok := s.handlers[req.Op]
if ok {
res, err = handler(re... | go | func (s *Server) Dispatch(packet []byte) ([]byte, error) {
req := &Packet{}
err := req.UnmarshalBinary(packet)
if err != nil {
return nil, err
}
if Trace {
fmt.Fprintf(os.Stderr, "[hgfs] request %#v\n", req.Header)
}
var res interface{}
handler, ok := s.handlers[req.Op]
if ok {
res, err = handler(re... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Dispatch",
"(",
"packet",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"req",
":=",
"&",
"Packet",
"{",
"}",
"\n\n",
"err",
":=",
"req",
".",
"UnmarshalBinary",
"(",
"packet",
")",
... | // Dispatch unpacks the given request packet and dispatches to the appropriate handler | [
"Dispatch",
"unpacks",
"the",
"given",
"request",
"packet",
"and",
"dispatches",
"to",
"the",
"appropriate",
"handler"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L98-L123 |
21,470 | vmware/govmomi | toolbox/hgfs/server.go | urlParse | func urlParse(name string) *url.URL {
var info os.FileInfo
u, err := url.Parse(name)
if err == nil && u.Scheme == "" {
info, err = os.Stat(u.Path)
if err == nil && info.IsDir() {
u.Scheme = ArchiveScheme // special case for IsDir()
return u
}
}
u, err = url.Parse(strings.TrimPrefix(name, "/")) // mus... | go | func urlParse(name string) *url.URL {
var info os.FileInfo
u, err := url.Parse(name)
if err == nil && u.Scheme == "" {
info, err = os.Stat(u.Path)
if err == nil && info.IsDir() {
u.Scheme = ArchiveScheme // special case for IsDir()
return u
}
}
u, err = url.Parse(strings.TrimPrefix(name, "/")) // mus... | [
"func",
"urlParse",
"(",
"name",
"string",
")",
"*",
"url",
".",
"URL",
"{",
"var",
"info",
"os",
".",
"FileInfo",
"\n\n",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"name",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"u",
".",
"Scheme",
"... | // urlParse attempts to convert the given name to a URL with scheme for use as FileHandler dispatch. | [
"urlParse",
"attempts",
"to",
"convert",
"the",
"given",
"name",
"to",
"a",
"URL",
"with",
"scheme",
"for",
"use",
"as",
"FileHandler",
"dispatch",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L142-L168 |
21,471 | vmware/govmomi | toolbox/hgfs/server.go | OpenFile | func (s *Server) OpenFile(name string, mode int32) (File, error) {
u := urlParse(name)
if h, ok := s.schemes[u.Scheme]; ok {
f, serr := h.Open(u, mode)
if serr != os.ErrNotExist {
return f, serr
}
}
switch mode {
case OpenModeReadOnly:
return os.Open(filepath.Clean(name))
case OpenModeWriteOnly:
fl... | go | func (s *Server) OpenFile(name string, mode int32) (File, error) {
u := urlParse(name)
if h, ok := s.schemes[u.Scheme]; ok {
f, serr := h.Open(u, mode)
if serr != os.ErrNotExist {
return f, serr
}
}
switch mode {
case OpenModeReadOnly:
return os.Open(filepath.Clean(name))
case OpenModeWriteOnly:
fl... | [
"func",
"(",
"s",
"*",
"Server",
")",
"OpenFile",
"(",
"name",
"string",
",",
"mode",
"int32",
")",
"(",
"File",
",",
"error",
")",
"{",
"u",
":=",
"urlParse",
"(",
"name",
")",
"\n\n",
"if",
"h",
",",
"ok",
":=",
"s",
".",
"schemes",
"[",
"u",... | // OpenFile selects the File implementation based on file type and mode. | [
"OpenFile",
"selects",
"the",
"File",
"implementation",
"based",
"on",
"file",
"type",
"and",
"mode",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L171-L193 |
21,472 | vmware/govmomi | toolbox/hgfs/server.go | CreateSessionV4 | func (s *Server) CreateSessionV4(p *Packet) (interface{}, error) {
const SessionMaxPacketSizeValid = 0x1
req := new(RequestCreateSessionV4)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
res := &ReplyCreateSessionV4{
SessionID: uint64(rand.Int63()),
NumCapabilities: uint32(... | go | func (s *Server) CreateSessionV4(p *Packet) (interface{}, error) {
const SessionMaxPacketSizeValid = 0x1
req := new(RequestCreateSessionV4)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
res := &ReplyCreateSessionV4{
SessionID: uint64(rand.Int63()),
NumCapabilities: uint32(... | [
"func",
"(",
"s",
"*",
"Server",
")",
"CreateSessionV4",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"const",
"SessionMaxPacketSizeValid",
"=",
"0x1",
"\n\n",
"req",
":=",
"new",
"(",
"RequestCreateSessionV4",
")",
"... | // CreateSessionV4 handls OpCreateSessionV4 requests | [
"CreateSessionV4",
"handls",
"OpCreateSessionV4",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L271-L297 |
21,473 | vmware/govmomi | toolbox/hgfs/server.go | DestroySessionV4 | func (s *Server) DestroySessionV4(p *Packet) (interface{}, error) {
if s.removeSession(p.SessionID) {
return &ReplyDestroySessionV4{}, nil
}
return nil, &Status{Code: StatusStaleSession}
} | go | func (s *Server) DestroySessionV4(p *Packet) (interface{}, error) {
if s.removeSession(p.SessionID) {
return &ReplyDestroySessionV4{}, nil
}
return nil, &Status{Code: StatusStaleSession}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"DestroySessionV4",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"s",
".",
"removeSession",
"(",
"p",
".",
"SessionID",
")",
"{",
"return",
"&",
"ReplyDestroySessionV4",
... | // DestroySessionV4 handls OpDestroySessionV4 requests | [
"DestroySessionV4",
"handls",
"OpDestroySessionV4",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L300-L306 |
21,474 | vmware/govmomi | toolbox/hgfs/server.go | Stat | func (a *AttrV2) Stat(info os.FileInfo) {
switch {
case info.IsDir():
a.Type = FileTypeDirectory
case info.Mode()&os.ModeSymlink == os.ModeSymlink:
a.Type = FileTypeSymlink
default:
a.Type = FileTypeRegular
}
a.Size = uint64(info.Size())
a.Mask = AttrValidType | AttrValidSize
a.sysStat(info)
} | go | func (a *AttrV2) Stat(info os.FileInfo) {
switch {
case info.IsDir():
a.Type = FileTypeDirectory
case info.Mode()&os.ModeSymlink == os.ModeSymlink:
a.Type = FileTypeSymlink
default:
a.Type = FileTypeRegular
}
a.Size = uint64(info.Size())
a.Mask = AttrValidType | AttrValidSize
a.sysStat(info)
} | [
"func",
"(",
"a",
"*",
"AttrV2",
")",
"Stat",
"(",
"info",
"os",
".",
"FileInfo",
")",
"{",
"switch",
"{",
"case",
"info",
".",
"IsDir",
"(",
")",
":",
"a",
".",
"Type",
"=",
"FileTypeDirectory",
"\n",
"case",
"info",
".",
"Mode",
"(",
")",
"&",
... | // Stat maps os.FileInfo to AttrV2 | [
"Stat",
"maps",
"os",
".",
"FileInfo",
"to",
"AttrV2"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L309-L324 |
21,475 | vmware/govmomi | toolbox/hgfs/server.go | GetattrV2 | func (s *Server) GetattrV2(p *Packet) (interface{}, error) {
res := &ReplyGetattrV2{}
req := new(RequestGetattrV2)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
name := req.FileName.Path()
info, err := s.Stat(name)
if err != nil {
return nil, err
}
res.Attr.Stat(info)
retur... | go | func (s *Server) GetattrV2(p *Packet) (interface{}, error) {
res := &ReplyGetattrV2{}
req := new(RequestGetattrV2)
err := UnmarshalBinary(p.Payload, req)
if err != nil {
return nil, err
}
name := req.FileName.Path()
info, err := s.Stat(name)
if err != nil {
return nil, err
}
res.Attr.Stat(info)
retur... | [
"func",
"(",
"s",
"*",
"Server",
")",
"GetattrV2",
"(",
"p",
"*",
"Packet",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"res",
":=",
"&",
"ReplyGetattrV2",
"{",
"}",
"\n\n",
"req",
":=",
"new",
"(",
"RequestGetattrV2",
")",
"\n",
"err"... | // GetattrV2 handles OpGetattrV2 requests | [
"GetattrV2",
"handles",
"OpGetattrV2",
"requests"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/hgfs/server.go#L327-L345 |
21,476 | 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 |
21,477 | 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 |
21,478 | 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 |
21,479 | 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 |
21,480 | 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 |
21,481 | 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 |
21,482 | 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 |
21,483 | 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 |
21,484 | 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 |
21,485 | 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 |
21,486 | 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 |
21,487 | 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 |
21,488 | 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 |
21,489 | 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 |
21,490 | 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 |
21,491 | 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 |
21,492 | 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 |
21,493 | 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 |
21,494 | 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 |
21,495 | 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 |
21,496 | 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 |
21,497 | 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 |
21,498 | 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 |
21,499 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.