repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
vmware/govmomi | vim25/xml/xml.go | autoClose | func (d *Decoder) autoClose(t Token) (Token, bool) {
if d.stk == nil || d.stk.kind != stkStart {
return nil, false
}
name := strings.ToLower(d.stk.name.Local)
for _, s := range d.AutoClose {
if strings.ToLower(s) == name {
// This one should be auto closed if t doesn't close it.
et, ok := t.(EndElement)
... | go | func (d *Decoder) autoClose(t Token) (Token, bool) {
if d.stk == nil || d.stk.kind != stkStart {
return nil, false
}
name := strings.ToLower(d.stk.name.Local)
for _, s := range d.AutoClose {
if strings.ToLower(s) == name {
// This one should be auto closed if t doesn't close it.
et, ok := t.(EndElement)
... | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"autoClose",
"(",
"t",
"Token",
")",
"(",
"Token",
",",
"bool",
")",
"{",
"if",
"d",
".",
"stk",
"==",
"nil",
"||",
"d",
".",
"stk",
".",
"kind",
"!=",
"stkStart",
"{",
"return",
"nil",
",",
"false",
"\n",... | // If the top element on the stack is autoclosing and
// t is not the end tag, invent the end tag. | [
"If",
"the",
"top",
"element",
"on",
"the",
"stack",
"is",
"autoclosing",
"and",
"t",
"is",
"not",
"the",
"end",
"tag",
"invent",
"the",
"end",
"tag",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L473-L489 | train |
vmware/govmomi | vim25/xml/xml.go | RawToken | func (d *Decoder) RawToken() (Token, error) {
if d.unmarshalDepth > 0 {
return nil, errRawToken
}
return d.rawToken()
} | go | func (d *Decoder) RawToken() (Token, error) {
if d.unmarshalDepth > 0 {
return nil, errRawToken
}
return d.rawToken()
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"RawToken",
"(",
")",
"(",
"Token",
",",
"error",
")",
"{",
"if",
"d",
".",
"unmarshalDepth",
">",
"0",
"{",
"return",
"nil",
",",
"errRawToken",
"\n",
"}",
"\n",
"return",
"d",
".",
"rawToken",
"(",
")",
"\... | // RawToken is like Token but does not verify that
// start and end elements match and does not translate
// name space prefixes to their corresponding URLs. | [
"RawToken",
"is",
"like",
"Token",
"but",
"does",
"not",
"verify",
"that",
"start",
"and",
"end",
"elements",
"match",
"and",
"does",
"not",
"translate",
"name",
"space",
"prefixes",
"to",
"their",
"corresponding",
"URLs",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L496-L501 | train |
vmware/govmomi | vim25/xml/xml.go | space | func (d *Decoder) space() {
for {
b, ok := d.getc()
if !ok {
return
}
switch b {
case ' ', '\r', '\n', '\t':
default:
d.ungetc(b)
return
}
}
} | go | func (d *Decoder) space() {
for {
b, ok := d.getc()
if !ok {
return
}
switch b {
case ' ', '\r', '\n', '\t':
default:
d.ungetc(b)
return
}
}
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"space",
"(",
")",
"{",
"for",
"{",
"b",
",",
"ok",
":=",
"d",
".",
"getc",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"switch",
"b",
"{",
"case",
"' '",
",",
"'\\r'",
",",
"'\\n'... | // Skip spaces if any | [
"Skip",
"spaces",
"if",
"any"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L828-L841 | train |
vmware/govmomi | vim25/xml/xml.go | getc | func (d *Decoder) getc() (b byte, ok bool) {
if d.err != nil {
return 0, false
}
if d.nextByte >= 0 {
b = byte(d.nextByte)
d.nextByte = -1
} else {
b, d.err = d.r.ReadByte()
if d.err != nil {
return 0, false
}
if d.saved != nil {
d.saved.WriteByte(b)
}
}
if b == '\n' {
d.line++
}
return ... | go | func (d *Decoder) getc() (b byte, ok bool) {
if d.err != nil {
return 0, false
}
if d.nextByte >= 0 {
b = byte(d.nextByte)
d.nextByte = -1
} else {
b, d.err = d.r.ReadByte()
if d.err != nil {
return 0, false
}
if d.saved != nil {
d.saved.WriteByte(b)
}
}
if b == '\n' {
d.line++
}
return ... | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"getc",
"(",
")",
"(",
"b",
"byte",
",",
"ok",
"bool",
")",
"{",
"if",
"d",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"if",
"d",
".",
"nextByte",
">=",
"0",
"{",
"b",
... | // Read a single byte.
// If there is no byte to read, return ok==false
// and leave the error in d.err.
// Maintain line number. | [
"Read",
"a",
"single",
"byte",
".",
"If",
"there",
"is",
"no",
"byte",
"to",
"read",
"return",
"ok",
"==",
"false",
"and",
"leave",
"the",
"error",
"in",
"d",
".",
"err",
".",
"Maintain",
"line",
"number",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L847-L867 | train |
vmware/govmomi | vim25/xml/xml.go | readName | func (d *Decoder) readName() (ok bool) {
var b byte
if b, ok = d.mustgetc(); !ok {
return
}
if b < utf8.RuneSelf && !isNameByte(b) {
d.ungetc(b)
return false
}
d.buf.WriteByte(b)
for {
if b, ok = d.mustgetc(); !ok {
return
}
if b < utf8.RuneSelf && !isNameByte(b) {
d.ungetc(b)
break
}
d... | go | func (d *Decoder) readName() (ok bool) {
var b byte
if b, ok = d.mustgetc(); !ok {
return
}
if b < utf8.RuneSelf && !isNameByte(b) {
d.ungetc(b)
return false
}
d.buf.WriteByte(b)
for {
if b, ok = d.mustgetc(); !ok {
return
}
if b < utf8.RuneSelf && !isNameByte(b) {
d.ungetc(b)
break
}
d... | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"readName",
"(",
")",
"(",
"ok",
"bool",
")",
"{",
"var",
"b",
"byte",
"\n",
"if",
"b",
",",
"ok",
"=",
"d",
".",
"mustgetc",
"(",
")",
";",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"if",
"b",
"<",
... | // Read a name and append its bytes to d.buf.
// The name is delimited by any single-byte character not valid in names.
// All multi-byte characters are accepted; the caller must check their validity. | [
"Read",
"a",
"name",
"and",
"append",
"its",
"bytes",
"to",
"d",
".",
"buf",
".",
"The",
"name",
"is",
"delimited",
"by",
"any",
"single",
"-",
"byte",
"character",
"not",
"valid",
"in",
"names",
".",
"All",
"multi",
"-",
"byte",
"characters",
"are",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L1127-L1149 | train |
vmware/govmomi | vim25/xml/xml.go | procInstEncoding | func procInstEncoding(s string) string {
// TODO: this parsing is somewhat lame and not exact.
// It works for all actual cases, though.
idx := strings.Index(s, "encoding=")
if idx == -1 {
return ""
}
v := s[idx+len("encoding="):]
if v == "" {
return ""
}
if v[0] != '\'' && v[0] != '"' {
return ""
}
id... | go | func procInstEncoding(s string) string {
// TODO: this parsing is somewhat lame and not exact.
// It works for all actual cases, though.
idx := strings.Index(s, "encoding=")
if idx == -1 {
return ""
}
v := s[idx+len("encoding="):]
if v == "" {
return ""
}
if v[0] != '\'' && v[0] != '"' {
return ""
}
id... | [
"func",
"procInstEncoding",
"(",
"s",
"string",
")",
"string",
"{",
"// TODO: this parsing is somewhat lame and not exact.",
"// It works for all actual cases, though.",
"idx",
":=",
"strings",
".",
"Index",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"if",
"idx",
"==",
"... | // procInstEncoding parses the `encoding="..."` or `encoding='...'`
// value out of the provided string, returning "" if not found. | [
"procInstEncoding",
"parses",
"the",
"encoding",
"=",
"...",
"or",
"encoding",
"=",
"...",
"value",
"out",
"of",
"the",
"provided",
"string",
"returning",
"if",
"not",
"found",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/xml.go#L1920-L1939 | train |
vmware/govmomi | object/distributed_virtual_portgroup.go | EthernetCardBackingInfo | func (p DistributedVirtualPortgroup) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error) {
var dvp mo.DistributedVirtualPortgroup
var dvs mo.DistributedVirtualSwitch
prop := "config.distributedVirtualSwitch"
if err := p.Properties(ctx, p.Reference(), []string{"key", prop}, &dvp... | go | func (p DistributedVirtualPortgroup) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error) {
var dvp mo.DistributedVirtualPortgroup
var dvs mo.DistributedVirtualSwitch
prop := "config.distributedVirtualSwitch"
if err := p.Properties(ctx, p.Reference(), []string{"key", prop}, &dvp... | [
"func",
"(",
"p",
"DistributedVirtualPortgroup",
")",
"EthernetCardBackingInfo",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"types",
".",
"BaseVirtualDeviceBackingInfo",
",",
"error",
")",
"{",
"var",
"dvp",
"mo",
".",
"DistributedVirtualPortgroup",
"\n",
"v... | // EthernetCardBackingInfo returns the VirtualDeviceBackingInfo for this DistributedVirtualPortgroup | [
"EthernetCardBackingInfo",
"returns",
"the",
"VirtualDeviceBackingInfo",
"for",
"this",
"DistributedVirtualPortgroup"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/distributed_virtual_portgroup.go#L40-L66 | train |
vmware/govmomi | object/host_network_system.go | AddPortGroup | func (o HostNetworkSystem) AddPortGroup(ctx context.Context, portgrp types.HostPortGroupSpec) error {
req := types.AddPortGroup{
This: o.Reference(),
Portgrp: portgrp,
}
_, err := methods.AddPortGroup(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) AddPortGroup(ctx context.Context, portgrp types.HostPortGroupSpec) error {
req := types.AddPortGroup{
This: o.Reference(),
Portgrp: portgrp,
}
_, err := methods.AddPortGroup(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"AddPortGroup",
"(",
"ctx",
"context",
".",
"Context",
",",
"portgrp",
"types",
".",
"HostPortGroupSpec",
")",
"error",
"{",
"req",
":=",
"types",
".",
"AddPortGroup",
"{",
"This",
":",
"o",
".",
"Reference",
"("... | // AddPortGroup wraps methods.AddPortGroup | [
"AddPortGroup",
"wraps",
"methods",
".",
"AddPortGroup"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L38-L50 | train |
vmware/govmomi | object/host_network_system.go | AddServiceConsoleVirtualNic | func (o HostNetworkSystem) AddServiceConsoleVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error) {
req := types.AddServiceConsoleVirtualNic{
This: o.Reference(),
Portgroup: portgroup,
Nic: nic,
}
res, err := methods.AddServiceConsoleVirtualNic(ctx, o.c, &r... | go | func (o HostNetworkSystem) AddServiceConsoleVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error) {
req := types.AddServiceConsoleVirtualNic{
This: o.Reference(),
Portgroup: portgroup,
Nic: nic,
}
res, err := methods.AddServiceConsoleVirtualNic(ctx, o.c, &r... | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"AddServiceConsoleVirtualNic",
"(",
"ctx",
"context",
".",
"Context",
",",
"portgroup",
"string",
",",
"nic",
"types",
".",
"HostVirtualNicSpec",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
":=",
"types",
".... | // AddServiceConsoleVirtualNic wraps methods.AddServiceConsoleVirtualNic | [
"AddServiceConsoleVirtualNic",
"wraps",
"methods",
".",
"AddServiceConsoleVirtualNic"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L53-L66 | train |
vmware/govmomi | object/host_network_system.go | AddVirtualSwitch | func (o HostNetworkSystem) AddVirtualSwitch(ctx context.Context, vswitchName string, spec *types.HostVirtualSwitchSpec) error {
req := types.AddVirtualSwitch{
This: o.Reference(),
VswitchName: vswitchName,
Spec: spec,
}
_, err := methods.AddVirtualSwitch(ctx, o.c, &req)
if err != nil {
return... | go | func (o HostNetworkSystem) AddVirtualSwitch(ctx context.Context, vswitchName string, spec *types.HostVirtualSwitchSpec) error {
req := types.AddVirtualSwitch{
This: o.Reference(),
VswitchName: vswitchName,
Spec: spec,
}
_, err := methods.AddVirtualSwitch(ctx, o.c, &req)
if err != nil {
return... | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"AddVirtualSwitch",
"(",
"ctx",
"context",
".",
"Context",
",",
"vswitchName",
"string",
",",
"spec",
"*",
"types",
".",
"HostVirtualSwitchSpec",
")",
"error",
"{",
"req",
":=",
"types",
".",
"AddVirtualSwitch",
"{",... | // AddVirtualSwitch wraps methods.AddVirtualSwitch | [
"AddVirtualSwitch",
"wraps",
"methods",
".",
"AddVirtualSwitch"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L85-L98 | train |
vmware/govmomi | object/host_network_system.go | QueryNetworkHint | func (o HostNetworkSystem) QueryNetworkHint(ctx context.Context, device []string) error {
req := types.QueryNetworkHint{
This: o.Reference(),
Device: device,
}
_, err := methods.QueryNetworkHint(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) QueryNetworkHint(ctx context.Context, device []string) error {
req := types.QueryNetworkHint{
This: o.Reference(),
Device: device,
}
_, err := methods.QueryNetworkHint(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"QueryNetworkHint",
"(",
"ctx",
"context",
".",
"Context",
",",
"device",
"[",
"]",
"string",
")",
"error",
"{",
"req",
":=",
"types",
".",
"QueryNetworkHint",
"{",
"This",
":",
"o",
".",
"Reference",
"(",
")",... | // QueryNetworkHint wraps methods.QueryNetworkHint | [
"QueryNetworkHint",
"wraps",
"methods",
".",
"QueryNetworkHint"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L101-L113 | train |
vmware/govmomi | object/host_network_system.go | RefreshNetworkSystem | func (o HostNetworkSystem) RefreshNetworkSystem(ctx context.Context) error {
req := types.RefreshNetworkSystem{
This: o.Reference(),
}
_, err := methods.RefreshNetworkSystem(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) RefreshNetworkSystem(ctx context.Context) error {
req := types.RefreshNetworkSystem{
This: o.Reference(),
}
_, err := methods.RefreshNetworkSystem(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"RefreshNetworkSystem",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"req",
":=",
"types",
".",
"RefreshNetworkSystem",
"{",
"This",
":",
"o",
".",
"Reference",
"(",
")",
",",
"}",
"\n\n",
"_",
","... | // RefreshNetworkSystem wraps methods.RefreshNetworkSystem | [
"RefreshNetworkSystem",
"wraps",
"methods",
".",
"RefreshNetworkSystem"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L116-L127 | train |
vmware/govmomi | object/host_network_system.go | RemovePortGroup | func (o HostNetworkSystem) RemovePortGroup(ctx context.Context, pgName string) error {
req := types.RemovePortGroup{
This: o.Reference(),
PgName: pgName,
}
_, err := methods.RemovePortGroup(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) RemovePortGroup(ctx context.Context, pgName string) error {
req := types.RemovePortGroup{
This: o.Reference(),
PgName: pgName,
}
_, err := methods.RemovePortGroup(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"RemovePortGroup",
"(",
"ctx",
"context",
".",
"Context",
",",
"pgName",
"string",
")",
"error",
"{",
"req",
":=",
"types",
".",
"RemovePortGroup",
"{",
"This",
":",
"o",
".",
"Reference",
"(",
")",
",",
"PgNam... | // RemovePortGroup wraps methods.RemovePortGroup | [
"RemovePortGroup",
"wraps",
"methods",
".",
"RemovePortGroup"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L130-L142 | train |
vmware/govmomi | object/host_network_system.go | RemoveVirtualSwitch | func (o HostNetworkSystem) RemoveVirtualSwitch(ctx context.Context, vswitchName string) error {
req := types.RemoveVirtualSwitch{
This: o.Reference(),
VswitchName: vswitchName,
}
_, err := methods.RemoveVirtualSwitch(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) RemoveVirtualSwitch(ctx context.Context, vswitchName string) error {
req := types.RemoveVirtualSwitch{
This: o.Reference(),
VswitchName: vswitchName,
}
_, err := methods.RemoveVirtualSwitch(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"RemoveVirtualSwitch",
"(",
"ctx",
"context",
".",
"Context",
",",
"vswitchName",
"string",
")",
"error",
"{",
"req",
":=",
"types",
".",
"RemoveVirtualSwitch",
"{",
"This",
":",
"o",
".",
"Reference",
"(",
")",
... | // RemoveVirtualSwitch wraps methods.RemoveVirtualSwitch | [
"RemoveVirtualSwitch",
"wraps",
"methods",
".",
"RemoveVirtualSwitch"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L175-L187 | train |
vmware/govmomi | object/host_network_system.go | UpdateConsoleIpRouteConfig | func (o HostNetworkSystem) UpdateConsoleIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error {
req := types.UpdateConsoleIpRouteConfig{
This: o.Reference(),
Config: config,
}
_, err := methods.UpdateConsoleIpRouteConfig(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) UpdateConsoleIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error {
req := types.UpdateConsoleIpRouteConfig{
This: o.Reference(),
Config: config,
}
_, err := methods.UpdateConsoleIpRouteConfig(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"UpdateConsoleIpRouteConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"types",
".",
"BaseHostIpRouteConfig",
")",
"error",
"{",
"req",
":=",
"types",
".",
"UpdateConsoleIpRouteConfig",
"{",
"This",
":",
"... | // UpdateConsoleIpRouteConfig wraps methods.UpdateConsoleIpRouteConfig | [
"UpdateConsoleIpRouteConfig",
"wraps",
"methods",
".",
"UpdateConsoleIpRouteConfig"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L205-L217 | train |
vmware/govmomi | object/host_network_system.go | UpdateNetworkConfig | func (o HostNetworkSystem) UpdateNetworkConfig(ctx context.Context, config types.HostNetworkConfig, changeMode string) (*types.HostNetworkConfigResult, error) {
req := types.UpdateNetworkConfig{
This: o.Reference(),
Config: config,
ChangeMode: changeMode,
}
res, err := methods.UpdateNetworkConfig(ct... | go | func (o HostNetworkSystem) UpdateNetworkConfig(ctx context.Context, config types.HostNetworkConfig, changeMode string) (*types.HostNetworkConfigResult, error) {
req := types.UpdateNetworkConfig{
This: o.Reference(),
Config: config,
ChangeMode: changeMode,
}
res, err := methods.UpdateNetworkConfig(ct... | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"UpdateNetworkConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"types",
".",
"HostNetworkConfig",
",",
"changeMode",
"string",
")",
"(",
"*",
"types",
".",
"HostNetworkConfigResult",
",",
"error",
")",
... | // UpdateNetworkConfig wraps methods.UpdateNetworkConfig | [
"UpdateNetworkConfig",
"wraps",
"methods",
".",
"UpdateNetworkConfig"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L265-L278 | train |
vmware/govmomi | object/host_network_system.go | UpdatePhysicalNicLinkSpeed | func (o HostNetworkSystem) UpdatePhysicalNicLinkSpeed(ctx context.Context, device string, linkSpeed *types.PhysicalNicLinkInfo) error {
req := types.UpdatePhysicalNicLinkSpeed{
This: o.Reference(),
Device: device,
LinkSpeed: linkSpeed,
}
_, err := methods.UpdatePhysicalNicLinkSpeed(ctx, o.c, &req)
if... | go | func (o HostNetworkSystem) UpdatePhysicalNicLinkSpeed(ctx context.Context, device string, linkSpeed *types.PhysicalNicLinkInfo) error {
req := types.UpdatePhysicalNicLinkSpeed{
This: o.Reference(),
Device: device,
LinkSpeed: linkSpeed,
}
_, err := methods.UpdatePhysicalNicLinkSpeed(ctx, o.c, &req)
if... | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"UpdatePhysicalNicLinkSpeed",
"(",
"ctx",
"context",
".",
"Context",
",",
"device",
"string",
",",
"linkSpeed",
"*",
"types",
".",
"PhysicalNicLinkInfo",
")",
"error",
"{",
"req",
":=",
"types",
".",
"UpdatePhysicalNic... | // UpdatePhysicalNicLinkSpeed wraps methods.UpdatePhysicalNicLinkSpeed | [
"UpdatePhysicalNicLinkSpeed",
"wraps",
"methods",
".",
"UpdatePhysicalNicLinkSpeed"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L281-L294 | train |
vmware/govmomi | object/host_network_system.go | UpdatePortGroup | func (o HostNetworkSystem) UpdatePortGroup(ctx context.Context, pgName string, portgrp types.HostPortGroupSpec) error {
req := types.UpdatePortGroup{
This: o.Reference(),
PgName: pgName,
Portgrp: portgrp,
}
_, err := methods.UpdatePortGroup(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) UpdatePortGroup(ctx context.Context, pgName string, portgrp types.HostPortGroupSpec) error {
req := types.UpdatePortGroup{
This: o.Reference(),
PgName: pgName,
Portgrp: portgrp,
}
_, err := methods.UpdatePortGroup(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"UpdatePortGroup",
"(",
"ctx",
"context",
".",
"Context",
",",
"pgName",
"string",
",",
"portgrp",
"types",
".",
"HostPortGroupSpec",
")",
"error",
"{",
"req",
":=",
"types",
".",
"UpdatePortGroup",
"{",
"This",
":... | // UpdatePortGroup wraps methods.UpdatePortGroup | [
"UpdatePortGroup",
"wraps",
"methods",
".",
"UpdatePortGroup"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L297-L310 | train |
vmware/govmomi | object/host_network_system.go | UpdateVirtualNic | func (o HostNetworkSystem) UpdateVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error {
req := types.UpdateVirtualNic{
This: o.Reference(),
Device: device,
Nic: nic,
}
_, err := methods.UpdateVirtualNic(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | go | func (o HostNetworkSystem) UpdateVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error {
req := types.UpdateVirtualNic{
This: o.Reference(),
Device: device,
Nic: nic,
}
_, err := methods.UpdateVirtualNic(ctx, o.c, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"o",
"HostNetworkSystem",
")",
"UpdateVirtualNic",
"(",
"ctx",
"context",
".",
"Context",
",",
"device",
"string",
",",
"nic",
"types",
".",
"HostVirtualNicSpec",
")",
"error",
"{",
"req",
":=",
"types",
".",
"UpdateVirtualNic",
"{",
"This",
":"... | // UpdateVirtualNic wraps methods.UpdateVirtualNic | [
"UpdateVirtualNic",
"wraps",
"methods",
".",
"UpdateVirtualNic"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/object/host_network_system.go#L329-L342 | train |
vmware/govmomi | view/task_view.go | CreateTaskView | func (m Manager) CreateTaskView(ctx context.Context, watch *types.ManagedObjectReference) (*TaskView, error) {
l, err := m.CreateListView(ctx, nil)
if err != nil {
return nil, err
}
tv := &TaskView{
ListView: l,
Watch: watch,
}
return tv, nil
} | go | func (m Manager) CreateTaskView(ctx context.Context, watch *types.ManagedObjectReference) (*TaskView, error) {
l, err := m.CreateListView(ctx, nil)
if err != nil {
return nil, err
}
tv := &TaskView{
ListView: l,
Watch: watch,
}
return tv, nil
} | [
"func",
"(",
"m",
"Manager",
")",
"CreateTaskView",
"(",
"ctx",
"context",
".",
"Context",
",",
"watch",
"*",
"types",
".",
"ManagedObjectReference",
")",
"(",
"*",
"TaskView",
",",
"error",
")",
"{",
"l",
",",
"err",
":=",
"m",
".",
"CreateListView",
... | // CreateTaskView creates a new ListView that optionally watches for a ManagedEntity's recentTask updates. | [
"CreateTaskView",
"creates",
"a",
"new",
"ListView",
"that",
"optionally",
"watches",
"for",
"a",
"ManagedEntity",
"s",
"recentTask",
"updates",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/view/task_view.go#L36-L48 | train |
vmware/govmomi | view/task_view.go | Collect | func (v TaskView) Collect(ctx context.Context, f func([]types.TaskInfo)) error {
// Using TaskHistoryCollector would be less clunky, but it isn't supported on ESX at all.
ref := v.Reference()
filter := new(property.WaitFilter).Add(ref, "Task", []string{"info"}, v.TraversalSpec())
if v.Watch != nil {
filter.Add(*... | go | func (v TaskView) Collect(ctx context.Context, f func([]types.TaskInfo)) error {
// Using TaskHistoryCollector would be less clunky, but it isn't supported on ESX at all.
ref := v.Reference()
filter := new(property.WaitFilter).Add(ref, "Task", []string{"info"}, v.TraversalSpec())
if v.Watch != nil {
filter.Add(*... | [
"func",
"(",
"v",
"TaskView",
")",
"Collect",
"(",
"ctx",
"context",
".",
"Context",
",",
"f",
"func",
"(",
"[",
"]",
"types",
".",
"TaskInfo",
")",
")",
"error",
"{",
"// Using TaskHistoryCollector would be less clunky, but it isn't supported on ESX at all.",
"ref"... | // Collect calls function f for each Task update. | [
"Collect",
"calls",
"function",
"f",
"for",
"each",
"Task",
"update",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/view/task_view.go#L51-L125 | train |
vmware/govmomi | vapi/vcenter/vcenter_ovf.go | DeployLibraryItem | func (c *Manager) DeployLibraryItem(ctx context.Context, libraryItemID string, deploy Deploy) (Deployment, error) {
url := internal.URL(c, internal.VCenterOVFLibraryItem).WithID(libraryItemID).WithAction("deploy")
var res Deployment
return res, c.Do(ctx, url.Request(http.MethodPost, deploy), &res)
} | go | func (c *Manager) DeployLibraryItem(ctx context.Context, libraryItemID string, deploy Deploy) (Deployment, error) {
url := internal.URL(c, internal.VCenterOVFLibraryItem).WithID(libraryItemID).WithAction("deploy")
var res Deployment
return res, c.Do(ctx, url.Request(http.MethodPost, deploy), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"DeployLibraryItem",
"(",
"ctx",
"context",
".",
"Context",
",",
"libraryItemID",
"string",
",",
"deploy",
"Deploy",
")",
"(",
"Deployment",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
"... | // DeployLibraryItem deploys a library OVF | [
"DeployLibraryItem",
"deploys",
"a",
"library",
"OVF"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/vcenter/vcenter_ovf.go#L141-L145 | train |
vmware/govmomi | vapi/vcenter/vcenter_ovf.go | FilterLibraryItem | func (c *Manager) FilterLibraryItem(ctx context.Context, libraryItemID string, filter FilterRequest) (FilterResponse, error) {
url := internal.URL(c, internal.VCenterOVFLibraryItem).WithID(libraryItemID).WithAction("filter")
var res FilterResponse
return res, c.Do(ctx, url.Request(http.MethodPost, filter), &res)
} | go | func (c *Manager) FilterLibraryItem(ctx context.Context, libraryItemID string, filter FilterRequest) (FilterResponse, error) {
url := internal.URL(c, internal.VCenterOVFLibraryItem).WithID(libraryItemID).WithAction("filter")
var res FilterResponse
return res, c.Do(ctx, url.Request(http.MethodPost, filter), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"FilterLibraryItem",
"(",
"ctx",
"context",
".",
"Context",
",",
"libraryItemID",
"string",
",",
"filter",
"FilterRequest",
")",
"(",
"FilterResponse",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",... | // FilterLibraryItem deploys a library OVF | [
"FilterLibraryItem",
"deploys",
"a",
"library",
"OVF"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/vcenter/vcenter_ovf.go#L148-L152 | train |
vmware/govmomi | vapi/rest/client.go | NewClient | func NewClient(c *vim25.Client) *Client {
sc := c.Client.NewServiceClient(internal.Path, "")
return &Client{sc}
} | go | func NewClient(c *vim25.Client) *Client {
sc := c.Client.NewServiceClient(internal.Path, "")
return &Client{sc}
} | [
"func",
"NewClient",
"(",
"c",
"*",
"vim25",
".",
"Client",
")",
"*",
"Client",
"{",
"sc",
":=",
"c",
".",
"Client",
".",
"NewServiceClient",
"(",
"internal",
".",
"Path",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"&",
"Client",
"{",
"sc",
"}",
"\n",... | // NewClient creates a new Client instance. | [
"NewClient",
"creates",
"a",
"new",
"Client",
"instance",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/rest/client.go#L40-L44 | train |
vmware/govmomi | vapi/rest/client.go | Do | func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{}) error {
switch req.Method {
case http.MethodPost, http.MethodPatch:
req.Header.Set("Content-Type", "application/json")
}
req.Header.Set("Accept", "application/json")
if s, ok := ctx.Value(signerContext{}).(Signer); ok {
if err :... | go | func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{}) error {
switch req.Method {
case http.MethodPost, http.MethodPatch:
req.Header.Set("Content-Type", "application/json")
}
req.Header.Set("Accept", "application/json")
if s, ok := ctx.Value(signerContext{}).(Signer); ok {
if err :... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"http",
".",
"Request",
",",
"resBody",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"req",
".",
"Method",
"{",
"case",
"http",
".",
"MethodP... | // Do sends the http.Request, decoding resBody if provided. | [
"Do",
"sends",
"the",
"http",
".",
"Request",
"decoding",
"resBody",
"if",
"provided",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/rest/client.go#L57-L102 | train |
vmware/govmomi | vapi/rest/client.go | Login | func (c *Client) Login(ctx context.Context, user *url.Userinfo) error {
req := internal.URL(c, internal.SessionPath).Request(http.MethodPost)
if user != nil {
if password, ok := user.Password(); ok {
req.SetBasicAuth(user.Username(), password)
}
}
return c.Do(ctx, req, nil)
} | go | func (c *Client) Login(ctx context.Context, user *url.Userinfo) error {
req := internal.URL(c, internal.SessionPath).Request(http.MethodPost)
if user != nil {
if password, ok := user.Password(); ok {
req.SetBasicAuth(user.Username(), password)
}
}
return c.Do(ctx, req, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Login",
"(",
"ctx",
"context",
".",
"Context",
",",
"user",
"*",
"url",
".",
"Userinfo",
")",
"error",
"{",
"req",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"SessionPath",
")",
".",
"Reques... | // Login creates a new session via Basic Authentication with the given url.Userinfo. | [
"Login",
"creates",
"a",
"new",
"session",
"via",
"Basic",
"Authentication",
"with",
"the",
"given",
"url",
".",
"Userinfo",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/rest/client.go#L105-L115 | train |
vmware/govmomi | vapi/rest/client.go | Logout | func (c *Client) Logout(ctx context.Context) error {
req := internal.URL(c, internal.SessionPath).Request(http.MethodDelete)
return c.Do(ctx, req, nil)
} | go | func (c *Client) Logout(ctx context.Context) error {
req := internal.URL(c, internal.SessionPath).Request(http.MethodDelete)
return c.Do(ctx, req, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Logout",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"req",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"SessionPath",
")",
".",
"Request",
"(",
"http",
".",
"MethodDelete",
")",
... | // Logout deletes the current session. | [
"Logout",
"deletes",
"the",
"current",
"session",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/rest/client.go#L122-L125 | train |
vmware/govmomi | lookup/client.go | NewClient | func NewClient(ctx context.Context, c *vim25.Client) (*Client, error) {
sc := c.Client.NewServiceClient(Path, Namespace)
sc.Version = Version
req := types.RetrieveServiceContent{
This: ServiceInstance,
}
res, err := methods.RetrieveServiceContent(ctx, sc, &req)
if err != nil {
return nil, err
}
return &C... | go | func NewClient(ctx context.Context, c *vim25.Client) (*Client, error) {
sc := c.Client.NewServiceClient(Path, Namespace)
sc.Version = Version
req := types.RetrieveServiceContent{
This: ServiceInstance,
}
res, err := methods.RetrieveServiceContent(ctx, sc, &req)
if err != nil {
return nil, err
}
return &C... | [
"func",
"NewClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"vim25",
".",
"Client",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"sc",
":=",
"c",
".",
"Client",
".",
"NewServiceClient",
"(",
"Path",
",",
"Namespace",
")",
"\n",
"... | // NewClient returns a client targeting the SSO Lookup Service API endpoint. | [
"NewClient",
"returns",
"a",
"client",
"targeting",
"the",
"SSO",
"Lookup",
"Service",
"API",
"endpoint",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/lookup/client.go#L54-L68 | train |
vmware/govmomi | lookup/client.go | EndpointURL | func EndpointURL(ctx context.Context, c *vim25.Client, path string, filter *types.LookupServiceRegistrationFilter) string {
if lu, err := NewClient(ctx, c); err == nil {
info, _ := lu.List(ctx, filter)
if len(info) != 0 && len(info[0].ServiceEndpoints) != 0 {
endpoint := &info[0].ServiceEndpoints[0]
path = e... | go | func EndpointURL(ctx context.Context, c *vim25.Client, path string, filter *types.LookupServiceRegistrationFilter) string {
if lu, err := NewClient(ctx, c); err == nil {
info, _ := lu.List(ctx, filter)
if len(info) != 0 && len(info[0].ServiceEndpoints) != 0 {
endpoint := &info[0].ServiceEndpoints[0]
path = e... | [
"func",
"EndpointURL",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"vim25",
".",
"Client",
",",
"path",
"string",
",",
"filter",
"*",
"types",
".",
"LookupServiceRegistrationFilter",
")",
"string",
"{",
"if",
"lu",
",",
"err",
":=",
"NewClient",
... | // EndpointURL uses the Lookup Service to find the endpoint URL and thumbprint for the given filter.
// If the endpoint is found, its TLS certificate is also added to the vim25.Client's trusted host thumbprints.
// If the Lookup Service is not available, the given path is returned as the default. | [
"EndpointURL",
"uses",
"the",
"Lookup",
"Service",
"to",
"find",
"the",
"endpoint",
"URL",
"and",
"thumbprint",
"for",
"the",
"given",
"filter",
".",
"If",
"the",
"endpoint",
"is",
"found",
"its",
"TLS",
"certificate",
"is",
"also",
"added",
"to",
"the",
"... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/lookup/client.go#L98-L113 | train |
vmware/govmomi | lookup/client.go | endpointThumbprint | func endpointThumbprint(endpoint *types.LookupServiceRegistrationEndpoint) string {
if len(endpoint.SslTrust) == 0 {
return ""
}
enc := endpoint.SslTrust[0]
b, err := base64.StdEncoding.DecodeString(enc)
if err != nil {
log.Printf("base64.Decode(%q): %s", enc, err)
return ""
}
cert, err := x509.ParseCert... | go | func endpointThumbprint(endpoint *types.LookupServiceRegistrationEndpoint) string {
if len(endpoint.SslTrust) == 0 {
return ""
}
enc := endpoint.SslTrust[0]
b, err := base64.StdEncoding.DecodeString(enc)
if err != nil {
log.Printf("base64.Decode(%q): %s", enc, err)
return ""
}
cert, err := x509.ParseCert... | [
"func",
"endpointThumbprint",
"(",
"endpoint",
"*",
"types",
".",
"LookupServiceRegistrationEndpoint",
")",
"string",
"{",
"if",
"len",
"(",
"endpoint",
".",
"SslTrust",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"enc",
":=",
"endpoint",
"... | // endpointThumbprint converts the base64 encoded endpoint certificate to a SHA1 thumbprint. | [
"endpointThumbprint",
"converts",
"the",
"base64",
"encoded",
"endpoint",
"certificate",
"to",
"a",
"SHA1",
"thumbprint",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/lookup/client.go#L116-L135 | train |
vmware/govmomi | ovf/manager.go | CreateDescriptor | func (m *Manager) CreateDescriptor(ctx context.Context, obj mo.Reference, cdp types.OvfCreateDescriptorParams) (*types.OvfCreateDescriptorResult, error) {
req := types.CreateDescriptor{
This: m.Reference(),
Obj: obj.Reference(),
Cdp: cdp,
}
res, err := methods.CreateDescriptor(ctx, m.c, &req)
if err != nil... | go | func (m *Manager) CreateDescriptor(ctx context.Context, obj mo.Reference, cdp types.OvfCreateDescriptorParams) (*types.OvfCreateDescriptorResult, error) {
req := types.CreateDescriptor{
This: m.Reference(),
Obj: obj.Reference(),
Cdp: cdp,
}
res, err := methods.CreateDescriptor(ctx, m.c, &req)
if err != nil... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"CreateDescriptor",
"(",
"ctx",
"context",
".",
"Context",
",",
"obj",
"mo",
".",
"Reference",
",",
"cdp",
"types",
".",
"OvfCreateDescriptorParams",
")",
"(",
"*",
"types",
".",
"OvfCreateDescriptorResult",
",",
"error... | // CreateDescriptor wraps methods.CreateDescriptor | [
"CreateDescriptor",
"wraps",
"methods",
".",
"CreateDescriptor"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/ovf/manager.go#L39-L52 | train |
vmware/govmomi | ovf/manager.go | CreateImportSpec | func (m *Manager) CreateImportSpec(ctx context.Context, ovfDescriptor string, resourcePool mo.Reference, datastore mo.Reference, cisp types.OvfCreateImportSpecParams) (*types.OvfCreateImportSpecResult, error) {
req := types.CreateImportSpec{
This: m.Reference(),
OvfDescriptor: ovfDescriptor,
ResourcePoo... | go | func (m *Manager) CreateImportSpec(ctx context.Context, ovfDescriptor string, resourcePool mo.Reference, datastore mo.Reference, cisp types.OvfCreateImportSpecParams) (*types.OvfCreateImportSpecResult, error) {
req := types.CreateImportSpec{
This: m.Reference(),
OvfDescriptor: ovfDescriptor,
ResourcePoo... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"CreateImportSpec",
"(",
"ctx",
"context",
".",
"Context",
",",
"ovfDescriptor",
"string",
",",
"resourcePool",
"mo",
".",
"Reference",
",",
"datastore",
"mo",
".",
"Reference",
",",
"cisp",
"types",
".",
"OvfCreateImpo... | // CreateImportSpec wraps methods.CreateImportSpec | [
"CreateImportSpec",
"wraps",
"methods",
".",
"CreateImportSpec"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/ovf/manager.go#L55-L70 | train |
vmware/govmomi | ovf/manager.go | ParseDescriptor | func (m *Manager) ParseDescriptor(ctx context.Context, ovfDescriptor string, pdp types.OvfParseDescriptorParams) (*types.OvfParseDescriptorResult, error) {
req := types.ParseDescriptor{
This: m.Reference(),
OvfDescriptor: ovfDescriptor,
Pdp: pdp,
}
res, err := methods.ParseDescriptor(ctx, m... | go | func (m *Manager) ParseDescriptor(ctx context.Context, ovfDescriptor string, pdp types.OvfParseDescriptorParams) (*types.OvfParseDescriptorResult, error) {
req := types.ParseDescriptor{
This: m.Reference(),
OvfDescriptor: ovfDescriptor,
Pdp: pdp,
}
res, err := methods.ParseDescriptor(ctx, m... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ParseDescriptor",
"(",
"ctx",
"context",
".",
"Context",
",",
"ovfDescriptor",
"string",
",",
"pdp",
"types",
".",
"OvfParseDescriptorParams",
")",
"(",
"*",
"types",
".",
"OvfParseDescriptorResult",
",",
"error",
")",
... | // ParseDescriptor wraps methods.ParseDescriptor | [
"ParseDescriptor",
"wraps",
"methods",
".",
"ParseDescriptor"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/ovf/manager.go#L73-L86 | train |
vmware/govmomi | ovf/manager.go | ValidateHost | func (m *Manager) ValidateHost(ctx context.Context, ovfDescriptor string, host mo.Reference, vhp types.OvfValidateHostParams) (*types.OvfValidateHostResult, error) {
req := types.ValidateHost{
This: m.Reference(),
OvfDescriptor: ovfDescriptor,
Host: host.Reference(),
Vhp: vhp,
}
... | go | func (m *Manager) ValidateHost(ctx context.Context, ovfDescriptor string, host mo.Reference, vhp types.OvfValidateHostParams) (*types.OvfValidateHostResult, error) {
req := types.ValidateHost{
This: m.Reference(),
OvfDescriptor: ovfDescriptor,
Host: host.Reference(),
Vhp: vhp,
}
... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ValidateHost",
"(",
"ctx",
"context",
".",
"Context",
",",
"ovfDescriptor",
"string",
",",
"host",
"mo",
".",
"Reference",
",",
"vhp",
"types",
".",
"OvfValidateHostParams",
")",
"(",
"*",
"types",
".",
"OvfValidateH... | // ValidateHost wraps methods.ValidateHost | [
"ValidateHost",
"wraps",
"methods",
".",
"ValidateHost"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/ovf/manager.go#L89-L103 | train |
vmware/govmomi | vapi/library/library_item.go | CreateLibraryItem | func (c *Manager) CreateLibraryItem(ctx context.Context, item Item) (string, error) {
type createItemSpec struct {
Name string `json:"name"`
Description string `json:"description"`
LibraryID string `json:"library_id,omitempty"`
Type string `json:"type"`
}
spec := struct {
Item createItemSpe... | go | func (c *Manager) CreateLibraryItem(ctx context.Context, item Item) (string, error) {
type createItemSpec struct {
Name string `json:"name"`
Description string `json:"description"`
LibraryID string `json:"library_id,omitempty"`
Type string `json:"type"`
}
spec := struct {
Item createItemSpe... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"CreateLibraryItem",
"(",
"ctx",
"context",
".",
"Context",
",",
"item",
"Item",
")",
"(",
"string",
",",
"error",
")",
"{",
"type",
"createItemSpec",
"struct",
"{",
"Name",
"string",
"`json:\"name\"`",
"\n",
"Descrip... | // CreateLibraryItem creates a new library item | [
"CreateLibraryItem",
"creates",
"a",
"new",
"library",
"item"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item.go#L62-L82 | train |
vmware/govmomi | vapi/library/library_item.go | DeleteLibraryItem | func (c *Manager) DeleteLibraryItem(ctx context.Context, item *Item) error {
url := internal.URL(c, internal.LibraryItemPath).WithID(item.ID)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | go | func (c *Manager) DeleteLibraryItem(ctx context.Context, item *Item) error {
url := internal.URL(c, internal.LibraryItemPath).WithID(item.ID)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"DeleteLibraryItem",
"(",
"ctx",
"context",
".",
"Context",
",",
"item",
"*",
"Item",
")",
"error",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"LibraryItemPath",
")",
".",
"WithID",
... | // DeleteLibraryItem deletes an existing library item. | [
"DeleteLibraryItem",
"deletes",
"an",
"existing",
"library",
"item",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item.go#L85-L88 | train |
vmware/govmomi | vapi/library/library_item.go | ListLibraryItems | func (c *Manager) ListLibraryItems(ctx context.Context, id string) ([]string, error) {
url := internal.URL(c, internal.LibraryItemPath).WithParameter("library_id", id)
var res []string
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | func (c *Manager) ListLibraryItems(ctx context.Context, id string) ([]string, error) {
url := internal.URL(c, internal.LibraryItemPath).WithParameter("library_id", id)
var res []string
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"ListLibraryItems",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"Libra... | // ListLibraryItems returns a list of all items in a content library. | [
"ListLibraryItems",
"returns",
"a",
"list",
"of",
"all",
"items",
"in",
"a",
"content",
"library",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item.go#L91-L95 | train |
vmware/govmomi | vapi/library/library_item.go | GetLibraryItem | func (c *Manager) GetLibraryItem(ctx context.Context, id string) (*Item, error) {
url := internal.URL(c, internal.LibraryItemPath).WithID(id)
var res Item
return &res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | func (c *Manager) GetLibraryItem(ctx context.Context, id string) (*Item, error) {
url := internal.URL(c, internal.LibraryItemPath).WithID(id)
var res Item
return &res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetLibraryItem",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"*",
"Item",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
"LibraryItemPath"... | // GetLibraryItem returns information on a library item for the given ID. | [
"GetLibraryItem",
"returns",
"information",
"on",
"a",
"library",
"item",
"for",
"the",
"given",
"ID",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item.go#L98-L102 | train |
vmware/govmomi | vapi/library/library_item.go | GetLibraryItems | func (c *Manager) GetLibraryItems(ctx context.Context, libraryID string) ([]Item, error) {
ids, err := c.ListLibraryItems(ctx, libraryID)
if err != nil {
return nil, fmt.Errorf("get library items failed for: %s", err)
}
var items []Item
for _, id := range ids {
item, err := c.GetLibraryItem(ctx, id)
if err !... | go | func (c *Manager) GetLibraryItems(ctx context.Context, libraryID string) ([]Item, error) {
ids, err := c.ListLibraryItems(ctx, libraryID)
if err != nil {
return nil, fmt.Errorf("get library items failed for: %s", err)
}
var items []Item
for _, id := range ids {
item, err := c.GetLibraryItem(ctx, id)
if err !... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetLibraryItems",
"(",
"ctx",
"context",
".",
"Context",
",",
"libraryID",
"string",
")",
"(",
"[",
"]",
"Item",
",",
"error",
")",
"{",
"ids",
",",
"err",
":=",
"c",
".",
"ListLibraryItems",
"(",
"ctx",
",",
... | // GetLibraryItems returns a list of all the library items for the specified library. | [
"GetLibraryItems",
"returns",
"a",
"list",
"of",
"all",
"the",
"library",
"items",
"for",
"the",
"specified",
"library",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item.go#L105-L119 | train |
vmware/govmomi | vapi/library/library_item.go | FindLibraryItems | func (c *Manager) FindLibraryItems(
ctx context.Context, search FindItem) ([]string, error) {
url := internal.URL(c, internal.LibraryItemPath).WithAction("find")
spec := struct {
Spec FindItem `json:"spec"`
}{search}
var res []string
return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
} | go | func (c *Manager) FindLibraryItems(
ctx context.Context, search FindItem) ([]string, error) {
url := internal.URL(c, internal.LibraryItemPath).WithAction("find")
spec := struct {
Spec FindItem `json:"spec"`
}{search}
var res []string
return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"FindLibraryItems",
"(",
"ctx",
"context",
".",
"Context",
",",
"search",
"FindItem",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"url",
":=",
"internal",
".",
"URL",
"(",
"c",
",",
"internal",
".",
... | // FindLibraryItems returns the IDs of all the library items that match the
// search criteria. | [
"FindLibraryItems",
"returns",
"the",
"IDs",
"of",
"all",
"the",
"library",
"items",
"that",
"match",
"the",
"search",
"criteria",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/library/library_item.go#L132-L141 | train |
vmware/govmomi | govc/host/esxcli/firewall_info.go | GetFirewallInfo | func GetFirewallInfo(s *object.HostSystem) (*FirewallInfo, error) {
x, err := NewExecutor(s.Client(), s)
if err != nil {
return nil, err
}
res, err := x.Run([]string{"network", "firewall", "get"})
if err != nil {
return nil, err
}
info := &FirewallInfo{
Loaded: res.Values[0]["Loaded"][0] == "true"... | go | func GetFirewallInfo(s *object.HostSystem) (*FirewallInfo, error) {
x, err := NewExecutor(s.Client(), s)
if err != nil {
return nil, err
}
res, err := x.Run([]string{"network", "firewall", "get"})
if err != nil {
return nil, err
}
info := &FirewallInfo{
Loaded: res.Values[0]["Loaded"][0] == "true"... | [
"func",
"GetFirewallInfo",
"(",
"s",
"*",
"object",
".",
"HostSystem",
")",
"(",
"*",
"FirewallInfo",
",",
"error",
")",
"{",
"x",
",",
"err",
":=",
"NewExecutor",
"(",
"s",
".",
"Client",
"(",
")",
",",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // GetFirewallInfo via 'esxcli network firewall get'
// The HostFirewallSystem type does not expose this data.
// This helper can be useful in particular to determine if the firewall is enabled or disabled. | [
"GetFirewallInfo",
"via",
"esxcli",
"network",
"firewall",
"get",
"The",
"HostFirewallSystem",
"type",
"does",
"not",
"expose",
"this",
"data",
".",
"This",
"helper",
"can",
"be",
"useful",
"in",
"particular",
"to",
"determine",
"if",
"the",
"firewall",
"is",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/host/esxcli/firewall_info.go#L30-L48 | train |
vmware/govmomi | session/keep_alive.go | KeepAlive | func KeepAlive(roundTripper soap.RoundTripper, idleTime time.Duration) soap.RoundTripper {
return KeepAliveHandler(roundTripper, idleTime, defaultKeepAlive)
} | go | func KeepAlive(roundTripper soap.RoundTripper, idleTime time.Duration) soap.RoundTripper {
return KeepAliveHandler(roundTripper, idleTime, defaultKeepAlive)
} | [
"func",
"KeepAlive",
"(",
"roundTripper",
"soap",
".",
"RoundTripper",
",",
"idleTime",
"time",
".",
"Duration",
")",
"soap",
".",
"RoundTripper",
"{",
"return",
"KeepAliveHandler",
"(",
"roundTripper",
",",
"idleTime",
",",
"defaultKeepAlive",
")",
"\n",
"}"
] | // KeepAlive wraps the specified soap.RoundTripper and executes a meaningless
// API request in the background after the RoundTripper has been idle for the
// specified amount of idle time. The keep alive process only starts once a
// user logs in and runs until the user logs out again. | [
"KeepAlive",
"wraps",
"the",
"specified",
"soap",
".",
"RoundTripper",
"and",
"executes",
"a",
"meaningless",
"API",
"request",
"in",
"the",
"background",
"after",
"the",
"RoundTripper",
"has",
"been",
"idle",
"for",
"the",
"specified",
"amount",
"of",
"idle",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/session/keep_alive.go#L51-L53 | train |
vmware/govmomi | vapi/tags/tag_association.go | AttachTag | func (c *Manager) AttachTag(ctx context.Context, tagID string, ref mo.Reference) error {
id, err := c.tagID(ctx, tagID)
if err != nil {
return err
}
spec := internal.NewAssociation(ref)
url := internal.URL(c, internal.AssociationPath).WithID(id).WithAction("attach")
return c.Do(ctx, url.Request(http.MethodPost,... | go | func (c *Manager) AttachTag(ctx context.Context, tagID string, ref mo.Reference) error {
id, err := c.tagID(ctx, tagID)
if err != nil {
return err
}
spec := internal.NewAssociation(ref)
url := internal.URL(c, internal.AssociationPath).WithID(id).WithAction("attach")
return c.Do(ctx, url.Request(http.MethodPost,... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"AttachTag",
"(",
"ctx",
"context",
".",
"Context",
",",
"tagID",
"string",
",",
"ref",
"mo",
".",
"Reference",
")",
"error",
"{",
"id",
",",
"err",
":=",
"c",
".",
"tagID",
"(",
"ctx",
",",
"tagID",
")",
"\... | // AttachTag attaches a tag ID to a managed object. | [
"AttachTag",
"attaches",
"a",
"tag",
"ID",
"to",
"a",
"managed",
"object",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/tag_association.go#L40-L48 | train |
vmware/govmomi | vapi/tags/tag_association.go | ListAttachedTags | func (c *Manager) ListAttachedTags(ctx context.Context, ref mo.Reference) ([]string, error) {
spec := internal.NewAssociation(ref)
url := internal.URL(c, internal.AssociationPath).WithAction("list-attached-tags")
var res []string
return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
} | go | func (c *Manager) ListAttachedTags(ctx context.Context, ref mo.Reference) ([]string, error) {
spec := internal.NewAssociation(ref)
url := internal.URL(c, internal.AssociationPath).WithAction("list-attached-tags")
var res []string
return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
} | [
"func",
"(",
"c",
"*",
"Manager",
")",
"ListAttachedTags",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"mo",
".",
"Reference",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"spec",
":=",
"internal",
".",
"NewAssociation",
"(",
"ref",
"... | // ListAttachedTags fetches the array of tag IDs attached to the given object. | [
"ListAttachedTags",
"fetches",
"the",
"array",
"of",
"tag",
"IDs",
"attached",
"to",
"the",
"given",
"object",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/tag_association.go#L63-L68 | train |
vmware/govmomi | vapi/tags/tag_association.go | GetAttachedTags | func (c *Manager) GetAttachedTags(ctx context.Context, ref mo.Reference) ([]Tag, error) {
ids, err := c.ListAttachedTags(ctx, ref)
if err != nil {
return nil, fmt.Errorf("get attached tags %s: %s", ref, err)
}
var info []Tag
for _, id := range ids {
tag, err := c.GetTag(ctx, id)
if err != nil {
return ni... | go | func (c *Manager) GetAttachedTags(ctx context.Context, ref mo.Reference) ([]Tag, error) {
ids, err := c.ListAttachedTags(ctx, ref)
if err != nil {
return nil, fmt.Errorf("get attached tags %s: %s", ref, err)
}
var info []Tag
for _, id := range ids {
tag, err := c.GetTag(ctx, id)
if err != nil {
return ni... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"GetAttachedTags",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"mo",
".",
"Reference",
")",
"(",
"[",
"]",
"Tag",
",",
"error",
")",
"{",
"ids",
",",
"err",
":=",
"c",
".",
"ListAttachedTags",
"(",
"ctx... | // GetAttachedTags fetches the array of tags attached to the given object. | [
"GetAttachedTags",
"fetches",
"the",
"array",
"of",
"tags",
"attached",
"to",
"the",
"given",
"object",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/tag_association.go#L71-L86 | train |
vmware/govmomi | vapi/tags/tag_association.go | ListAttachedObjects | func (c *Manager) ListAttachedObjects(ctx context.Context, tagID string) ([]mo.Reference, error) {
id, err := c.tagID(ctx, tagID)
if err != nil {
return nil, err
}
url := internal.URL(c, internal.AssociationPath).WithID(id).WithAction("list-attached-objects")
var res []internal.AssociatedObject
if err := c.Do(c... | go | func (c *Manager) ListAttachedObjects(ctx context.Context, tagID string) ([]mo.Reference, error) {
id, err := c.tagID(ctx, tagID)
if err != nil {
return nil, err
}
url := internal.URL(c, internal.AssociationPath).WithID(id).WithAction("list-attached-objects")
var res []internal.AssociatedObject
if err := c.Do(c... | [
"func",
"(",
"c",
"*",
"Manager",
")",
"ListAttachedObjects",
"(",
"ctx",
"context",
".",
"Context",
",",
"tagID",
"string",
")",
"(",
"[",
"]",
"mo",
".",
"Reference",
",",
"error",
")",
"{",
"id",
",",
"err",
":=",
"c",
".",
"tagID",
"(",
"ctx",
... | // ListAttachedObjects fetches the array of attached objects for the given tag ID. | [
"ListAttachedObjects",
"fetches",
"the",
"array",
"of",
"attached",
"objects",
"for",
"the",
"given",
"tag",
"ID",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vapi/tags/tag_association.go#L89-L105 | train |
vmware/govmomi | toolbox/channel.go | Request | func (c *ChannelOut) Request(request []byte) ([]byte, error) {
if err := c.Send(request); err != nil {
return nil, err
}
reply, err := c.Receive()
if err != nil {
return nil, err
}
if bytes.HasPrefix(reply, rpciOK) {
return reply[2:], nil
}
return nil, fmt.Errorf("request %q: %q", request, reply)
} | go | func (c *ChannelOut) Request(request []byte) ([]byte, error) {
if err := c.Send(request); err != nil {
return nil, err
}
reply, err := c.Receive()
if err != nil {
return nil, err
}
if bytes.HasPrefix(reply, rpciOK) {
return reply[2:], nil
}
return nil, fmt.Errorf("request %q: %q", request, reply)
} | [
"func",
"(",
"c",
"*",
"ChannelOut",
")",
"Request",
"(",
"request",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"Send",
"(",
"request",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // Request sends an RPC command to the vmx and checks the return code for success or error | [
"Request",
"sends",
"an",
"RPC",
"command",
"to",
"the",
"vmx",
"and",
"checks",
"the",
"return",
"code",
"for",
"success",
"or",
"error"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/toolbox/channel.go#L43-L58 | train |
vmware/govmomi | find/finder.go | datacenterPath | func (f *Finder) datacenterPath(ctx context.Context, ref types.ManagedObjectReference) (string, error) {
mes, err := mo.Ancestors(ctx, f.client, f.client.ServiceContent.PropertyCollector, ref)
if err != nil {
return "", err
}
// Chop leaves under the Datacenter
for i := len(mes) - 1; i > 0; i-- {
if mes[i].Se... | go | func (f *Finder) datacenterPath(ctx context.Context, ref types.ManagedObjectReference) (string, error) {
mes, err := mo.Ancestors(ctx, f.client, f.client.ServiceContent.PropertyCollector, ref)
if err != nil {
return "", err
}
// Chop leaves under the Datacenter
for i := len(mes) - 1; i > 0; i-- {
if mes[i].Se... | [
"func",
"(",
"f",
"*",
"Finder",
")",
"datacenterPath",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"types",
".",
"ManagedObjectReference",
")",
"(",
"string",
",",
"error",
")",
"{",
"mes",
",",
"err",
":=",
"mo",
".",
"Ancestors",
"(",
"ctx",
... | // datacenterPath returns the absolute path to the Datacenter containing the given ref | [
"datacenterPath",
"returns",
"the",
"absolute",
"path",
"to",
"the",
"Datacenter",
"containing",
"the",
"given",
"ref"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/find/finder.go#L152-L178 | train |
vmware/govmomi | find/finder.go | Element | func (f *Finder) Element(ctx context.Context, ref types.ManagedObjectReference) (*list.Element, error) {
rl := func(_ context.Context) (object.Reference, error) {
return ref, nil
}
s := &spec{
Relative: rl,
}
e, err := f.find(ctx, "./", s)
if err != nil {
return nil, err
}
if len(e) == 0 {
return nil... | go | func (f *Finder) Element(ctx context.Context, ref types.ManagedObjectReference) (*list.Element, error) {
rl := func(_ context.Context) (object.Reference, error) {
return ref, nil
}
s := &spec{
Relative: rl,
}
e, err := f.find(ctx, "./", s)
if err != nil {
return nil, err
}
if len(e) == 0 {
return nil... | [
"func",
"(",
"f",
"*",
"Finder",
")",
"Element",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"types",
".",
"ManagedObjectReference",
")",
"(",
"*",
"list",
".",
"Element",
",",
"error",
")",
"{",
"rl",
":=",
"func",
"(",
"_",
"context",
".",
... | // Element returns an Element for the given ManagedObjectReference
// This method is only useful for looking up the InventoryPath of a ManagedObjectReference. | [
"Element",
"returns",
"an",
"Element",
"for",
"the",
"given",
"ManagedObjectReference",
"This",
"method",
"is",
"only",
"useful",
"for",
"looking",
"up",
"the",
"InventoryPath",
"of",
"a",
"ManagedObjectReference",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/find/finder.go#L276-L299 | train |
vmware/govmomi | find/finder.go | ObjectReference | func (f *Finder) ObjectReference(ctx context.Context, ref types.ManagedObjectReference) (object.Reference, error) {
e, err := f.Element(ctx, ref)
if err != nil {
return nil, err
}
r := object.NewReference(f.client, ref)
type common interface {
SetInventoryPath(string)
}
r.(common).SetInventoryPath(e.Path)... | go | func (f *Finder) ObjectReference(ctx context.Context, ref types.ManagedObjectReference) (object.Reference, error) {
e, err := f.Element(ctx, ref)
if err != nil {
return nil, err
}
r := object.NewReference(f.client, ref)
type common interface {
SetInventoryPath(string)
}
r.(common).SetInventoryPath(e.Path)... | [
"func",
"(",
"f",
"*",
"Finder",
")",
"ObjectReference",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"types",
".",
"ManagedObjectReference",
")",
"(",
"object",
".",
"Reference",
",",
"error",
")",
"{",
"e",
",",
"err",
":=",
"f",
".",
"Element"... | // ObjectReference converts the given ManagedObjectReference to a type from the object package via object.NewReference
// with the object.Common.InventoryPath field set. | [
"ObjectReference",
"converts",
"the",
"given",
"ManagedObjectReference",
"to",
"a",
"type",
"from",
"the",
"object",
"package",
"via",
"object",
".",
"NewReference",
"with",
"the",
"object",
".",
"Common",
".",
"InventoryPath",
"field",
"set",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/find/finder.go#L303-L324 | train |
vmware/govmomi | find/finder.go | ResourcePoolListAll | func (f *Finder) ResourcePoolListAll(ctx context.Context, path string) ([]*object.ResourcePool, error) {
pools, err := f.ResourcePoolList(ctx, path)
if err != nil {
if _, ok := err.(*NotFoundError); !ok {
return nil, err
}
vapps, _ := f.VirtualAppList(ctx, path)
if len(vapps) == 0 {
return nil, err
... | go | func (f *Finder) ResourcePoolListAll(ctx context.Context, path string) ([]*object.ResourcePool, error) {
pools, err := f.ResourcePoolList(ctx, path)
if err != nil {
if _, ok := err.(*NotFoundError); !ok {
return nil, err
}
vapps, _ := f.VirtualAppList(ctx, path)
if len(vapps) == 0 {
return nil, err
... | [
"func",
"(",
"f",
"*",
"Finder",
")",
"ResourcePoolListAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
")",
"(",
"[",
"]",
"*",
"object",
".",
"ResourcePool",
",",
"error",
")",
"{",
"pools",
",",
"err",
":=",
"f",
".",
"ResourceP... | // ResourcePoolListAll combines ResourcePoolList and VirtualAppList
// VirtualAppList is only called if ResourcePoolList does not find any pools with the given path. | [
"ResourcePoolListAll",
"combines",
"ResourcePoolList",
"and",
"VirtualAppList",
"VirtualAppList",
"is",
"only",
"called",
"if",
"ResourcePoolList",
"does",
"not",
"find",
"any",
"pools",
"with",
"the",
"given",
"path",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/find/finder.go#L881-L900 | train |
vmware/govmomi | vim25/xml/marshal.go | MarshalIndent | func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
var b bytes.Buffer
enc := NewEncoder(&b)
enc.Indent(prefix, indent)
if err := enc.Encode(v); err != nil {
return nil, err
}
return b.Bytes(), nil
} | go | func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
var b bytes.Buffer
enc := NewEncoder(&b)
enc.Indent(prefix, indent)
if err := enc.Encode(v); err != nil {
return nil, err
}
return b.Bytes(), nil
} | [
"func",
"MarshalIndent",
"(",
"v",
"interface",
"{",
"}",
",",
"prefix",
",",
"indent",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"enc",
":=",
"NewEncoder",
"(",
"&",
"b",
")",
"\n",
"... | // MarshalIndent works like Marshal, but each XML element begins on a new
// indented line that starts with prefix and is followed by one or more
// copies of indent according to the nesting depth. | [
"MarshalIndent",
"works",
"like",
"Marshal",
"but",
"each",
"XML",
"element",
"begins",
"on",
"a",
"new",
"indented",
"line",
"that",
"starts",
"with",
"prefix",
"and",
"is",
"followed",
"by",
"one",
"or",
"more",
"copies",
"of",
"indent",
"according",
"to",... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L116-L124 | train |
vmware/govmomi | vim25/xml/marshal.go | Indent | func (enc *Encoder) Indent(prefix, indent string) {
enc.p.prefix = prefix
enc.p.indent = indent
} | go | func (enc *Encoder) Indent(prefix, indent string) {
enc.p.prefix = prefix
enc.p.indent = indent
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"Indent",
"(",
"prefix",
",",
"indent",
"string",
")",
"{",
"enc",
".",
"p",
".",
"prefix",
"=",
"prefix",
"\n",
"enc",
".",
"p",
".",
"indent",
"=",
"indent",
"\n",
"}"
] | // Indent sets the encoder to generate XML in which each element
// begins on a new indented line that starts with prefix and is followed by
// one or more copies of indent according to the nesting depth. | [
"Indent",
"sets",
"the",
"encoder",
"to",
"generate",
"XML",
"in",
"which",
"each",
"element",
"begins",
"on",
"a",
"new",
"indented",
"line",
"that",
"starts",
"with",
"prefix",
"and",
"is",
"followed",
"by",
"one",
"or",
"more",
"copies",
"of",
"indent",... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L141-L144 | train |
vmware/govmomi | vim25/xml/marshal.go | Encode | func (enc *Encoder) Encode(v interface{}) error {
err := enc.p.marshalValue(reflect.ValueOf(v), nil, nil)
if err != nil {
return err
}
return enc.p.Flush()
} | go | func (enc *Encoder) Encode(v interface{}) error {
err := enc.p.marshalValue(reflect.ValueOf(v), nil, nil)
if err != nil {
return err
}
return enc.p.Flush()
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"Encode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"err",
":=",
"enc",
".",
"p",
".",
"marshalValue",
"(",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
",",
"nil",
",",
"nil",
")",
"\n",
"if",
"e... | // Encode writes the XML encoding of v to the stream.
//
// See the documentation for Marshal for details about the conversion
// of Go values to XML.
//
// Encode calls Flush before returning. | [
"Encode",
"writes",
"the",
"XML",
"encoding",
"of",
"v",
"to",
"the",
"stream",
".",
"See",
"the",
"documentation",
"for",
"Marshal",
"for",
"details",
"about",
"the",
"conversion",
"of",
"Go",
"values",
"to",
"XML",
".",
"Encode",
"calls",
"Flush",
"befor... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L152-L158 | train |
vmware/govmomi | vim25/xml/marshal.go | EncodeElement | func (enc *Encoder) EncodeElement(v interface{}, start StartElement) error {
err := enc.p.marshalValue(reflect.ValueOf(v), nil, &start)
if err != nil {
return err
}
return enc.p.Flush()
} | go | func (enc *Encoder) EncodeElement(v interface{}, start StartElement) error {
err := enc.p.marshalValue(reflect.ValueOf(v), nil, &start)
if err != nil {
return err
}
return enc.p.Flush()
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeElement",
"(",
"v",
"interface",
"{",
"}",
",",
"start",
"StartElement",
")",
"error",
"{",
"err",
":=",
"enc",
".",
"p",
".",
"marshalValue",
"(",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
",",
"nil",
... | // EncodeElement writes the XML encoding of v to the stream,
// using start as the outermost tag in the encoding.
//
// See the documentation for Marshal for details about the conversion
// of Go values to XML.
//
// EncodeElement calls Flush before returning. | [
"EncodeElement",
"writes",
"the",
"XML",
"encoding",
"of",
"v",
"to",
"the",
"stream",
"using",
"start",
"as",
"the",
"outermost",
"tag",
"in",
"the",
"encoding",
".",
"See",
"the",
"documentation",
"for",
"Marshal",
"for",
"details",
"about",
"the",
"conver... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L167-L173 | train |
vmware/govmomi | vim25/xml/marshal.go | deleteAttrPrefix | func (p *printer) deleteAttrPrefix(prefix string) {
delete(p.attrPrefix, p.attrNS[prefix])
delete(p.attrNS, prefix)
} | go | func (p *printer) deleteAttrPrefix(prefix string) {
delete(p.attrPrefix, p.attrNS[prefix])
delete(p.attrNS, prefix)
} | [
"func",
"(",
"p",
"*",
"printer",
")",
"deleteAttrPrefix",
"(",
"prefix",
"string",
")",
"{",
"delete",
"(",
"p",
".",
"attrPrefix",
",",
"p",
".",
"attrNS",
"[",
"prefix",
"]",
")",
"\n",
"delete",
"(",
"p",
".",
"attrNS",
",",
"prefix",
")",
"\n"... | // deleteAttrPrefix removes an attribute name space prefix. | [
"deleteAttrPrefix",
"removes",
"an",
"attribute",
"name",
"space",
"prefix",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L324-L327 | train |
vmware/govmomi | vim25/xml/marshal.go | defaultStart | func defaultStart(typ reflect.Type, finfo *fieldInfo, startTemplate *StartElement) StartElement {
var start StartElement
// Precedence for the XML element name is as above,
// except that we do not look inside structs for the first field.
if startTemplate != nil {
start.Name = startTemplate.Name
start.Attr = ap... | go | func defaultStart(typ reflect.Type, finfo *fieldInfo, startTemplate *StartElement) StartElement {
var start StartElement
// Precedence for the XML element name is as above,
// except that we do not look inside structs for the first field.
if startTemplate != nil {
start.Name = startTemplate.Name
start.Attr = ap... | [
"func",
"defaultStart",
"(",
"typ",
"reflect",
".",
"Type",
",",
"finfo",
"*",
"fieldInfo",
",",
"startTemplate",
"*",
"StartElement",
")",
"StartElement",
"{",
"var",
"start",
"StartElement",
"\n",
"// Precedence for the XML element name is as above,",
"// except that ... | // defaultStart returns the default start element to use,
// given the reflect type, field info, and start template. | [
"defaultStart",
"returns",
"the",
"default",
"start",
"element",
"to",
"use",
"given",
"the",
"reflect",
"type",
"field",
"info",
"and",
"start",
"template",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L560-L584 | train |
vmware/govmomi | vim25/xml/marshal.go | marshalInterface | func (p *printer) marshalInterface(val Marshaler, start StartElement) error {
// Push a marker onto the tag stack so that MarshalXML
// cannot close the XML tags that it did not open.
p.tags = append(p.tags, Name{})
n := len(p.tags)
err := val.MarshalXML(p.encoder, start)
if err != nil {
return err
}
// Mak... | go | func (p *printer) marshalInterface(val Marshaler, start StartElement) error {
// Push a marker onto the tag stack so that MarshalXML
// cannot close the XML tags that it did not open.
p.tags = append(p.tags, Name{})
n := len(p.tags)
err := val.MarshalXML(p.encoder, start)
if err != nil {
return err
}
// Mak... | [
"func",
"(",
"p",
"*",
"printer",
")",
"marshalInterface",
"(",
"val",
"Marshaler",
",",
"start",
"StartElement",
")",
"error",
"{",
"// Push a marker onto the tag stack so that MarshalXML",
"// cannot close the XML tags that it did not open.",
"p",
".",
"tags",
"=",
"app... | // marshalInterface marshals a Marshaler interface value. | [
"marshalInterface",
"marshals",
"a",
"Marshaler",
"interface",
"value",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L587-L604 | train |
vmware/govmomi | vim25/xml/marshal.go | marshalTextInterface | func (p *printer) marshalTextInterface(val encoding.TextMarshaler, start StartElement) error {
if err := p.writeStart(&start); err != nil {
return err
}
text, err := val.MarshalText()
if err != nil {
return err
}
EscapeText(p, text)
return p.writeEnd(start.Name)
} | go | func (p *printer) marshalTextInterface(val encoding.TextMarshaler, start StartElement) error {
if err := p.writeStart(&start); err != nil {
return err
}
text, err := val.MarshalText()
if err != nil {
return err
}
EscapeText(p, text)
return p.writeEnd(start.Name)
} | [
"func",
"(",
"p",
"*",
"printer",
")",
"marshalTextInterface",
"(",
"val",
"encoding",
".",
"TextMarshaler",
",",
"start",
"StartElement",
")",
"error",
"{",
"if",
"err",
":=",
"p",
".",
"writeStart",
"(",
"&",
"start",
")",
";",
"err",
"!=",
"nil",
"{... | // marshalTextInterface marshals a TextMarshaler interface value. | [
"marshalTextInterface",
"marshals",
"a",
"TextMarshaler",
"interface",
"value",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L607-L617 | train |
vmware/govmomi | vim25/xml/marshal.go | writeStart | func (p *printer) writeStart(start *StartElement) error {
if start.Name.Local == "" {
return fmt.Errorf("xml: start tag with no name")
}
p.tags = append(p.tags, start.Name)
p.markPrefix()
p.writeIndent(1)
p.WriteByte('<')
p.WriteString(start.Name.Local)
if start.Name.Space != "" {
p.WriteString(` xmlns="... | go | func (p *printer) writeStart(start *StartElement) error {
if start.Name.Local == "" {
return fmt.Errorf("xml: start tag with no name")
}
p.tags = append(p.tags, start.Name)
p.markPrefix()
p.writeIndent(1)
p.WriteByte('<')
p.WriteString(start.Name.Local)
if start.Name.Space != "" {
p.WriteString(` xmlns="... | [
"func",
"(",
"p",
"*",
"printer",
")",
"writeStart",
"(",
"start",
"*",
"StartElement",
")",
"error",
"{",
"if",
"start",
".",
"Name",
".",
"Local",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"... | // writeStart writes the given start element. | [
"writeStart",
"writes",
"the",
"given",
"start",
"element",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L620-L656 | train |
vmware/govmomi | vim25/xml/marshal.go | cachedWriteError | func (p *printer) cachedWriteError() error {
_, err := p.Write(nil)
return err
} | go | func (p *printer) cachedWriteError() error {
_, err := p.Write(nil)
return err
} | [
"func",
"(",
"p",
"*",
"printer",
")",
"cachedWriteError",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"p",
".",
"Write",
"(",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // return the bufio Writer's cached write error | [
"return",
"the",
"bufio",
"Writer",
"s",
"cached",
"write",
"error"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L852-L855 | train |
vmware/govmomi | vim25/xml/marshal.go | trim | func (s *parentStack) trim(parents []string) error {
split := 0
for ; split < len(parents) && split < len(s.stack); split++ {
if parents[split] != s.stack[split] {
break
}
}
for i := len(s.stack) - 1; i >= split; i-- {
if err := s.p.writeEnd(Name{Local: s.stack[i]}); err != nil {
return err
}
}
s.st... | go | func (s *parentStack) trim(parents []string) error {
split := 0
for ; split < len(parents) && split < len(s.stack); split++ {
if parents[split] != s.stack[split] {
break
}
}
for i := len(s.stack) - 1; i >= split; i-- {
if err := s.p.writeEnd(Name{Local: s.stack[i]}); err != nil {
return err
}
}
s.st... | [
"func",
"(",
"s",
"*",
"parentStack",
")",
"trim",
"(",
"parents",
"[",
"]",
"string",
")",
"error",
"{",
"split",
":=",
"0",
"\n",
"for",
";",
"split",
"<",
"len",
"(",
"parents",
")",
"&&",
"split",
"<",
"len",
"(",
"s",
".",
"stack",
")",
";... | // trim updates the XML context to match the longest common prefix of the stack
// and the given parents. A closing tag will be written for every parent
// popped. Passing a zero slice or nil will close all the elements. | [
"trim",
"updates",
"the",
"XML",
"context",
"to",
"match",
"the",
"longest",
"common",
"prefix",
"of",
"the",
"stack",
"and",
"the",
"given",
"parents",
".",
"A",
"closing",
"tag",
"will",
"be",
"written",
"for",
"every",
"parent",
"popped",
".",
"Passing"... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L896-L910 | train |
vmware/govmomi | vim25/xml/marshal.go | push | func (s *parentStack) push(parents []string) error {
for i := 0; i < len(parents); i++ {
if err := s.p.writeStart(&StartElement{Name: Name{Local: parents[i]}}); err != nil {
return err
}
}
s.stack = append(s.stack, parents...)
return nil
} | go | func (s *parentStack) push(parents []string) error {
for i := 0; i < len(parents); i++ {
if err := s.p.writeStart(&StartElement{Name: Name{Local: parents[i]}}); err != nil {
return err
}
}
s.stack = append(s.stack, parents...)
return nil
} | [
"func",
"(",
"s",
"*",
"parentStack",
")",
"push",
"(",
"parents",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"parents",
")",
";",
"i",
"++",
"{",
"if",
"err",
":=",
"s",
".",
"p",
".",
"writeStar... | // push adds parent elements to the stack and writes open tags. | [
"push",
"adds",
"parent",
"elements",
"to",
"the",
"stack",
"and",
"writes",
"open",
"tags",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/xml/marshal.go#L913-L921 | train |
vmware/govmomi | govc/object/find.go | rootMatch | func (cmd *find) rootMatch(ctx context.Context, root object.Reference, client *vim25.Client, filter property.Filter) bool {
ref := root.Reference()
if !cmd.kind.wanted(ref.Type) {
return false
}
if len(filter) == 1 && filter["name"] == "*" {
return true
}
var content []types.ObjectContent
pc := property.... | go | func (cmd *find) rootMatch(ctx context.Context, root object.Reference, client *vim25.Client, filter property.Filter) bool {
ref := root.Reference()
if !cmd.kind.wanted(ref.Type) {
return false
}
if len(filter) == 1 && filter["name"] == "*" {
return true
}
var content []types.ObjectContent
pc := property.... | [
"func",
"(",
"cmd",
"*",
"find",
")",
"rootMatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"root",
"object",
".",
"Reference",
",",
"client",
"*",
"vim25",
".",
"Client",
",",
"filter",
"property",
".",
"Filter",
")",
"bool",
"{",
"ref",
":=",
"r... | // rootMatch returns true if the root object path should be printed | [
"rootMatch",
"returns",
"true",
"if",
"the",
"root",
"object",
"path",
"should",
"be",
"printed"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/govc/object/find.go#L157-L174 | train |
vmware/govmomi | vslm/object_manager.go | NewObjectManager | func NewObjectManager(client *vim25.Client, ref ...types.ManagedObjectReference) *ObjectManager {
mref := *client.ServiceContent.VStorageObjectManager
if len(ref) == 1 {
mref = ref[0]
}
m := ObjectManager{
ManagedObjectReference: mref,
c: client,
isVC: mref.Type == "... | go | func NewObjectManager(client *vim25.Client, ref ...types.ManagedObjectReference) *ObjectManager {
mref := *client.ServiceContent.VStorageObjectManager
if len(ref) == 1 {
mref = ref[0]
}
m := ObjectManager{
ManagedObjectReference: mref,
c: client,
isVC: mref.Type == "... | [
"func",
"NewObjectManager",
"(",
"client",
"*",
"vim25",
".",
"Client",
",",
"ref",
"...",
"types",
".",
"ManagedObjectReference",
")",
"*",
"ObjectManager",
"{",
"mref",
":=",
"*",
"client",
".",
"ServiceContent",
".",
"VStorageObjectManager",
"\n\n",
"if",
"... | // NewObjectManager returns an ObjectManager referencing the VcenterVStorageObjectManager singleton when connected to vCenter or
// the HostVStorageObjectManager singleton when connected to an ESX host. The optional ref param can be used to specify a ESX
// host instead, when connected to vCenter. | [
"NewObjectManager",
"returns",
"an",
"ObjectManager",
"referencing",
"the",
"VcenterVStorageObjectManager",
"singleton",
"when",
"connected",
"to",
"vCenter",
"or",
"the",
"HostVStorageObjectManager",
"singleton",
"when",
"connected",
"to",
"an",
"ESX",
"host",
".",
"Th... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vslm/object_manager.go#L40-L54 | train |
vmware/govmomi | vslm/object_manager.go | PlaceDisk | func (m ObjectManager) PlaceDisk(ctx context.Context, spec *types.VslmCreateSpec, pool types.ManagedObjectReference) error {
backing := spec.BackingSpec.GetVslmCreateSpecBackingSpec()
if backing.Datastore.Type != "StoragePod" {
return nil
}
device := &types.VirtualDisk{
VirtualDevice: types.VirtualDevice{
K... | go | func (m ObjectManager) PlaceDisk(ctx context.Context, spec *types.VslmCreateSpec, pool types.ManagedObjectReference) error {
backing := spec.BackingSpec.GetVslmCreateSpecBackingSpec()
if backing.Datastore.Type != "StoragePod" {
return nil
}
device := &types.VirtualDisk{
VirtualDevice: types.VirtualDevice{
K... | [
"func",
"(",
"m",
"ObjectManager",
")",
"PlaceDisk",
"(",
"ctx",
"context",
".",
"Context",
",",
"spec",
"*",
"types",
".",
"VslmCreateSpec",
",",
"pool",
"types",
".",
"ManagedObjectReference",
")",
"error",
"{",
"backing",
":=",
"spec",
".",
"BackingSpec",... | // PlaceDisk uses StorageResourceManager datastore placement recommendations to choose a Datastore from a Datastore cluster.
// If the given spec backing Datastore field is not that of type StoragePod, the spec is unmodifed.
// Otherwise, the backing Datastore field is replaced with a Datastore suggestion. | [
"PlaceDisk",
"uses",
"StorageResourceManager",
"datastore",
"placement",
"recommendations",
"to",
"choose",
"a",
"Datastore",
"from",
"a",
"Datastore",
"cluster",
".",
"If",
"the",
"given",
"spec",
"backing",
"Datastore",
"field",
"is",
"not",
"that",
"of",
"type"... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vslm/object_manager.go#L59-L124 | train |
vmware/govmomi | simulator/registry.go | NewRegistry | func NewRegistry() *Registry {
r := &Registry{
objects: make(map[types.ManagedObjectReference]mo.Reference),
handlers: make(map[types.ManagedObjectReference]RegisterObject),
locks: make(map[types.ManagedObjectReference]sync.Locker),
Namespace: vim25.Namespace,
Path: vim25.Path,
}
return r
} | go | func NewRegistry() *Registry {
r := &Registry{
objects: make(map[types.ManagedObjectReference]mo.Reference),
handlers: make(map[types.ManagedObjectReference]RegisterObject),
locks: make(map[types.ManagedObjectReference]sync.Locker),
Namespace: vim25.Namespace,
Path: vim25.Path,
}
return r
} | [
"func",
"NewRegistry",
"(",
")",
"*",
"Registry",
"{",
"r",
":=",
"&",
"Registry",
"{",
"objects",
":",
"make",
"(",
"map",
"[",
"types",
".",
"ManagedObjectReference",
"]",
"mo",
".",
"Reference",
")",
",",
"handlers",
":",
"make",
"(",
"map",
"[",
... | // NewRegistry creates a new instances of Registry | [
"NewRegistry",
"creates",
"a",
"new",
"instances",
"of",
"Registry"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L81-L92 | train |
vmware/govmomi | simulator/registry.go | typeName | func typeName(item mo.Reference) string {
return reflect.TypeOf(item).Elem().Name()
} | go | func typeName(item mo.Reference) string {
return reflect.TypeOf(item).Elem().Name()
} | [
"func",
"typeName",
"(",
"item",
"mo",
".",
"Reference",
")",
"string",
"{",
"return",
"reflect",
".",
"TypeOf",
"(",
"item",
")",
".",
"Elem",
"(",
")",
".",
"Name",
"(",
")",
"\n",
"}"
] | // typeName returns the type of the given object. | [
"typeName",
"returns",
"the",
"type",
"of",
"the",
"given",
"object",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L104-L106 | train |
vmware/govmomi | simulator/registry.go | valuePrefix | func valuePrefix(typeName string) string {
if v, ok := refValueMap[typeName]; ok {
return v
}
return strings.ToLower(typeName)
} | go | func valuePrefix(typeName string) string {
if v, ok := refValueMap[typeName]; ok {
return v
}
return strings.ToLower(typeName)
} | [
"func",
"valuePrefix",
"(",
"typeName",
"string",
")",
"string",
"{",
"if",
"v",
",",
"ok",
":=",
"refValueMap",
"[",
"typeName",
"]",
";",
"ok",
"{",
"return",
"v",
"\n",
"}",
"\n\n",
"return",
"strings",
".",
"ToLower",
"(",
"typeName",
")",
"\n",
... | // valuePrefix returns the value name prefix of a given object | [
"valuePrefix",
"returns",
"the",
"value",
"name",
"prefix",
"of",
"a",
"given",
"object"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L109-L115 | train |
vmware/govmomi | simulator/registry.go | newReference | func (r *Registry) newReference(item mo.Reference) types.ManagedObjectReference {
ref := item.Reference()
if ref.Type == "" {
ref.Type = typeName(item)
}
if ref.Value == "" {
n := atomic.AddInt64(&r.counter, 1)
ref.Value = fmt.Sprintf("%s-%d", valuePrefix(ref.Type), n)
}
return ref
} | go | func (r *Registry) newReference(item mo.Reference) types.ManagedObjectReference {
ref := item.Reference()
if ref.Type == "" {
ref.Type = typeName(item)
}
if ref.Value == "" {
n := atomic.AddInt64(&r.counter, 1)
ref.Value = fmt.Sprintf("%s-%d", valuePrefix(ref.Type), n)
}
return ref
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"newReference",
"(",
"item",
"mo",
".",
"Reference",
")",
"types",
".",
"ManagedObjectReference",
"{",
"ref",
":=",
"item",
".",
"Reference",
"(",
")",
"\n\n",
"if",
"ref",
".",
"Type",
"==",
"\"",
"\"",
"{",
"... | // newReference returns a new MOR, where Type defaults to type of the given item
// and Value defaults to a unique id for the given type. | [
"newReference",
"returns",
"a",
"new",
"MOR",
"where",
"Type",
"defaults",
"to",
"type",
"of",
"the",
"given",
"item",
"and",
"Value",
"defaults",
"to",
"a",
"unique",
"id",
"for",
"the",
"given",
"type",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L119-L132 | train |
vmware/govmomi | simulator/registry.go | AddHandler | func (r *Registry) AddHandler(h RegisterObject) {
r.m.Lock()
r.handlers[h.Reference()] = h
r.m.Unlock()
} | go | func (r *Registry) AddHandler(h RegisterObject) {
r.m.Lock()
r.handlers[h.Reference()] = h
r.m.Unlock()
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"AddHandler",
"(",
"h",
"RegisterObject",
")",
"{",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"handlers",
"[",
"h",
".",
"Reference",
"(",
")",
"]",
"=",
"h",
"\n",
"r",
".",
"m",
".",
"Unlo... | // AddHandler adds a RegisterObject handler to the Registry. | [
"AddHandler",
"adds",
"a",
"RegisterObject",
"handler",
"to",
"the",
"Registry",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L140-L144 | train |
vmware/govmomi | simulator/registry.go | PutEntity | func (r *Registry) PutEntity(parent mo.Entity, item mo.Entity) mo.Entity {
e := item.Entity()
if parent != nil {
e.Parent = &parent.Entity().Self
}
r.Put(item)
return item
} | go | func (r *Registry) PutEntity(parent mo.Entity, item mo.Entity) mo.Entity {
e := item.Entity()
if parent != nil {
e.Parent = &parent.Entity().Self
}
r.Put(item)
return item
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"PutEntity",
"(",
"parent",
"mo",
".",
"Entity",
",",
"item",
"mo",
".",
"Entity",
")",
"mo",
".",
"Entity",
"{",
"e",
":=",
"item",
".",
"Entity",
"(",
")",
"\n\n",
"if",
"parent",
"!=",
"nil",
"{",
"e",
... | // PutEntity sets item.Parent to that of parent.Self before adding item to the Registry. | [
"PutEntity",
"sets",
"item",
".",
"Parent",
"to",
"that",
"of",
"parent",
".",
"Self",
"before",
"adding",
"item",
"to",
"the",
"Registry",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L156-L166 | train |
vmware/govmomi | simulator/registry.go | Get | func (r *Registry) Get(ref types.ManagedObjectReference) mo.Reference {
r.m.Lock()
defer r.m.Unlock()
return r.objects[ref]
} | go | func (r *Registry) Get(ref types.ManagedObjectReference) mo.Reference {
r.m.Lock()
defer r.m.Unlock()
return r.objects[ref]
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"Get",
"(",
"ref",
"types",
".",
"ManagedObjectReference",
")",
"mo",
".",
"Reference",
"{",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"r... | // Get returns the object for the given reference. | [
"Get",
"returns",
"the",
"object",
"for",
"the",
"given",
"reference",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L169-L174 | train |
vmware/govmomi | simulator/registry.go | Any | func (r *Registry) Any(kind string) mo.Entity {
r.m.Lock()
defer r.m.Unlock()
for ref, val := range r.objects {
if ref.Type == kind {
return val.(mo.Entity)
}
}
return nil
} | go | func (r *Registry) Any(kind string) mo.Entity {
r.m.Lock()
defer r.m.Unlock()
for ref, val := range r.objects {
if ref.Type == kind {
return val.(mo.Entity)
}
}
return nil
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"Any",
"(",
"kind",
"string",
")",
"mo",
".",
"Entity",
"{",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"ref",
",",
"val",
":=",
"range",... | // Any returns the first instance of entity type specified by kind. | [
"Any",
"returns",
"the",
"first",
"instance",
"of",
"entity",
"type",
"specified",
"by",
"kind",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L177-L188 | train |
vmware/govmomi | simulator/registry.go | All | func (r *Registry) All(kind string) []mo.Entity {
r.m.Lock()
defer r.m.Unlock()
var entities []mo.Entity
for ref, val := range r.objects {
if kind == "" || ref.Type == kind {
if e, ok := val.(mo.Entity); ok {
entities = append(entities, e)
}
}
}
return entities
} | go | func (r *Registry) All(kind string) []mo.Entity {
r.m.Lock()
defer r.m.Unlock()
var entities []mo.Entity
for ref, val := range r.objects {
if kind == "" || ref.Type == kind {
if e, ok := val.(mo.Entity); ok {
entities = append(entities, e)
}
}
}
return entities
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"All",
"(",
"kind",
"string",
")",
"[",
"]",
"mo",
".",
"Entity",
"{",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"entities",
"[",
"]",
... | // All returns all entities of type specified by kind.
// If kind is empty - all entities will be returned. | [
"All",
"returns",
"all",
"entities",
"of",
"type",
"specified",
"by",
"kind",
".",
"If",
"kind",
"is",
"empty",
"-",
"all",
"entities",
"will",
"be",
"returned",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L192-L206 | train |
vmware/govmomi | simulator/registry.go | applyHandlers | func (r *Registry) applyHandlers(f func(o RegisterObject)) {
r.m.Lock()
handlers := make([]RegisterObject, 0, len(r.handlers))
for _, handler := range r.handlers {
handlers = append(handlers, handler)
}
r.m.Unlock()
for i := range handlers {
f(handlers[i])
}
} | go | func (r *Registry) applyHandlers(f func(o RegisterObject)) {
r.m.Lock()
handlers := make([]RegisterObject, 0, len(r.handlers))
for _, handler := range r.handlers {
handlers = append(handlers, handler)
}
r.m.Unlock()
for i := range handlers {
f(handlers[i])
}
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"applyHandlers",
"(",
"f",
"func",
"(",
"o",
"RegisterObject",
")",
")",
"{",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"handlers",
":=",
"make",
"(",
"[",
"]",
"RegisterObject",
",",
"0",
",",
"len",
"("... | // applyHandlers calls the given func for each r.handlers | [
"applyHandlers",
"calls",
"the",
"given",
"func",
"for",
"each",
"r",
".",
"handlers"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L209-L220 | train |
vmware/govmomi | simulator/registry.go | Put | func (r *Registry) Put(item mo.Reference) mo.Reference {
r.m.Lock()
ref := item.Reference()
if ref.Type == "" || ref.Value == "" {
ref = r.newReference(item)
r.setReference(item, ref)
}
if me, ok := item.(mo.Entity); ok {
me.Entity().ConfigStatus = types.ManagedEntityStatusGreen
me.Entity().OverallStatus... | go | func (r *Registry) Put(item mo.Reference) mo.Reference {
r.m.Lock()
ref := item.Reference()
if ref.Type == "" || ref.Value == "" {
ref = r.newReference(item)
r.setReference(item, ref)
}
if me, ok := item.(mo.Entity); ok {
me.Entity().ConfigStatus = types.ManagedEntityStatusGreen
me.Entity().OverallStatus... | [
"func",
"(",
"r",
"*",
"Registry",
")",
"Put",
"(",
"item",
"mo",
".",
"Reference",
")",
"mo",
".",
"Reference",
"{",
"r",
".",
"m",
".",
"Lock",
"(",
")",
"\n\n",
"ref",
":=",
"item",
".",
"Reference",
"(",
")",
"\n",
"if",
"ref",
".",
"Type",... | // Put adds a new object to Registry, generating a ManagedObjectReference if not already set. | [
"Put",
"adds",
"a",
"new",
"object",
"to",
"Registry",
"generating",
"a",
"ManagedObjectReference",
"if",
"not",
"already",
"set",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L223-L247 | train |
vmware/govmomi | simulator/registry.go | Remove | func (r *Registry) Remove(item types.ManagedObjectReference) {
r.applyHandlers(func(o RegisterObject) {
o.RemoveObject(item)
})
r.m.Lock()
delete(r.objects, item)
delete(r.handlers, item)
delete(r.locks, item)
r.m.Unlock()
} | go | func (r *Registry) Remove(item types.ManagedObjectReference) {
r.applyHandlers(func(o RegisterObject) {
o.RemoveObject(item)
})
r.m.Lock()
delete(r.objects, item)
delete(r.handlers, item)
delete(r.locks, item)
r.m.Unlock()
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"Remove",
"(",
"item",
"types",
".",
"ManagedObjectReference",
")",
"{",
"r",
".",
"applyHandlers",
"(",
"func",
"(",
"o",
"RegisterObject",
")",
"{",
"o",
".",
"RemoveObject",
"(",
"item",
")",
"\n",
"}",
")",
... | // Remove removes an object from the Registry. | [
"Remove",
"removes",
"an",
"object",
"from",
"the",
"Registry",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L250-L260 | train |
vmware/govmomi | simulator/registry.go | Update | func (r *Registry) Update(obj mo.Reference, changes []types.PropertyChange) {
for i := range changes {
if changes[i].Op == "" {
changes[i].Op = types.PropertyChangeOpAssign
}
if changes[i].Val != nil {
rval := reflect.ValueOf(changes[i].Val)
changes[i].Val = wrapValue(rval, rval.Type())
}
}
val := ... | go | func (r *Registry) Update(obj mo.Reference, changes []types.PropertyChange) {
for i := range changes {
if changes[i].Op == "" {
changes[i].Op = types.PropertyChangeOpAssign
}
if changes[i].Val != nil {
rval := reflect.ValueOf(changes[i].Val)
changes[i].Val = wrapValue(rval, rval.Type())
}
}
val := ... | [
"func",
"(",
"r",
"*",
"Registry",
")",
"Update",
"(",
"obj",
"mo",
".",
"Reference",
",",
"changes",
"[",
"]",
"types",
".",
"PropertyChange",
")",
"{",
"for",
"i",
":=",
"range",
"changes",
"{",
"if",
"changes",
"[",
"i",
"]",
".",
"Op",
"==",
... | // Update dispatches object property changes to RegisterObject handlers,
// such as any PropertyCollector instances with in-progress WaitForUpdates calls.
// The changes are also applied to the given object via mo.ApplyPropertyChange,
// so there is no need to set object fields directly. | [
"Update",
"dispatches",
"object",
"property",
"changes",
"to",
"RegisterObject",
"handlers",
"such",
"as",
"any",
"PropertyCollector",
"instances",
"with",
"in",
"-",
"progress",
"WaitForUpdates",
"calls",
".",
"The",
"changes",
"are",
"also",
"applied",
"to",
"th... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L266-L284 | train |
vmware/govmomi | simulator/registry.go | getEntityParent | func (r *Registry) getEntityParent(item mo.Entity, kind string) mo.Entity {
for {
parent := item.Entity().Parent
item = r.Get(*parent).(mo.Entity)
if item.Reference().Type == kind {
return item
}
}
} | go | func (r *Registry) getEntityParent(item mo.Entity, kind string) mo.Entity {
for {
parent := item.Entity().Parent
item = r.Get(*parent).(mo.Entity)
if item.Reference().Type == kind {
return item
}
}
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"getEntityParent",
"(",
"item",
"mo",
".",
"Entity",
",",
"kind",
"string",
")",
"mo",
".",
"Entity",
"{",
"for",
"{",
"parent",
":=",
"item",
".",
"Entity",
"(",
")",
".",
"Parent",
"\n\n",
"item",
"=",
"r",... | // getEntityParent traverses up the inventory and returns the first object of type kind.
// If no object of type kind is found, the method will panic when it reaches the
// inventory root Folder where the Parent field is nil. | [
"getEntityParent",
"traverses",
"up",
"the",
"inventory",
"and",
"returns",
"the",
"first",
"object",
"of",
"type",
"kind",
".",
"If",
"no",
"object",
"of",
"type",
"kind",
"is",
"found",
"the",
"method",
"will",
"panic",
"when",
"it",
"reaches",
"the",
"i... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L289-L299 | train |
vmware/govmomi | simulator/registry.go | getEntityDatacenter | func (r *Registry) getEntityDatacenter(item mo.Entity) *Datacenter {
return r.getEntityParent(item, "Datacenter").(*Datacenter)
} | go | func (r *Registry) getEntityDatacenter(item mo.Entity) *Datacenter {
return r.getEntityParent(item, "Datacenter").(*Datacenter)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"getEntityDatacenter",
"(",
"item",
"mo",
".",
"Entity",
")",
"*",
"Datacenter",
"{",
"return",
"r",
".",
"getEntityParent",
"(",
"item",
",",
"\"",
"\"",
")",
".",
"(",
"*",
"Datacenter",
")",
"\n",
"}"
] | // getEntityDatacenter returns the Datacenter containing the given item | [
"getEntityDatacenter",
"returns",
"the",
"Datacenter",
"containing",
"the",
"given",
"item"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L302-L304 | train |
vmware/govmomi | simulator/registry.go | getEntityComputeResource | func (r *Registry) getEntityComputeResource(item mo.Entity) mo.Entity {
for {
parent := item.Entity().Parent
item = r.Get(*parent).(mo.Entity)
switch item.Reference().Type {
case "ComputeResource":
return item
case "ClusterComputeResource":
return item
}
}
} | go | func (r *Registry) getEntityComputeResource(item mo.Entity) mo.Entity {
for {
parent := item.Entity().Parent
item = r.Get(*parent).(mo.Entity)
switch item.Reference().Type {
case "ComputeResource":
return item
case "ClusterComputeResource":
return item
}
}
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"getEntityComputeResource",
"(",
"item",
"mo",
".",
"Entity",
")",
"mo",
".",
"Entity",
"{",
"for",
"{",
"parent",
":=",
"item",
".",
"Entity",
"(",
")",
".",
"Parent",
"\n\n",
"item",
"=",
"r",
".",
"Get",
"... | // getEntityComputeResource returns the ComputeResource parent for the given item.
// A ResourcePool for example may have N Parents of type ResourcePool, but the top
// most Parent pool is always a ComputeResource child. | [
"getEntityComputeResource",
"returns",
"the",
"ComputeResource",
"parent",
"for",
"the",
"given",
"item",
".",
"A",
"ResourcePool",
"for",
"example",
"may",
"have",
"N",
"Parents",
"of",
"type",
"ResourcePool",
"but",
"the",
"top",
"most",
"Parent",
"pool",
"is"... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L332-L345 | train |
vmware/govmomi | simulator/registry.go | FindByName | func (r *Registry) FindByName(name string, refs []types.ManagedObjectReference) mo.Entity {
for _, ref := range refs {
if e, ok := r.Get(ref).(mo.Entity); ok {
if name == e.Entity().Name {
return e
}
}
}
return nil
} | go | func (r *Registry) FindByName(name string, refs []types.ManagedObjectReference) mo.Entity {
for _, ref := range refs {
if e, ok := r.Get(ref).(mo.Entity); ok {
if name == e.Entity().Name {
return e
}
}
}
return nil
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"FindByName",
"(",
"name",
"string",
",",
"refs",
"[",
"]",
"types",
".",
"ManagedObjectReference",
")",
"mo",
".",
"Entity",
"{",
"for",
"_",
",",
"ref",
":=",
"range",
"refs",
"{",
"if",
"e",
",",
"ok",
":=... | // FindByName returns the first mo.Entity of the given refs whose Name field is equal to the given name.
// If there is no match, nil is returned.
// This method is useful for cases where objects are required to have a unique name, such as Datastore with
// a HostStorageSystem or HostSystem within a ClusterComputeResou... | [
"FindByName",
"returns",
"the",
"first",
"mo",
".",
"Entity",
"of",
"the",
"given",
"refs",
"whose",
"Name",
"field",
"is",
"equal",
"to",
"the",
"given",
"name",
".",
"If",
"there",
"is",
"no",
"match",
"nil",
"is",
"returned",
".",
"This",
"method",
... | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L351-L361 | train |
vmware/govmomi | simulator/registry.go | FindReference | func FindReference(refs []types.ManagedObjectReference, match ...types.ManagedObjectReference) *types.ManagedObjectReference {
for _, ref := range refs {
for _, m := range match {
if ref == m {
return &ref
}
}
}
return nil
} | go | func FindReference(refs []types.ManagedObjectReference, match ...types.ManagedObjectReference) *types.ManagedObjectReference {
for _, ref := range refs {
for _, m := range match {
if ref == m {
return &ref
}
}
}
return nil
} | [
"func",
"FindReference",
"(",
"refs",
"[",
"]",
"types",
".",
"ManagedObjectReference",
",",
"match",
"...",
"types",
".",
"ManagedObjectReference",
")",
"*",
"types",
".",
"ManagedObjectReference",
"{",
"for",
"_",
",",
"ref",
":=",
"range",
"refs",
"{",
"f... | // FindReference returns the 1st match found in refs, or nil if not found. | [
"FindReference",
"returns",
"the",
"1st",
"match",
"found",
"in",
"refs",
"or",
"nil",
"if",
"not",
"found",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L364-L374 | train |
vmware/govmomi | simulator/registry.go | AppendReference | func (r *Registry) AppendReference(obj mo.Reference, field *[]types.ManagedObjectReference, ref ...types.ManagedObjectReference) {
r.WithLock(obj, func() {
*field = append(*field, ref...)
})
} | go | func (r *Registry) AppendReference(obj mo.Reference, field *[]types.ManagedObjectReference, ref ...types.ManagedObjectReference) {
r.WithLock(obj, func() {
*field = append(*field, ref...)
})
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"AppendReference",
"(",
"obj",
"mo",
".",
"Reference",
",",
"field",
"*",
"[",
"]",
"types",
".",
"ManagedObjectReference",
",",
"ref",
"...",
"types",
".",
"ManagedObjectReference",
")",
"{",
"r",
".",
"WithLock",
... | // AppendReference appends the given refs to field. | [
"AppendReference",
"appends",
"the",
"given",
"refs",
"to",
"field",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L377-L381 | train |
vmware/govmomi | simulator/registry.go | AddReference | func (r *Registry) AddReference(obj mo.Reference, field *[]types.ManagedObjectReference, ref types.ManagedObjectReference) {
r.WithLock(obj, func() {
if FindReference(*field, ref) == nil {
*field = append(*field, ref)
}
})
} | go | func (r *Registry) AddReference(obj mo.Reference, field *[]types.ManagedObjectReference, ref types.ManagedObjectReference) {
r.WithLock(obj, func() {
if FindReference(*field, ref) == nil {
*field = append(*field, ref)
}
})
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"AddReference",
"(",
"obj",
"mo",
".",
"Reference",
",",
"field",
"*",
"[",
"]",
"types",
".",
"ManagedObjectReference",
",",
"ref",
"types",
".",
"ManagedObjectReference",
")",
"{",
"r",
".",
"WithLock",
"(",
"obj... | // AddReference appends ref to field if not already in the given field. | [
"AddReference",
"appends",
"ref",
"to",
"field",
"if",
"not",
"already",
"in",
"the",
"given",
"field",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L384-L390 | train |
vmware/govmomi | simulator/registry.go | SearchIndex | func (r *Registry) SearchIndex() *SearchIndex {
return r.Get(r.content().SearchIndex.Reference()).(*SearchIndex)
} | go | func (r *Registry) SearchIndex() *SearchIndex {
return r.Get(r.content().SearchIndex.Reference()).(*SearchIndex)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"SearchIndex",
"(",
")",
"*",
"SearchIndex",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"SearchIndex",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"SearchIndex",
")",
"\n",
... | // SearchIndex returns the SearchIndex singleton | [
"SearchIndex",
"returns",
"the",
"SearchIndex",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L435-L437 | train |
vmware/govmomi | simulator/registry.go | EventManager | func (r *Registry) EventManager() *EventManager {
return r.Get(r.content().EventManager.Reference()).(*EventManager)
} | go | func (r *Registry) EventManager() *EventManager {
return r.Get(r.content().EventManager.Reference()).(*EventManager)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"EventManager",
"(",
")",
"*",
"EventManager",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"EventManager",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"EventManager",
")",
"\n... | // EventManager returns the EventManager singleton | [
"EventManager",
"returns",
"the",
"EventManager",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L440-L442 | train |
vmware/govmomi | simulator/registry.go | FileManager | func (r *Registry) FileManager() *FileManager {
return r.Get(r.content().FileManager.Reference()).(*FileManager)
} | go | func (r *Registry) FileManager() *FileManager {
return r.Get(r.content().FileManager.Reference()).(*FileManager)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"FileManager",
"(",
")",
"*",
"FileManager",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"FileManager",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"FileManager",
")",
"\n",
... | // FileManager returns the FileManager singleton | [
"FileManager",
"returns",
"the",
"FileManager",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L445-L447 | train |
vmware/govmomi | simulator/registry.go | VirtualDiskManager | func (r *Registry) VirtualDiskManager() *VirtualDiskManager {
return r.Get(r.content().VirtualDiskManager.Reference()).(*VirtualDiskManager)
} | go | func (r *Registry) VirtualDiskManager() *VirtualDiskManager {
return r.Get(r.content().VirtualDiskManager.Reference()).(*VirtualDiskManager)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"VirtualDiskManager",
"(",
")",
"*",
"VirtualDiskManager",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"VirtualDiskManager",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"VirtualDi... | // VirtualDiskManager returns the VirtualDiskManager singleton | [
"VirtualDiskManager",
"returns",
"the",
"VirtualDiskManager",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L450-L452 | train |
vmware/govmomi | simulator/registry.go | ViewManager | func (r *Registry) ViewManager() *ViewManager {
return r.Get(r.content().ViewManager.Reference()).(*ViewManager)
} | go | func (r *Registry) ViewManager() *ViewManager {
return r.Get(r.content().ViewManager.Reference()).(*ViewManager)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"ViewManager",
"(",
")",
"*",
"ViewManager",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"ViewManager",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"ViewManager",
")",
"\n",
... | // ViewManager returns the ViewManager singleton | [
"ViewManager",
"returns",
"the",
"ViewManager",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L455-L457 | train |
vmware/govmomi | simulator/registry.go | UserDirectory | func (r *Registry) UserDirectory() *UserDirectory {
return r.Get(r.content().UserDirectory.Reference()).(*UserDirectory)
} | go | func (r *Registry) UserDirectory() *UserDirectory {
return r.Get(r.content().UserDirectory.Reference()).(*UserDirectory)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"UserDirectory",
"(",
")",
"*",
"UserDirectory",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"UserDirectory",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"UserDirectory",
")",
... | // UserDirectory returns the UserDirectory singleton | [
"UserDirectory",
"returns",
"the",
"UserDirectory",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L460-L462 | train |
vmware/govmomi | simulator/registry.go | SessionManager | func (r *Registry) SessionManager() *SessionManager {
return r.Get(r.content().SessionManager.Reference()).(*SessionManager)
} | go | func (r *Registry) SessionManager() *SessionManager {
return r.Get(r.content().SessionManager.Reference()).(*SessionManager)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"SessionManager",
"(",
")",
"*",
"SessionManager",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"SessionManager",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"SessionManager",
")... | // SessionManager returns the SessionManager singleton | [
"SessionManager",
"returns",
"the",
"SessionManager",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L465-L467 | train |
vmware/govmomi | simulator/registry.go | OptionManager | func (r *Registry) OptionManager() *OptionManager {
return r.Get(r.content().Setting.Reference()).(*OptionManager)
} | go | func (r *Registry) OptionManager() *OptionManager {
return r.Get(r.content().Setting.Reference()).(*OptionManager)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"OptionManager",
"(",
")",
"*",
"OptionManager",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"Setting",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"OptionManager",
")",
"\n",... | // OptionManager returns the OptionManager singleton | [
"OptionManager",
"returns",
"the",
"OptionManager",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L470-L472 | train |
vmware/govmomi | simulator/registry.go | CustomFieldsManager | func (r *Registry) CustomFieldsManager() *CustomFieldsManager {
return r.Get(r.content().CustomFieldsManager.Reference()).(*CustomFieldsManager)
} | go | func (r *Registry) CustomFieldsManager() *CustomFieldsManager {
return r.Get(r.content().CustomFieldsManager.Reference()).(*CustomFieldsManager)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"CustomFieldsManager",
"(",
")",
"*",
"CustomFieldsManager",
"{",
"return",
"r",
".",
"Get",
"(",
"r",
".",
"content",
"(",
")",
".",
"CustomFieldsManager",
".",
"Reference",
"(",
")",
")",
".",
"(",
"*",
"Custom... | // CustomFieldsManager returns CustomFieldsManager singleton | [
"CustomFieldsManager",
"returns",
"CustomFieldsManager",
"singleton"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/registry.go#L475-L477 | train |
vmware/govmomi | vim25/mo/type_info.go | LoadFromObjectContent | func (t *typeInfo) LoadFromObjectContent(o types.ObjectContent) (reflect.Value, error) {
v := reflect.New(t.typ)
assignValue(v, t.self, reflect.ValueOf(o.Obj))
for _, p := range o.PropSet {
rv, ok := t.props[p.Name]
if !ok {
continue
}
assignValue(v, rv, reflect.ValueOf(p.Val))
}
return v, nil
} | go | func (t *typeInfo) LoadFromObjectContent(o types.ObjectContent) (reflect.Value, error) {
v := reflect.New(t.typ)
assignValue(v, t.self, reflect.ValueOf(o.Obj))
for _, p := range o.PropSet {
rv, ok := t.props[p.Name]
if !ok {
continue
}
assignValue(v, rv, reflect.ValueOf(p.Val))
}
return v, nil
} | [
"func",
"(",
"t",
"*",
"typeInfo",
")",
"LoadFromObjectContent",
"(",
"o",
"types",
".",
"ObjectContent",
")",
"(",
"reflect",
".",
"Value",
",",
"error",
")",
"{",
"v",
":=",
"reflect",
".",
"New",
"(",
"t",
".",
"typ",
")",
"\n",
"assignValue",
"("... | // LoadObjectFromContent loads properties from the 'PropSet' field in the
// specified ObjectContent value into the value it represents, which is
// returned as a reflect.Value. | [
"LoadObjectFromContent",
"loads",
"properties",
"from",
"the",
"PropSet",
"field",
"in",
"the",
"specified",
"ObjectContent",
"value",
"into",
"the",
"value",
"it",
"represents",
"which",
"is",
"returned",
"as",
"a",
"reflect",
".",
"Value",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/vim25/mo/type_info.go#L245-L258 | train |
vmware/govmomi | simulator/simulator.go | New | func New(instance *ServiceInstance) *Service {
s := &Service{
readAll: ioutil.ReadAll,
sm: Map.SessionManager(),
sdk: make(map[string]*Registry),
}
s.client, _ = vim25.NewClient(context.Background(), s)
return s
} | go | func New(instance *ServiceInstance) *Service {
s := &Service{
readAll: ioutil.ReadAll,
sm: Map.SessionManager(),
sdk: make(map[string]*Registry),
}
s.client, _ = vim25.NewClient(context.Background(), s)
return s
} | [
"func",
"New",
"(",
"instance",
"*",
"ServiceInstance",
")",
"*",
"Service",
"{",
"s",
":=",
"&",
"Service",
"{",
"readAll",
":",
"ioutil",
".",
"ReadAll",
",",
"sm",
":",
"Map",
".",
"SessionManager",
"(",
")",
",",
"sdk",
":",
"make",
"(",
"map",
... | // New returns an initialized simulator Service instance | [
"New",
"returns",
"an",
"initialized",
"simulator",
"Service",
"instance"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/simulator.go#L88-L98 | train |
vmware/govmomi | simulator/simulator.go | Fault | func Fault(msg string, fault types.BaseMethodFault) *soap.Fault {
f := &soap.Fault{
Code: "ServerFaultCode",
String: msg,
}
f.Detail.Fault = fault
return f
} | go | func Fault(msg string, fault types.BaseMethodFault) *soap.Fault {
f := &soap.Fault{
Code: "ServerFaultCode",
String: msg,
}
f.Detail.Fault = fault
return f
} | [
"func",
"Fault",
"(",
"msg",
"string",
",",
"fault",
"types",
".",
"BaseMethodFault",
")",
"*",
"soap",
".",
"Fault",
"{",
"f",
":=",
"&",
"soap",
".",
"Fault",
"{",
"Code",
":",
"\"",
"\"",
",",
"String",
":",
"msg",
",",
"}",
"\n\n",
"f",
".",
... | // Fault wraps the given message and fault in a soap.Fault | [
"Fault",
"wraps",
"the",
"given",
"message",
"and",
"fault",
"in",
"a",
"soap",
".",
"Fault"
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/simulator.go#L111-L120 | train |
vmware/govmomi | simulator/simulator.go | About | func (s *Service) About(w http.ResponseWriter, r *http.Request) {
var about struct {
Methods []string
Types []string
}
seen := make(map[string]bool)
f := reflect.TypeOf((*soap.HasFault)(nil)).Elem()
for _, obj := range Map.objects {
kind := obj.Reference().Type
if seen[kind] {
continue
}
seen[k... | go | func (s *Service) About(w http.ResponseWriter, r *http.Request) {
var about struct {
Methods []string
Types []string
}
seen := make(map[string]bool)
f := reflect.TypeOf((*soap.HasFault)(nil)).Elem()
for _, obj := range Map.objects {
kind := obj.Reference().Type
if seen[kind] {
continue
}
seen[k... | [
"func",
"(",
"s",
"*",
"Service",
")",
"About",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"about",
"struct",
"{",
"Methods",
"[",
"]",
"string",
"\n",
"Types",
"[",
"]",
"string",
"\n",
"}",
... | // About generates some info about the simulator. | [
"About",
"generates",
"some",
"info",
"about",
"the",
"simulator",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/simulator.go#L317-L363 | train |
vmware/govmomi | simulator/simulator.go | Handle | func (s *Service) Handle(pattern string, handler http.Handler) {
s.ServeMux.Handle(pattern, handler)
// Not ideal, but avoids having to add yet another registration mechanism
// so we can optionally use vapi/simulator internally.
if m, ok := handler.(tagManager); ok {
s.sdk[vim25.Path].tagManager = m
}
} | go | func (s *Service) Handle(pattern string, handler http.Handler) {
s.ServeMux.Handle(pattern, handler)
// Not ideal, but avoids having to add yet another registration mechanism
// so we can optionally use vapi/simulator internally.
if m, ok := handler.(tagManager); ok {
s.sdk[vim25.Path].tagManager = m
}
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"Handle",
"(",
"pattern",
"string",
",",
"handler",
"http",
".",
"Handler",
")",
"{",
"s",
".",
"ServeMux",
".",
"Handle",
"(",
"pattern",
",",
"handler",
")",
"\n",
"// Not ideal, but avoids having to add yet another reg... | // Handle registers the handler for the given pattern with Service.ServeMux. | [
"Handle",
"registers",
"the",
"handler",
"for",
"the",
"given",
"pattern",
"with",
"Service",
".",
"ServeMux",
"."
] | fc3f0e9d2275df0e497a80917807a7c72d3c35bc | https://github.com/vmware/govmomi/blob/fc3f0e9d2275df0e497a80917807a7c72d3c35bc/simulator/simulator.go#L366-L373 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.