_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21300 | RevertToCurrentSnapshot | train | func (v VirtualMachine) RevertToCurrentSnapshot(ctx context.Context, suppressPowerOn bool) (*Task, error) {
req := types.RevertToCurrentSnapshot_Task{
This: v.Reference(),
SuppressPowerOn: types.NewBool(suppressPowerOn),
}
res, err := methods.RevertToCurrentSnapshot_Task(ctx, v.c, &req)
if err != ni... | go | {
"resource": ""
} |
q21301 | RevertToSnapshot | train | func (v VirtualMachine) RevertToSnapshot(ctx context.Context, name string, suppressPowerOn bool) (*Task, error) {
snapshot, err := v.FindSnapshot(ctx, name)
if err != nil {
return nil, err
}
req := types.RevertToSnapshot_Task{
This: snapshot.Reference(),
SuppressPowerOn: types.NewBool(suppressPowe... | go | {
"resource": ""
} |
q21302 | IsToolsRunning | train | func (v VirtualMachine) IsToolsRunning(ctx context.Context) (bool, error) {
var o mo.VirtualMachine
err := v.Properties(ctx, v.Reference(), []string{"guest.toolsRunningStatus"}, &o)
if err != nil {
return false, err
}
return o.Guest.ToolsRunningStatus == string(types.VirtualMachineToolsRunningStatusGuestToolsR... | go | {
"resource": ""
} |
q21303 | WaitForPowerState | train | func (v VirtualMachine) WaitForPowerState(ctx context.Context, state types.VirtualMachinePowerState) error {
p := property.DefaultCollector(v.c)
err := property.Wait(ctx, p, v.Reference(), []string{PropRuntimePowerState}, func(pc []types.PropertyChange) bool {
for _, c := range pc {
if c.Name != PropRuntimePower... | go | {
"resource": ""
} |
q21304 | QueryConfigTarget | train | func (v VirtualMachine) QueryConfigTarget(ctx context.Context) (*types.ConfigTarget, error) {
var vm mo.VirtualMachine
err := v.Properties(ctx, v.Reference(), []string{"environmentBrowser"}, &vm)
if err != nil {
return nil, err
}
req := types.QueryConfigTarget{
This: vm.EnvironmentBrowser,
}
res, err := m... | go | {
"resource": ""
} |
q21305 | UUID | train | func (v VirtualMachine) UUID(ctx context.Context) string {
var o mo.VirtualMachine
err := v.Properties(ctx, v.Reference(), []string{"config.uuid"}, &o)
if err != nil {
return ""
}
return o.Config.Uuid
} | go | {
"resource": ""
} |
q21306 | typeToString | train | func typeToString(typ reflect.Type) string {
switch typ.Kind() {
case reflect.Bool:
return "xsd:boolean"
case reflect.Int8:
return "xsd:byte"
case reflect.Int16:
return "xsd:short"
case reflect.Int32:
return "xsd:int"
case reflect.Int, reflect.Int64:
return "xsd:long"
case reflect.Uint8:
return "xsd:... | go | {
"resource": ""
} |
q21307 | inspect | train | func (c *container) inspect(vm *VirtualMachine) error {
if c.id == "" {
return nil
}
var objects []struct {
NetworkSettings struct {
Gateway string
IPAddress string
IPPrefixLen int
MacAddress string
}
}
cmd := exec.Command("docker", "inspect", c.id)
out, err := cmd.Output()
if err != n... | go | {
"resource": ""
} |
q21308 | start | train | func (c *container) start(vm *VirtualMachine) {
if c.id != "" {
start := "start"
if vm.Runtime.PowerState == types.VirtualMachinePowerStateSuspended {
start = "unpause"
}
cmd := exec.Command("docker", start, c.id)
err := cmd.Run()
if err != nil {
log.Printf("%s %s: %s", vm.Name, cmd.Args, err)
}
... | go | {
"resource": ""
} |
q21309 | Login | train | func (c *Client) Login(ctx context.Context, u *url.Userinfo) error {
return c.SessionManager.Login(ctx, u)
} | go | {
"resource": ""
} |
q21310 | Logout | train | func (c *Client) Logout(ctx context.Context) error {
// Close any idle connections after logging out.
defer c.Client.CloseIdleConnections()
return c.SessionManager.Logout(ctx)
} | go | {
"resource": ""
} |
q21311 | RetrieveOne | train | func (c *Client) RetrieveOne(ctx context.Context, obj types.ManagedObjectReference, p []string, dst interface{}) error {
return c.PropertyCollector().RetrieveOne(ctx, obj, p, dst)
} | go | {
"resource": ""
} |
q21312 | Retrieve | train | func (c *Client) Retrieve(ctx context.Context, objs []types.ManagedObjectReference, p []string, dst interface{}) error {
return c.PropertyCollector().Retrieve(ctx, objs, p, dst)
} | go | {
"resource": ""
} |
q21313 | Wait | train | func (c *Client) Wait(ctx context.Context, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error {
return property.Wait(ctx, c.PropertyCollector(), obj, ps, f)
} | go | {
"resource": ""
} |
q21314 | NewClient | train | func NewClient(ctx context.Context, c *vim25.Client) (*Client, error) {
filter := &types.LookupServiceRegistrationFilter{
ServiceType: &types.LookupServiceRegistrationServiceType{
Product: "com.vmware.cis",
Type: "sso:sts",
},
EndpointType: &types.LookupServiceRegistrationEndpointType{
Protocol: "wsT... | go | {
"resource": ""
} |
q21315 | Renew | train | func (c *Client) Renew(ctx context.Context, req TokenRequest) (*Signer, error) {
s := &Signer{
Certificate: req.Certificate,
}
rst, err := c.newRequest(req, "Renew", s)
if err != nil {
return nil, err
}
if req.Token == "" {
return nil, errors.New("TokenRequest Token is required")
}
rst.RenewTarget = &i... | go | {
"resource": ""
} |
q21316 | QueryVsanObjectUuidsByFilter | train | func (m HostVsanInternalSystem) QueryVsanObjectUuidsByFilter(ctx context.Context, uuids []string, limit int32, version int32) ([]string, error) {
req := types.QueryVsanObjectUuidsByFilter{
This: m.Reference(),
Uuids: uuids,
Limit: &limit,
Version: version,
}
res, err := methods.QueryVsanObjectUuidsBy... | go | {
"resource": ""
} |
q21317 | NewURL | train | func (d Datastore) NewURL(path string) *url.URL {
u := d.c.URL()
return &url.URL{
Scheme: u.Scheme,
Host: u.Host,
Path: fmt.Sprintf("/folder/%s", path),
RawQuery: url.Values{
"dcPath": []string{d.DatacenterPath},
"dsName": []string{d.Name()},
}.Encode(),
}
} | go | {
"resource": ""
} |
q21318 | URL | train | func (d Datastore) URL(ctx context.Context, dc *Datacenter, path string) (*url.URL, error) {
return d.NewURL(path), nil
} | go | {
"resource": ""
} |
q21319 | HostContext | train | func (d Datastore) HostContext(ctx context.Context, host *HostSystem) context.Context {
return context.WithValue(ctx, datastoreServiceTicketHostKey{}, host)
} | go | {
"resource": ""
} |
q21320 | ServiceTicket | train | func (d Datastore) ServiceTicket(ctx context.Context, path string, method string) (*url.URL, *http.Cookie, error) {
u := d.NewURL(path)
host, ok := ctx.Value(datastoreServiceTicketHostKey{}).(*HostSystem)
if !ok {
if !d.useServiceTicket() {
return u, nil, nil
}
hosts, err := d.AttachedHosts(ctx)
if err... | go | {
"resource": ""
} |
q21321 | Upload | train | func (d Datastore) Upload(ctx context.Context, f io.Reader, path string, param *soap.Upload) error {
u, p, err := d.uploadTicket(ctx, path, param)
if err != nil {
return err
}
return d.Client().Upload(ctx, f, u, p)
} | go | {
"resource": ""
} |
q21322 | UploadFile | train | func (d Datastore) UploadFile(ctx context.Context, file string, path string, param *soap.Upload) error {
u, p, err := d.uploadTicket(ctx, path, param)
if err != nil {
return err
}
return d.Client().UploadFile(ctx, file, u, p)
} | go | {
"resource": ""
} |
q21323 | Download | train | func (d Datastore) Download(ctx context.Context, path string, param *soap.Download) (io.ReadCloser, int64, error) {
u, p, err := d.downloadTicket(ctx, path, param)
if err != nil {
return nil, 0, err
}
return d.Client().Download(ctx, u, p)
} | go | {
"resource": ""
} |
q21324 | DownloadFile | train | func (d Datastore) DownloadFile(ctx context.Context, path string, file string, param *soap.Download) error {
u, p, err := d.downloadTicket(ctx, path, param)
if err != nil {
return err
}
return d.Client().DownloadFile(ctx, file, u, p)
} | go | {
"resource": ""
} |
q21325 | AttachedHosts | train | func (d Datastore) AttachedHosts(ctx context.Context) ([]*HostSystem, error) {
var ds mo.Datastore
var hosts []*HostSystem
pc := property.DefaultCollector(d.Client())
err := pc.RetrieveOne(ctx, d.Reference(), []string{"host"}, &ds)
if err != nil {
return nil, err
}
mounts := make(map[types.ManagedObjectRefer... | go | {
"resource": ""
} |
q21326 | AttachedClusterHosts | train | func (d Datastore) AttachedClusterHosts(ctx context.Context, cluster *ComputeResource) ([]*HostSystem, error) {
var hosts []*HostSystem
clusterHosts, err := cluster.Hosts(ctx)
if err != nil {
return nil, err
}
attachedHosts, err := d.AttachedHosts(ctx)
if err != nil {
return nil, err
}
refs := make(map[t... | go | {
"resource": ""
} |
q21327 | Type | train | func (d Datastore) Type(ctx context.Context) (types.HostFileSystemVolumeFileSystemType, error) {
var mds mo.Datastore
if err := d.Properties(ctx, d.Reference(), []string{"summary.type"}, &mds); err != nil {
return types.HostFileSystemVolumeFileSystemType(""), err
}
return types.HostFileSystemVolumeFileSystemType... | go | {
"resource": ""
} |
q21328 | NewAssociation | train | func NewAssociation(ref mo.Reference) Association {
obj := AssociatedObject(ref.Reference())
return Association{
ObjectID: &obj,
}
} | go | {
"resource": ""
} |
q21329 | URL | train | func URL(c CloneURL, path string) *Resource {
r := &Resource{u: c.URL()}
r.u.Path = Path + path
return r
} | go | {
"resource": ""
} |
q21330 | WithID | train | func (r *Resource) WithID(id string) *Resource {
r.u.Path += "/id:" + id
return r
} | go | {
"resource": ""
} |
q21331 | WithAction | train | func (r *Resource) WithAction(action string) *Resource {
r.u.RawQuery = url.Values{
"~action": []string{action},
}.Encode()
return r
} | go | {
"resource": ""
} |
q21332 | WithParameter | train | func (r *Resource) WithParameter(name string, value string) *Resource {
parameter := url.Values{}
parameter.Set(name, value)
r.u.RawQuery = parameter.Encode()
return r
} | go | {
"resource": ""
} |
q21333 | Request | train | func (r *Resource) Request(method string, body ...interface{}) *http.Request {
rdr := io.MultiReader() // empty body by default
if len(body) != 0 {
rdr = encode(body[0])
}
req, err := http.NewRequest(method, r.u.String(), rdr)
if err != nil {
panic(err)
}
return req
} | go | {
"resource": ""
} |
q21334 | encode | train | func encode(body interface{}) io.Reader {
var b bytes.Buffer
err := json.NewEncoder(&b).Encode(body)
if err != nil {
return errorReader{err}
}
return &b
} | go | {
"resource": ""
} |
q21335 | NewClient | train | func NewClient(ctx context.Context, rt soap.RoundTripper) (*Client, error) {
c := Client{
RoundTripper: rt,
}
// Set client if it happens to be a soap.Client
if sc, ok := rt.(*soap.Client); ok {
c.Client = sc
if c.Namespace == "" {
c.Namespace = "urn:" + Namespace
} else if !strings.Contains(c.Namespac... | go | {
"resource": ""
} |
q21336 | RoundTrip | train | func (c *Client) RoundTrip(ctx context.Context, req, res soap.HasFault) error {
return c.RoundTripper.RoundTrip(ctx, req, res)
} | go | {
"resource": ""
} |
q21337 | Valid | train | func (c *Client) Valid() bool {
if c == nil {
return false
}
if c.Client == nil {
return false
}
// Use arbitrary pointer field in the service content.
// Doesn't matter which one, as long as it is populated by default.
if c.ServiceContent.SessionManager == nil {
return false
}
return true
} | go | {
"resource": ""
} |
q21338 | taskName | train | func taskName(info *types.TaskInfo) string {
name := strings.TrimSuffix(info.Name, "_Task")
switch name {
case "":
return info.DescriptionId
case "Destroy", "Rename":
return info.Entity.Type + "." + name
default:
return name
}
} | go | {
"resource": ""
} |
q21339 | NewCustomDatastoreFlag | train | func NewCustomDatastoreFlag(ctx context.Context) (*DatastoreFlag, context.Context) {
v := &DatastoreFlag{}
v.DatacenterFlag, ctx = NewDatacenterFlag(ctx)
return v, ctx
} | go | {
"resource": ""
} |
q21340 | NewFileManager | train | func (d Datastore) NewFileManager(dc *Datacenter, force bool) *DatastoreFileManager {
c := d.Client()
m := &DatastoreFileManager{
Datacenter: dc,
Datastore: &d,
FileManager: NewFileManager(c),
VirtualDiskManager: NewVirtualDiskManager(c),
Force: force,
DatacenterTarge... | go | {
"resource": ""
} |
q21341 | Delete | train | func (m *DatastoreFileManager) Delete(ctx context.Context, name string) error {
switch path.Ext(name) {
case ".vmdk":
return m.DeleteVirtualDisk(ctx, name)
default:
return m.DeleteFile(ctx, name)
}
} | go | {
"resource": ""
} |
q21342 | DeleteFile | train | func (m *DatastoreFileManager) DeleteFile(ctx context.Context, name string) error {
p := m.Path(name)
task, err := m.FileManager.DeleteDatastoreFile(ctx, p.String(), m.Datacenter)
if err != nil {
return err
}
return m.wait(ctx, task)
} | go | {
"resource": ""
} |
q21343 | DeleteVirtualDisk | train | func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Context, name string) error {
p := m.Path(name)
var merr error
if m.Force {
merr = m.markDiskAsDeletable(ctx, p)
}
task, err := m.VirtualDiskManager.DeleteVirtualDisk(ctx, p.String(), m.Datacenter)
if err != nil {
log.Printf("markDiskAsDeletable(... | go | {
"resource": ""
} |
q21344 | Copy | train | func (m *DatastoreFileManager) Copy(ctx context.Context, src string, dst string) error {
srcp := m.Path(src)
dstp := m.Path(dst)
f := m.FileManager.CopyDatastoreFile
if srcp.IsVMDK() {
// types.VirtualDiskSpec=nil as it is not implemented by vCenter
f = func(ctx context.Context, src string, srcDC *Datacenter,... | go | {
"resource": ""
} |
q21345 | MoveFile | train | func (m *DatastoreFileManager) MoveFile(ctx context.Context, src string, dst string) error {
srcp := m.Path(src)
dstp := m.Path(dst)
task, err := m.FileManager.MoveDatastoreFile(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force)
if err != nil {
return err
}
return m.wait(ctx, task)
... | go | {
"resource": ""
} |
q21346 | Move | train | func (m *DatastoreFileManager) Move(ctx context.Context, src string, dst string) error {
srcp := m.Path(src)
dstp := m.Path(dst)
f := m.FileManager.MoveDatastoreFile
if srcp.IsVMDK() {
f = m.VirtualDiskManager.MoveVirtualDisk
}
task, err := f(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarge... | go | {
"resource": ""
} |
q21347 | Path | train | func (m *DatastoreFileManager) Path(name string) *DatastorePath {
var p DatastorePath
if !p.FromString(name) {
p.Path = name
p.Datastore = m.Datastore.Name()
}
return &p
} | go | {
"resource": ""
} |
q21348 | Abort | train | func (l *Lease) Abort(ctx context.Context, fault *types.LocalizedMethodFault) error {
req := types.HttpNfcLeaseAbort{
This: l.Reference(),
Fault: fault,
}
_, err := methods.HttpNfcLeaseAbort(ctx, l.c, &req)
if err != nil {
return err
}
return nil
} | go | {
"resource": ""
} |
q21349 | Complete | train | func (l *Lease) Complete(ctx context.Context) error {
req := types.HttpNfcLeaseComplete{
This: l.Reference(),
}
_, err := methods.HttpNfcLeaseComplete(ctx, l.c, &req)
if err != nil {
return err
}
return nil
} | go | {
"resource": ""
} |
q21350 | GetManifest | train | func (l *Lease) GetManifest(ctx context.Context) error {
req := types.HttpNfcLeaseGetManifest{
This: l.Reference(),
}
_, err := methods.HttpNfcLeaseGetManifest(ctx, l.c, &req)
if err != nil {
return err
}
return nil
} | go | {
"resource": ""
} |
q21351 | Progress | train | func (l *Lease) Progress(ctx context.Context, percent int32) error {
req := types.HttpNfcLeaseProgress{
This: l.Reference(),
Percent: percent,
}
_, err := methods.HttpNfcLeaseProgress(ctx, l.c, &req)
if err != nil {
return err
}
return nil
} | go | {
"resource": ""
} |
q21352 | FindLibrary | train | func (c *Manager) FindLibrary(ctx context.Context, search Find) ([]string, error) {
url := internal.URL(c, internal.LibraryPath).WithAction("find")
spec := struct {
Spec Find `json:"spec"`
}{search}
var res []string
return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
} | go | {
"resource": ""
} |
q21353 | CreateLibrary | train | func (c *Manager) CreateLibrary(ctx context.Context, library Library) (string, error) {
if library.Type != "LOCAL" {
return "", fmt.Errorf("unsupported library type: %q", library.Type)
}
spec := struct {
Library Library `json:"create_spec"`
}{library}
url := internal.URL(c, internal.LocalLibraryPath)
var res ... | go | {
"resource": ""
} |
q21354 | DeleteLibrary | train | func (c *Manager) DeleteLibrary(ctx context.Context, library *Library) error {
url := internal.URL(c, internal.LocalLibraryPath).WithID(library.ID)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | go | {
"resource": ""
} |
q21355 | ListLibraries | train | func (c *Manager) ListLibraries(ctx context.Context) ([]string, error) {
url := internal.URL(c, internal.LibraryPath)
var res []string
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | {
"resource": ""
} |
q21356 | GetLibraryByID | train | func (c *Manager) GetLibraryByID(ctx context.Context, id string) (*Library, error) {
url := internal.URL(c, internal.LibraryPath).WithID(id)
var res Library
return &res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | {
"resource": ""
} |
q21357 | GetLibraryByName | train | func (c *Manager) GetLibraryByName(ctx context.Context, name string) (*Library, error) {
// Lookup by name
libraries, err := c.GetLibraries(ctx)
if err != nil {
return nil, err
}
for i := range libraries {
if libraries[i].Name == name {
return &libraries[i], nil
}
}
return nil, fmt.Errorf("library name ... | go | {
"resource": ""
} |
q21358 | GetLibraries | train | func (c *Manager) GetLibraries(ctx context.Context) ([]Library, error) {
ids, err := c.ListLibraries(ctx)
if err != nil {
return nil, fmt.Errorf("get libraries failed for: %s", err)
}
var libraries []Library
for _, id := range ids {
library, err := c.GetLibraryByID(ctx, id)
if err != nil {
return nil, fm... | go | {
"resource": ""
} |
q21359 | wrapValue | train | func wrapValue(rval reflect.Value, rtype reflect.Type) interface{} {
pval := rval.Interface()
if rval.Kind() == reflect.Slice {
// Convert slice to types.ArrayOf*
switch v := pval.(type) {
case []string:
pval = &types.ArrayOfString{
String: v,
}
case []uint8:
pval = &types.ArrayOfByte{
Byte:... | go | {
"resource": ""
} |
q21360 | RetrieveProperties | train | func (pc *PropertyCollector) RetrieveProperties(ctx *Context, r *types.RetrieveProperties) soap.HasFault {
body := &methods.RetrievePropertiesBody{}
res := pc.RetrievePropertiesEx(ctx, &types.RetrievePropertiesEx{
This: r.This,
SpecSet: r.SpecSet,
})
if res.Fault() != nil {
body.Fault_ = res.Fault()
} e... | go | {
"resource": ""
} |
q21361 | WaitForUpdates | train | func (pc *PropertyCollector) WaitForUpdates(ctx *Context, r *types.WaitForUpdates) soap.HasFault {
body := &methods.WaitForUpdatesBody{}
res := pc.WaitForUpdatesEx(ctx, &types.WaitForUpdatesEx{
This: r.This,
Version: r.Version,
})
if res.Fault() != nil {
body.Fault_ = res.Fault()
} else {
body.Res = &... | go | {
"resource": ""
} |
q21362 | Fetch | train | func (pc *PropertyCollector) Fetch(ctx *Context, req *internal.Fetch) soap.HasFault {
body := new(internal.FetchBody)
if req.This == vim25.ServiceInstance && req.Prop == "content" {
content := ctx.Map.content()
// ovftool uses API version for 6.0 and fails when these fields are non-nil; TODO
content.VStorageOb... | go | {
"resource": ""
} |
q21363 | FromString | train | func (p *DatastorePath) FromString(s string) bool {
if s == "" {
return false
}
s = strings.TrimSpace(s)
if !strings.HasPrefix(s, "[") {
return false
}
s = s[1:]
ix := strings.Index(s, "]")
if ix < 0 {
return false
}
p.Datastore = s[:ix]
p.Path = strings.TrimSpace(s[ix+1:])
return true
} | go | {
"resource": ""
} |
q21364 | String | train | func (p *DatastorePath) String() string {
s := fmt.Sprintf("[%s]", p.Datastore)
if p.Path == "" {
return s
}
return strings.Join([]string{s, p.Path}, " ")
} | go | {
"resource": ""
} |
q21365 | Name | train | func (c Common) Name() string {
if c.InventoryPath == "" {
return ""
}
return path.Base(c.InventoryPath)
} | go | {
"resource": ""
} |
q21366 | ObjectName | train | func (c Common) ObjectName(ctx context.Context) (string, error) {
var o mo.ManagedEntity
err := c.Properties(ctx, c.Reference(), []string{"name"}, &o)
if err != nil {
return "", err
}
if o.Name != "" {
return o.Name, nil
}
// Network has its own "name" field...
var n mo.Network
err = c.Properties(ctx, ... | go | {
"resource": ""
} |
q21367 | UserSession | train | func (sm *Manager) UserSession(ctx context.Context) (*types.UserSession, error) {
var mgr mo.SessionManager
pc := property.DefaultCollector(sm.client)
err := pc.RetrieveOne(ctx, sm.Reference(), []string{"currentSession"}, &mgr)
if err != nil {
// It's OK if we can't retrieve properties because we're not authenti... | go | {
"resource": ""
} |
q21368 | SessionIsActive | train | func (sm *Manager) SessionIsActive(ctx context.Context) (bool, error) {
if sm.userSession == nil {
return false, nil
}
req := types.SessionIsActive{
This: sm.Reference(),
SessionID: sm.userSession.Key,
UserName: sm.userSession.UserName,
}
active, err := methods.SessionIsActive(ctx, sm.client, &req)... | go | {
"resource": ""
} |
q21369 | DefaultCollector | train | func DefaultCollector(c *vim25.Client) *Collector {
p := Collector{
roundTripper: c,
reference: c.ServiceContent.PropertyCollector,
}
return &p
} | go | {
"resource": ""
} |
q21370 | Create | train | func (p *Collector) Create(ctx context.Context) (*Collector, error) {
req := types.CreatePropertyCollector{
This: p.Reference(),
}
res, err := methods.CreatePropertyCollector(ctx, p.roundTripper, &req)
if err != nil {
return nil, err
}
newp := Collector{
roundTripper: p.roundTripper,
reference: res.R... | go | {
"resource": ""
} |
q21371 | Destroy | train | func (p *Collector) Destroy(ctx context.Context) error {
req := types.DestroyPropertyCollector{
This: p.Reference(),
}
_, err := methods.DestroyPropertyCollector(ctx, p.roundTripper, &req)
if err != nil {
return err
}
p.reference = types.ManagedObjectReference{}
return nil
} | go | {
"resource": ""
} |
q21372 | Add | train | func (f *WaitFilter) Add(obj types.ManagedObjectReference, kind string, ps []string, set ...types.BaseSelectionSpec) *WaitFilter {
spec := types.ObjectSpec{
Obj: obj,
SelectSet: set,
}
pset := types.PropertySpec{
Type: kind,
PathSet: ps,
}
if len(ps) == 0 {
pset.All = types.NewBool(true)
}
... | go | {
"resource": ""
} |
q21373 | Wait | train | func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error {
filter := new(WaitFilter).Add(obj, obj.Type, ps)
return WaitForUpdates(ctx, c, filter, func(updates []types.ObjectUpdate) bool {
for _, update := range updates {
if f(update.C... | go | {
"resource": ""
} |
q21374 | Change | train | func (flag *NetworkFlag) Change(device types.BaseVirtualDevice, update types.BaseVirtualDevice) {
current := device.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard()
changed := update.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard()
current.Backing = changed.Backing
if changed.MacAddress != "" {
... | go | {
"resource": ""
} |
q21375 | GetExtensionManager | train | func GetExtensionManager(c *vim25.Client) (*ExtensionManager, error) {
if c.ServiceContent.ExtensionManager == nil {
return nil, ErrNotSupported
}
return NewExtensionManager(c), nil
} | go | {
"resource": ""
} |
q21376 | NewDatacenter | train | func NewDatacenter(f *Folder) *Datacenter {
dc := &Datacenter{
isESX: f.Self == esx.RootFolder.Self,
}
if dc.isESX {
dc.Datacenter = esx.Datacenter
}
f.putChild(dc)
dc.createFolders()
return dc
} | go | {
"resource": ""
} |
q21377 | CreateTag | train | func (c *Manager) CreateTag(ctx context.Context, tag *Tag) (string, error) {
// create avoids the annoyance of CreateTag requiring a "description" key to be included in the request,
// even though the field value can be empty.
type create struct {
Name string `json:"name"`
Description string `json:"descri... | go | {
"resource": ""
} |
q21378 | UpdateTag | train | func (c *Manager) UpdateTag(ctx context.Context, tag *Tag) error {
spec := struct {
Tag Tag `json:"update_spec"`
}{
Tag: Tag{
Name: tag.Name,
Description: tag.Description,
},
}
url := internal.URL(c, internal.TagPath).WithID(tag.ID)
return c.Do(ctx, url.Request(http.MethodPatch, spec), nil)
} | go | {
"resource": ""
} |
q21379 | DeleteTag | train | func (c *Manager) DeleteTag(ctx context.Context, tag *Tag) error {
url := internal.URL(c, internal.TagPath).WithID(tag.ID)
return c.Do(ctx, url.Request(http.MethodDelete), nil)
} | go | {
"resource": ""
} |
q21380 | GetTag | train | func (c *Manager) GetTag(ctx context.Context, id string) (*Tag, error) {
if isName(id) {
tags, err := c.GetTags(ctx)
if err != nil {
return nil, err
}
for i := range tags {
if tags[i].Name == id {
return &tags[i], nil
}
}
}
url := internal.URL(c, internal.TagPath).WithID(id)
var res Tag
re... | go | {
"resource": ""
} |
q21381 | GetTagForCategory | train | func (c *Manager) GetTagForCategory(ctx context.Context, id, category string) (*Tag, error) {
if category == "" {
return c.GetTag(ctx, id)
}
ids, err := c.ListTagsForCategory(ctx, category)
if err != nil {
return nil, err
}
for _, tagid := range ids {
tag, err := c.GetTag(ctx, tagid)
if err != nil {
... | go | {
"resource": ""
} |
q21382 | ListTags | train | func (c *Manager) ListTags(ctx context.Context) ([]string, error) {
url := internal.URL(c, internal.TagPath)
var res []string
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
} | go | {
"resource": ""
} |
q21383 | GetTags | train | func (c *Manager) GetTags(ctx context.Context) ([]Tag, error) {
ids, err := c.ListTags(ctx)
if err != nil {
return nil, fmt.Errorf("get tags failed for: %s", err)
}
var tags []Tag
for _, id := range ids {
tag, err := c.GetTag(ctx, id)
if err != nil {
return nil, fmt.Errorf("get category %s failed for %s"... | go | {
"resource": ""
} |
q21384 | NewServiceClient | train | func (c *Client) NewServiceClient(path string, namespace string) *Client {
vc := c.URL()
u, err := url.Parse(path)
if err != nil {
log.Panicf("url.Parse(%q): %s", path, err)
}
if u.Host == "" {
u.Scheme = vc.Scheme
u.Host = vc.Host
}
client := NewClient(u, c.k)
client.Namespace = "urn:" + namespace
if c... | go | {
"resource": ""
} |
q21385 | hostAddr | train | func hostAddr(addr string) string {
_, port := splitHostPort(addr)
if port == "" {
return addr + ":443"
}
return addr
} | go | {
"resource": ""
} |
q21386 | Thumbprint | train | func (c *Client) Thumbprint(host string) string {
host = hostAddr(host)
c.hostsMu.Lock()
defer c.hostsMu.Unlock()
return c.hosts[host]
} | go | {
"resource": ""
} |
q21387 | LoadThumbprints | train | func (c *Client) LoadThumbprints(file string) error {
if file == "" {
return nil
}
for _, name := range filepath.SplitList(file) {
err := c.loadThumbprints(name)
if err != nil {
return err
}
}
return nil
} | go | {
"resource": ""
} |
q21388 | WithHeader | train | func (c *Client) WithHeader(ctx context.Context, header Header) context.Context {
return context.WithValue(ctx, headerContext{}, header)
} | go | {
"resource": ""
} |
q21389 | Upload | train | func (c *Client) Upload(ctx context.Context, f io.Reader, u *url.URL, param *Upload) error {
var err error
if param.Progress != nil {
pr := progress.NewReader(ctx, param.Progress, f, param.ContentLength)
f = pr
// Mark progress reader as done when returning from this function.
defer func() {
pr.Done(err)... | go | {
"resource": ""
} |
q21390 | UploadFile | train | func (c *Client) UploadFile(ctx context.Context, file string, u *url.URL, param *Upload) error {
if param == nil {
p := DefaultUpload // Copy since we set ContentLength
param = &p
}
s, err := os.Stat(file)
if err != nil {
return err
}
f, err := os.Open(filepath.Clean(file))
if err != nil {
return err
... | go | {
"resource": ""
} |
q21391 | DownloadRequest | train | func (c *Client) DownloadRequest(ctx context.Context, u *url.URL, param *Download) (*http.Response, error) {
req, err := http.NewRequest(param.Method, u.String(), nil)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
for k, v := range param.Headers {
req.Header.Add(k, v)
}
if param.Ticket != n... | go | {
"resource": ""
} |
q21392 | Download | train | func (c *Client) Download(ctx context.Context, u *url.URL, param *Download) (io.ReadCloser, int64, error) {
res, err := c.DownloadRequest(ctx, u, param)
if err != nil {
return nil, 0, err
}
switch res.StatusCode {
case http.StatusOK:
default:
err = errors.New(res.Status)
}
if err != nil {
return nil, 0,... | go | {
"resource": ""
} |
q21393 | DownloadFile | train | func (c *Client) DownloadFile(ctx context.Context, file string, u *url.URL, param *Download) error {
var err error
if param == nil {
param = &DefaultDownload
}
rc, contentLength, err := c.Download(ctx, u, param)
if err != nil {
return err
}
return c.WriteFile(ctx, file, rc, contentLength, param.Progress, p... | go | {
"resource": ""
} |
q21394 | WithIO | train | func (p *Process) WithIO() *Process {
p.IO = &ProcessIO{
Out: new(bytes.Buffer),
Err: new(bytes.Buffer),
}
return p
} | go | {
"resource": ""
} |
q21395 | NewProcessManager | train | func NewProcessManager() *ProcessManager {
// We use pseudo PIDs that don't conflict with OS PIDs, so they can live in the same table.
// For the pseudo PIDs, we use a sync.Pool rather than a plain old counter to avoid the unlikely,
// but possible wrapping should such a counter exceed MaxInt64.
pid := int64(32768)... | go | {
"resource": ""
} |
q21396 | Start | train | func (m *ProcessManager) Start(r *vix.StartProgramRequest, p *Process) (int64, error) {
p.Name = r.ProgramPath
p.Args = r.Arguments
// Owner is cosmetic, but useful for example with: govc guest.ps -U $uid
if p.Owner == "" {
p.Owner = defaultOwner
}
p.StartTime = time.Now().Unix()
p.ctx, p.Kill = context.Wit... | go | {
"resource": ""
} |
q21397 | Kill | train | func (m *ProcessManager) Kill(pid int64) bool {
m.mu.Lock()
entry, ok := m.entries[pid]
m.mu.Unlock()
if ok {
entry.Kill()
return true
}
return false
} | go | {
"resource": ""
} |
q21398 | ListProcesses | train | func (m *ProcessManager) ListProcesses(pids []int64) []byte {
w := new(bytes.Buffer)
m.mu.Lock()
if len(pids) == 0 {
for _, p := range m.entries {
_, _ = w.WriteString(p.toXML())
}
} else {
for _, id := range pids {
p, ok := m.entries[id]
if !ok {
continue
}
_, _ = w.WriteString(p.toXML(... | go | {
"resource": ""
} |
q21399 | Stat | train | func (m *ProcessManager) Stat(u *url.URL) (os.FileInfo, error) {
name := path.Join("/proc", u.Path)
info, err := os.Stat(name)
if err == nil && info.Size() == 0 {
// This is a real /proc file
return &procFileInfo{info}, nil
}
dir, file := path.Split(u.Path)
pid, err := strconv.ParseInt(path.Base(dir), 10, ... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.