_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21500 | CreateCategory | train | func (c *Manager) CreateCategory(ctx context.Context, category *Category) (string, error) {
// create avoids the annoyance of CreateTag requiring field keys to be included in the request,
// even though the field value can be empty.
type create struct {
Name string `json:"name"`
Description stri... | go | {
"resource": ""
} |
q21501 | UpdateCategory | train | func (c *Manager) UpdateCategory(ctx context.Context, category *Category) error {
spec := struct {
Category Category `json:"update_spec"`
}{
Category: Category{
AssociableTypes: category.AssociableTypes,
Cardinality: category.Cardinality,
Description: category.Description,
Name: cat... | go | {
"resource": ""
} |
q21502 | DeleteCategory | train | func (c *Manager) DeleteCategory(ctx context.Context, category *Category) error {
url := internal.URL(c, internal.CategoryPath).WithID(category.ID)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | go | {
"resource": ""
} |
q21503 | GetCategory | train | func (c *Manager) GetCategory(ctx context.Context, id string) (*Category, error) {
if isName(id) {
cat, err := c.GetCategories(ctx)
if err != nil {
return nil, err
}
for i := range cat {
if cat[i].Name == id {
return &cat[i], nil
}
}
}
url := internal.URL(c, internal.CategoryPath).WithID(id)
... | go | {
"resource": ""
} |
q21504 | ListCategories | train | func (c *Manager) ListCategories(ctx context.Context) ([]string, error) {
url := internal.URL(c, internal.CategoryPath)
var res []string
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | {
"resource": ""
} |
q21505 | GetCategories | train | func (c *Manager) GetCategories(ctx context.Context) ([]Category, error) {
ids, err := c.ListCategories(ctx)
if err != nil {
return nil, fmt.Errorf("list categories: %s", err)
}
var categories []Category
for _, id := range ids {
category, err := c.GetCategory(ctx, id)
if err != nil {
return nil, fmt.Erro... | go | {
"resource": ""
} |
q21506 | New | train | func New(u *url.URL, settings []vim.BaseOptionValue) (string, http.Handler) {
s := &handler{
ServeMux: http.NewServeMux(),
URL: *u,
Category: make(map[string]*tags.Category),
Tag: make(map[string]*tags.Tag),
Association: make(map[string]map[internal.AssociatedObject]bool),
Session: ... | go | {
"resource": ""
} |
q21507 | AttachedObjects | train | func (s *handler) AttachedObjects(tag vim.VslmTagEntry) ([]vim.ManagedObjectReference, vim.BaseMethodFault) {
t := s.findTag(tag)
if t == nil {
return nil, new(vim.NotFound)
}
var ids []vim.ManagedObjectReference
for id := range s.Association[t.ID] {
ids = append(ids, vim.ManagedObjectReference(id))
}
return... | go | {
"resource": ""
} |
q21508 | AttachedTags | train | func (s *handler) AttachedTags(ref vim.ManagedObjectReference) ([]vim.VslmTagEntry, vim.BaseMethodFault) {
oid := internal.AssociatedObject(ref)
var tags []vim.VslmTagEntry
for id, objs := range s.Association {
if objs[oid] {
tag := s.Tag[id]
cat := s.Category[tag.CategoryID]
tags = append(tags, vim.VslmT... | go | {
"resource": ""
} |
q21509 | AttachTag | train | func (s *handler) AttachTag(ref vim.ManagedObjectReference, tag vim.VslmTagEntry) vim.BaseMethodFault {
t := s.findTag(tag)
if t == nil {
return new(vim.NotFound)
}
s.Association[t.ID][internal.AssociatedObject(ref)] = true
return nil
} | go | {
"resource": ""
} |
q21510 | DetachTag | train | func (s *handler) DetachTag(id vim.ManagedObjectReference, tag vim.VslmTagEntry) vim.BaseMethodFault {
t := s.findTag(tag)
if t == nil {
return new(vim.NotFound)
}
delete(s.Association[t.ID], internal.AssociatedObject(id))
return nil
} | go | {
"resource": ""
} |
q21511 | ok | train | func (s *handler) ok(w http.ResponseWriter, val ...interface{}) {
w.WriteHeader(http.StatusOK)
if len(val) == 0 {
return
}
err := json.NewEncoder(w).Encode(struct {
Value interface{} `json:"value,omitempty"`
}{
val[0],
})
if err != nil {
log.Panic(err)
}
} | go | {
"resource": ""
} |
q21512 | ServeHTTP | train | func (s *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodPost, http.MethodDelete, http.MethodGet, http.MethodPatch, http.MethodPut:
default:
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
h, _ := s.Handler(r)
h.ServeHTTP(w, r)
} | go | {
"resource": ""
} |
q21513 | libraryPath | train | func libraryPath(l *library.Library, id string) string {
// DatastoreID (moref) format is "$local-path@$ds-folder-id",
// see simulator.HostDatastoreSystem.CreateLocalDatastore
ds := strings.SplitN(l.Storage[0].DatastoreID, "@", 2)[0]
return path.Join(append([]string{ds, "contentlib-" + l.ID}, id)...)
} | go | {
"resource": ""
} |
q21514 | NewOVAFile | train | func NewOVAFile(filename string) (*OVAFile, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
tarFile := tar.NewReader(f)
return &OVAFile{filename: filename, file: f, tarFile: tarFile}, nil
} | go | {
"resource": ""
} |
q21515 | Find | train | func (of *OVAFile) Find(filename string) (*tar.Header, error) {
for {
header, err := of.tarFile.Next()
if err == io.EOF {
return nil, err
}
if header.Name == filename {
return header, nil
}
}
} | go | {
"resource": ""
} |
q21516 | Read | train | func (of *OVAFile) Read(b []byte) (int, error) {
if of.tarFile == nil {
return 0, io.EOF
}
return of.tarFile.Read(b)
} | go | {
"resource": ""
} |
q21517 | getOVAFileInfo | train | func getOVAFileInfo(ovafile string, filename string) (int64, string, error) {
of, err := NewOVAFile(ovafile)
if err != nil {
return 0, "", err
}
hdr, err := of.Find(filename)
if err != nil {
return 0, "", err
}
hash := md5.New()
_, err = io.Copy(hash, of)
if err != nil {
return 0, "", err
}
md5String... | go | {
"resource": ""
} |
q21518 | uploadFile | train | func uploadFile(ctx context.Context, m *library.Manager, sessionID string, ovafile string, filename string) error {
var updateFileInfo library.UpdateFile
fmt.Printf("Uploading %s from %s\n", filename, ovafile)
size, md5String, _ := getOVAFileInfo(ovafile, filename)
// Get the URI for the file upload
updateFileI... | go | {
"resource": ""
} |
q21519 | hostsWithDatastore | train | func hostsWithDatastore(hosts []types.ManagedObjectReference, path string) []types.ManagedObjectReference {
attached := hosts[:0]
var p object.DatastorePath
p.FromString(path)
for _, host := range hosts {
h := Map.Get(host).(*HostSystem)
if Map.FindByName(p.Datastore, h.Datastore) != nil {
attached = append... | go | {
"resource": ""
} |
q21520 | Marshal | train | func (e Env) Marshal() (string, error) {
x, err := xml.Marshal(e)
if err != nil {
return "", err
}
return fmt.Sprintf("%s%s", xml.Header, x), nil
} | go | {
"resource": ""
} |
q21521 | MarshalManual | train | func (e Env) MarshalManual() string {
var buffer bytes.Buffer
buffer.WriteString(xml.Header)
buffer.WriteString(fmt.Sprintf(ovfEnvHeader, e.EsxID))
buffer.WriteString(fmt.Sprintf(ovfEnvPlatformSection, e.Platform.Kind, e.Platform.Version, e.Platform.Vendor, e.Platform.Locale))
buffer.WriteString(fmt.Sprint(ovfEn... | go | {
"resource": ""
} |
q21522 | DecodeElement | train | func (d *Decoder) DecodeElement(v interface{}, start *StartElement) error {
val := reflect.ValueOf(v)
if val.Kind() != reflect.Ptr {
return errors.New("non-pointer passed to Unmarshal")
}
return d.unmarshal(val.Elem(), start)
} | go | {
"resource": ""
} |
q21523 | receiverType | train | func receiverType(val interface{}) string {
t := reflect.TypeOf(val)
if t.Name() != "" {
return t.String()
}
return "(" + t.String() + ")"
} | go | {
"resource": ""
} |
q21524 | typeForElement | train | func (p *Decoder) typeForElement(val reflect.Value, start *StartElement) reflect.Type {
t := ""
for i, a := range start.Attr {
if a.Name == xmlSchemaInstance || a.Name == xsiType {
t = a.Value
// HACK: ensure xsi:type is last in the list to avoid using that value for
// a "type" attribute, such as ManagedO... | go | {
"resource": ""
} |
q21525 | unmarshalPath | train | func (p *Decoder) unmarshalPath(tinfo *typeInfo, sv reflect.Value, parents []string, start *StartElement) (consumed bool, err error) {
recurse := false
Loop:
for i := range tinfo.fields {
finfo := &tinfo.fields[i]
if finfo.flags&fElement == 0 || len(finfo.parents) < len(parents) || finfo.xmlns != "" && finfo.xmln... | go | {
"resource": ""
} |
q21526 | Skip | train | func (d *Decoder) Skip() error {
for {
tok, err := d.Token()
if err != nil {
return err
}
switch tok.(type) {
case StartElement:
if err := d.Skip(); err != nil {
return err
}
case EndElement:
return nil
}
}
} | go | {
"resource": ""
} |
q21527 | AddLibraryItemFile | train | func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, updateFile UpdateFile) (*UpdateFileInfo, error) {
url := internal.URL(c, internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("add")
spec := struct {
FileSpec UpdateFile `json:"file_spec"`
}{updateFile}
var res UpdateFileIn... | go | {
"resource": ""
} |
q21528 | AddLibraryItemFileFromURI | train | func (c *Manager) AddLibraryItemFileFromURI(
ctx context.Context,
sessionID, fileName, uri string) (*UpdateFileInfo, error) {
n, fingerprint, err := GetContentLengthAndFingerprint(ctx, uri)
if err != nil {
return nil, err
}
info, err := c.AddLibraryItemFile(ctx, sessionID, UpdateFile{
Name: fileName,
... | go | {
"resource": ""
} |
q21529 | GetLibraryItemUpdateSessionFile | train | func (c *Manager) GetLibraryItemUpdateSessionFile(ctx context.Context, sessionID string, fileName string) (*UpdateFileInfo, error) {
url := internal.URL(c, internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("get")
spec := struct {
Name string `json:"file_name"`
}{fileName}
var res UpdateFileInfo
... | go | {
"resource": ""
} |
q21530 | GetContentLengthAndFingerprint | train | func GetContentLengthAndFingerprint(
ctx context.Context, uri string) (int64, string, error) {
resp, err := http.Head(uri)
if err != nil {
return 0, "", err
}
if resp.TLS == nil || len(resp.TLS.PeerCertificates) == 0 {
return resp.ContentLength, "", nil
}
fingerprint := &bytes.Buffer{}
sum := sha1.Sum(resp.... | go | {
"resource": ""
} |
q21531 | formatMessage | train | func (m *EventManager) formatMessage(event types.BaseEvent) {
id := reflect.ValueOf(event).Elem().Type().Name()
e := event.GetEvent()
t, ok := m.templates[id]
if !ok {
for _, info := range m.Description.EventInfo {
if info.Key == id {
t = template.Must(template.New(id).Parse(info.FullFormat))
m.templa... | go | {
"resource": ""
} |
q21532 | doEntityEventArgument | train | func doEntityEventArgument(event types.BaseEvent, f func(types.ManagedObjectReference, *types.EntityEventArgument) bool) bool {
e := event.GetEvent()
if arg := e.Vm; arg != nil {
if f(arg.Vm, &arg.EntityEventArgument) {
return true
}
}
if arg := e.Host; arg != nil {
if f(arg.Host, &arg.EntityEventArgumen... | go | {
"resource": ""
} |
q21533 | eventFilterSelf | train | func eventFilterSelf(event types.BaseEvent, self types.ManagedObjectReference) bool {
return doEntityEventArgument(event, func(ref types.ManagedObjectReference, _ *types.EntityEventArgument) bool {
return self == ref
})
} | go | {
"resource": ""
} |
q21534 | eventFilterChildren | train | func eventFilterChildren(event types.BaseEvent, self types.ManagedObjectReference) bool {
return doEntityEventArgument(event, func(ref types.ManagedObjectReference, _ *types.EntityEventArgument) bool {
seen := false
var match func(types.ManagedObjectReference)
match = func(child types.ManagedObjectReference) {... | go | {
"resource": ""
} |
q21535 | entityMatches | train | func (c *EventHistoryCollector) entityMatches(event types.BaseEvent, spec *types.EventFilterSpec) bool {
e := spec.Entity
if e == nil {
return true
}
isRootFolder := c.m.root == e.Entity
switch e.Recursion {
case types.EventFilterSpecRecursionOptionSelf:
return isRootFolder || eventFilterSelf(event, e.Entit... | go | {
"resource": ""
} |
q21536 | typeMatches | train | func (c *EventHistoryCollector) typeMatches(event types.BaseEvent, spec *types.EventFilterSpec) bool {
if len(spec.EventTypeId) == 0 {
return true
}
matches := func(name string) bool {
for _, id := range spec.EventTypeId {
if id == name {
return true
}
}
return false
}
kind := reflect.ValueOf(ev... | go | {
"resource": ""
} |
q21537 | eventMatches | train | func (c *EventHistoryCollector) eventMatches(event types.BaseEvent) bool {
spec := c.Filter.(types.EventFilterSpec)
if !c.typeMatches(event, &spec) {
return false
}
// TODO: spec.Time, spec.UserName, etc
return c.entityMatches(event, &spec)
} | go | {
"resource": ""
} |
q21538 | fillPage | train | func (c *EventHistoryCollector) fillPage(size int) {
c.pos = 0
l := c.page.Len()
delta := size - l
if delta < 0 {
// Shrink ring size
c.page = c.page.Unlink(-delta)
return
}
matches := 0
mpage := c.m.page
page := c.page
if delta != 0 {
// Grow ring size
c.page = c.page.Link(ring.New(delta))
}
f... | go | {
"resource": ""
} |
q21539 | CopyVirtualDisk | train | func (m VirtualDiskManager) CopyVirtualDisk(
ctx context.Context,
sourceName string, sourceDatacenter *Datacenter,
destName string, destDatacenter *Datacenter,
destSpec *types.VirtualDiskSpec, force bool) (*Task, error) {
req := types.CopyVirtualDisk_Task{
This: m.Reference(),
SourceName: sourceName,
... | go | {
"resource": ""
} |
q21540 | CreateVirtualDisk | train | func (m VirtualDiskManager) CreateVirtualDisk(
ctx context.Context,
name string, datacenter *Datacenter,
spec types.BaseVirtualDiskSpec) (*Task, error) {
req := types.CreateVirtualDisk_Task{
This: m.Reference(),
Name: name,
Spec: spec,
}
if datacenter != nil {
ref := datacenter.Reference()
req.Datacen... | go | {
"resource": ""
} |
q21541 | ShrinkVirtualDisk | train | func (m VirtualDiskManager) ShrinkVirtualDisk(ctx context.Context, name string, dc *Datacenter, copy *bool) (*Task, error) {
req := types.ShrinkVirtualDisk_Task{
This: m.Reference(),
Name: name,
Copy: copy,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.ShrinkVirtual... | go | {
"resource": ""
} |
q21542 | QueryVirtualDiskUuid | train | func (m VirtualDiskManager) QueryVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter) (string, error) {
req := types.QueryVirtualDiskUuid{
This: m.Reference(),
Name: name,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
res, err := methods.QueryVirtualDiskUuid(ctx, m.c, &req)
... | go | {
"resource": ""
} |
q21543 | NewService | train | func NewService(rpcIn Channel, rpcOut Channel) *Service {
s := &Service{
name: "toolbox", // Same name used by vmtoolsd
in: NewTraceChannel(rpcIn),
out: &ChannelOut{NewTraceChannel(rpcOut)},
handlers: make(map[string]Handler),
wg: new(sync.WaitGroup),
stop: make(chan struct{}),
... | go | {
"resource": ""
} |
q21544 | backoff | train | func (s *Service) backoff() {
if s.delay < maxDelay {
if s.delay > 0 {
d := s.delay * 2
if d > s.delay && d < maxDelay {
s.delay = d
} else {
s.delay = maxDelay
}
} else {
s.delay = 1
}
}
} | go | {
"resource": ""
} |
q21545 | Start | train | func (s *Service) Start() error {
err := s.startChannel()
if err != nil {
return err
}
s.wg.Add(1)
go func() {
defer s.wg.Done()
// Same polling interval and backoff logic as vmtoolsd.
// Required in our case at startup at least, otherwise it is possible
// we miss the 1 Capabilities_Register call for ... | go | {
"resource": ""
} |
q21546 | RegisterHandler | train | func (s *Service) RegisterHandler(name string, handler Handler) {
s.handlers[name] = handler
} | go | {
"resource": ""
} |
q21547 | Dispatch | train | func (s *Service) Dispatch(request []byte) []byte {
msg := bytes.SplitN(request, []byte{' '}, 2)
name := msg[0]
// Trim NULL byte terminator
name = bytes.TrimRight(name, "\x00")
handler, ok := s.handlers[string(name)]
if !ok {
log.Printf("unknown command: %q\n", name)
return []byte("Unknown Command")
}
... | go | {
"resource": ""
} |
q21548 | Reset | train | func (s *Service) Reset([]byte) ([]byte, error) {
s.SendGuestInfo() // Send the IP info ASAP
return []byte("ATR " + s.name), nil
} | go | {
"resource": ""
} |
q21549 | SetOption | train | func (s *Service) SetOption(args []byte) ([]byte, error) {
opts := bytes.SplitN(args, []byte{' '}, 2)
key := string(opts[0])
val := string(opts[1])
if Trace {
fmt.Fprintf(os.Stderr, "set option %q=%q\n", key, val)
}
switch key {
case "broadcastIP": // TODO: const-ify
if val == "1" {
ip := s.PrimaryIP()
... | go | {
"resource": ""
} |
q21550 | DefaultIP | train | func DefaultIP() string {
addrs, err := netInterfaceAddrs()
if err == nil {
for _, addr := range addrs {
if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
if ip.IP.To4() != nil {
return ip.IP.String()
}
}
}
}
return ""
} | go | {
"resource": ""
} |
q21551 | CreateDirectory | train | func (nm DatastoreNamespaceManager) CreateDirectory(ctx context.Context, ds *Datastore, displayName string, policy string) (string, error) {
req := &types.CreateDirectory{
This: nm.Reference(),
Datastore: ds.Reference(),
DisplayName: displayName,
Policy: policy,
}
resp, err := methods.CreateD... | go | {
"resource": ""
} |
q21552 | DeleteDirectory | train | func (nm DatastoreNamespaceManager) DeleteDirectory(ctx context.Context, dc *Datacenter, datastorePath string) error {
req := &types.DeleteDirectory{
This: nm.Reference(),
DatastorePath: datastorePath,
}
if dc != nil {
ref := dc.Reference()
req.Datacenter = &ref
}
if _, err := methods.DeleteDir... | go | {
"resource": ""
} |
q21553 | NewManager | train | func NewManager(client *vim25.Client) *Manager {
m := Manager{
Common: object.NewCommon(client, *client.ServiceContent.PerfManager),
}
m.pm.PerformanceManager = new(mo.PerformanceManager)
return &m
} | go | {
"resource": ""
} |
q21554 | HistoricalInterval | train | func (m *Manager) HistoricalInterval(ctx context.Context) (IntervalList, error) {
var pm mo.PerformanceManager
err := m.Properties(ctx, m.Reference(), []string{"historicalInterval"}, &pm)
if err != nil {
return nil, err
}
return IntervalList(pm.HistoricalInterval), nil
} | go | {
"resource": ""
} |
q21555 | CounterInfo | train | func (m *Manager) CounterInfo(ctx context.Context) ([]types.PerfCounterInfo, error) {
m.pm.Lock()
defer m.pm.Unlock()
if len(m.pm.PerfCounter) == 0 {
err := m.Properties(ctx, m.Reference(), []string{"perfCounter"}, m.pm.PerformanceManager)
if err != nil {
return nil, err
}
}
return m.pm.PerfCounter, nil... | go | {
"resource": ""
} |
q21556 | CounterInfoByKey | train | func (m *Manager) CounterInfoByKey(ctx context.Context) (map[int32]*types.PerfCounterInfo, error) {
m.infoByKey.Lock()
defer m.infoByKey.Unlock()
if m.infoByKey.m != nil {
return m.infoByKey.m, nil
}
info, err := m.CounterInfo(ctx)
if err != nil {
return nil, err
}
m.infoByKey.m = make(map[int32]*types.P... | go | {
"resource": ""
} |
q21557 | ProviderSummary | train | func (m *Manager) ProviderSummary(ctx context.Context, entity types.ManagedObjectReference) (*types.PerfProviderSummary, error) {
req := types.QueryPerfProviderSummary{
This: m.Reference(),
Entity: entity,
}
res, err := methods.QueryPerfProviderSummary(ctx, m.Client(), &req)
if err != nil {
return nil, err... | go | {
"resource": ""
} |
q21558 | AvailableMetric | train | func (m *Manager) AvailableMetric(ctx context.Context, entity types.ManagedObjectReference, interval int32) (MetricList, error) {
req := types.QueryAvailablePerfMetric{
This: m.Reference(),
Entity: entity.Reference(),
IntervalId: interval,
}
res, err := methods.QueryAvailablePerfMetric(ctx, m.Client... | go | {
"resource": ""
} |
q21559 | Query | train | func (m *Manager) Query(ctx context.Context, spec []types.PerfQuerySpec) ([]types.BasePerfEntityMetricBase, error) {
req := types.QueryPerf{
This: m.Reference(),
QuerySpec: spec,
}
res, err := methods.QueryPerf(ctx, m.Client(), &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
} | go | {
"resource": ""
} |
q21560 | ValueCSV | train | func (s *MetricSeries) ValueCSV() string {
vals := make([]string, len(s.Value))
for i := range s.Value {
vals[i] = s.Format(s.Value[i])
}
return strings.Join(vals, ",")
} | go | {
"resource": ""
} |
q21561 | SampleInfoCSV | train | func (m *EntityMetric) SampleInfoCSV() string {
vals := make([]string, len(m.SampleInfo)*2)
i := 0
for _, s := range m.SampleInfo {
vals[i] = s.Timestamp.Format(time.RFC3339)
i++
vals[i] = strconv.Itoa(int(s.Interval))
i++
}
return strings.Join(vals, ",")
} | go | {
"resource": ""
} |
q21562 | Spec | train | func (flag *HostConnectFlag) Spec(c *vim25.Client) types.HostConnectSpec {
spec := flag.HostConnectSpec
if spec.SslThumbprint == "" {
spec.SslThumbprint = c.Thumbprint(spec.HostName)
if spec.SslThumbprint == "" && flag.noverify {
var info object.HostCertificateInfo
t := c.Transport.(*http.Transport)
_ ... | go | {
"resource": ""
} |
q21563 | Fault | train | func (flag *HostConnectFlag) Fault(err error) error {
if err == nil {
return nil
}
if f, ok := err.(types.HasFault); ok {
switch fault := f.Fault().(type) {
case *types.SSLVerifyFault:
return fmt.Errorf("%s thumbprint=%s", err, fault.Thumbprint)
}
}
return err
} | go | {
"resource": ""
} |
q21564 | Run | train | func (c *Client) Run(ctx context.Context, cmd *exec.Cmd) error {
vc := c.ProcessManager.Client()
spec := types.GuestProgramSpec{
ProgramPath: cmd.Path,
Arguments: strings.Join(cmd.Args, " "),
EnvVariables: cmd.Env,
WorkingDirectory: cmd.Dir,
}
pid, serr := c.ProcessManager.StartProgram(ctx... | go | {
"resource": ""
} |
q21565 | Download | train | func (c *Client) Download(ctx context.Context, src string) (io.ReadCloser, int64, error) {
vc := c.ProcessManager.Client()
info, err := c.FileManager.InitiateFileTransferFromGuest(ctx, c.Authentication, src)
if err != nil {
return nil, 0, err
}
u, err := c.FileManager.TransferURL(ctx, info.Url)
if err != nil ... | go | {
"resource": ""
} |
q21566 | Upload | train | func (c *Client) Upload(ctx context.Context, src io.Reader, dst string, p soap.Upload, attr types.BaseGuestFileAttributes, force bool) error {
vc := c.ProcessManager.Client()
var err error
if p.ContentLength == 0 { // Content-Length is required
switch r := src.(type) {
case *bytes.Buffer:
p.ContentLength = ... | go | {
"resource": ""
} |
q21567 | ByRule | train | func (l HostFirewallRulesetList) ByRule(rule types.HostFirewallRule) HostFirewallRulesetList {
var matches HostFirewallRulesetList
for _, rs := range l {
for _, r := range rs.Rule {
if r.PortType != rule.PortType ||
r.Protocol != rule.Protocol ||
r.Direction != rule.Direction {
continue
}
if ... | go | {
"resource": ""
} |
q21568 | Enabled | train | func (l HostFirewallRulesetList) Enabled() HostFirewallRulesetList {
var matches HostFirewallRulesetList
for _, rs := range l {
if rs.Enabled {
matches = append(matches, rs)
}
}
return matches
} | go | {
"resource": ""
} |
q21569 | Keys | train | func (l HostFirewallRulesetList) Keys() []string {
var keys []string
for _, rs := range l {
keys = append(keys, rs.Key)
}
return keys
} | go | {
"resource": ""
} |
q21570 | CopyToken | train | func CopyToken(t Token) Token {
switch v := t.(type) {
case CharData:
return v.Copy()
case Comment:
return v.Copy()
case Directive:
return v.Copy()
case ProcInst:
return v.Copy()
case StartElement:
return v.Copy()
}
return t
} | go | {
"resource": ""
} |
q21571 | NewDecoder | train | func NewDecoder(r io.Reader) *Decoder {
d := &Decoder{
ns: make(map[string]string),
nextByte: -1,
line: 1,
Strict: true,
}
d.switchToReader(r)
return d
} | go | {
"resource": ""
} |
q21572 | popEOF | train | func (d *Decoder) popEOF() bool {
if d.stk == nil || d.stk.kind != stkEOF {
return false
}
d.pop()
return true
} | go | {
"resource": ""
} |
q21573 | pushElement | train | func (d *Decoder) pushElement(name Name) {
s := d.push(stkStart)
s.name = name
} | go | {
"resource": ""
} |
q21574 | syntaxError | train | func (d *Decoder) syntaxError(msg string) error {
return &SyntaxError{Msg: msg, Line: d.line}
} | go | {
"resource": ""
} |
q21575 | popElement | train | func (d *Decoder) popElement(t *EndElement) bool {
s := d.pop()
name := t.Name
switch {
case s == nil || s.kind != stkStart:
d.err = d.syntaxError("unexpected end element </" + name.Local + ">")
return false
case s.name.Local != name.Local:
if !d.Strict {
d.needClose = true
d.toClose = t.Name
t.Name... | go | {
"resource": ""
} |
q21576 | autoClose | train | 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 | {
"resource": ""
} |
q21577 | RawToken | train | func (d *Decoder) RawToken() (Token, error) {
if d.unmarshalDepth > 0 {
return nil, errRawToken
}
return d.rawToken()
} | go | {
"resource": ""
} |
q21578 | space | train | func (d *Decoder) space() {
for {
b, ok := d.getc()
if !ok {
return
}
switch b {
case ' ', '\r', '\n', '\t':
default:
d.ungetc(b)
return
}
}
} | go | {
"resource": ""
} |
q21579 | getc | train | 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 | {
"resource": ""
} |
q21580 | readName | train | 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 | {
"resource": ""
} |
q21581 | procInstEncoding | train | 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 | {
"resource": ""
} |
q21582 | EthernetCardBackingInfo | train | 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 | {
"resource": ""
} |
q21583 | AddPortGroup | train | 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 | {
"resource": ""
} |
q21584 | AddServiceConsoleVirtualNic | train | 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 | {
"resource": ""
} |
q21585 | AddVirtualSwitch | train | 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 | {
"resource": ""
} |
q21586 | QueryNetworkHint | train | 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 | {
"resource": ""
} |
q21587 | RefreshNetworkSystem | train | 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 | {
"resource": ""
} |
q21588 | RemovePortGroup | train | 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 | {
"resource": ""
} |
q21589 | RemoveVirtualSwitch | train | 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 | {
"resource": ""
} |
q21590 | UpdateConsoleIpRouteConfig | train | 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 | {
"resource": ""
} |
q21591 | UpdateNetworkConfig | train | 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 | {
"resource": ""
} |
q21592 | UpdatePhysicalNicLinkSpeed | train | 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 | {
"resource": ""
} |
q21593 | UpdatePortGroup | train | 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 | {
"resource": ""
} |
q21594 | UpdateVirtualNic | train | 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 | {
"resource": ""
} |
q21595 | CreateTaskView | train | 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 | {
"resource": ""
} |
q21596 | Collect | train | 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 | {
"resource": ""
} |
q21597 | DeployLibraryItem | train | 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 | {
"resource": ""
} |
q21598 | FilterLibraryItem | train | 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 | {
"resource": ""
} |
q21599 | NewClient | train | func NewClient(c *vim25.Client) *Client {
sc := c.Client.NewServiceClient(internal.Path, "")
return &Client{sc}
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.