本文整理汇总了Golang中github.com/vmware/govmomi/object.Datastore.Client方法的典型用法代码示例。如果您正苦于以下问题:Golang Datastore.Client方法的具体用法?Golang Datastore.Client怎么用?Golang Datastore.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/govmomi/object.Datastore
的用法示例。
在下文中一共展示了Datastore.Client方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: deleteDatastoreFiles
func (d *Dispatcher) deleteDatastoreFiles(ds *object.Datastore, path string, force bool) (bool, error) {
defer trace.End(trace.Begin(fmt.Sprintf("path %q, force %t", path, force)))
// refuse to delete everything on the datstore, ignore force
if path == "" {
dsn, _ := ds.ObjectName(d.ctx)
msg := fmt.Sprintf("refusing to remove datastore files for path \"\" on datastore %q", dsn)
return false, errors.New(msg)
}
var empty bool
dsPath := ds.Path(path)
res, err := d.lsFolder(ds, dsPath)
if err != nil {
if !types.IsFileNotFound(err) {
err = errors.Errorf("Failed to browse folder %q: %s", dsPath, err)
return empty, err
}
log.Debugf("Folder %q is not found", dsPath)
empty = true
return empty, nil
}
if len(res.File) > 0 && !force {
log.Debugf("Folder %q is not empty, leave it there", dsPath)
return empty, nil
}
m := object.NewFileManager(ds.Client())
if err = d.deleteFilesIteratively(m, ds, dsPath); err != nil {
return empty, err
}
return true, nil
}
示例2: deleteUpgradeImages
func (d *Dispatcher) deleteUpgradeImages(ds *object.Datastore, settings *data.InstallerData) {
defer trace.End(trace.Begin(""))
log.Infof("Deleting upgrade images")
// do clean up aggressively, even the previous operation failed with context deadline excceeded.
d.ctx = context.Background()
m := object.NewFileManager(ds.Client())
file := ds.Path(path.Join(d.vmPathName, settings.ApplianceISO))
if err := d.deleteVMFSFiles(m, ds, file); err != nil {
log.Warnf("Image file %q is not removed for %s. Use the vSphere UI to delete content", file, err)
}
file = ds.Path(path.Join(d.vmPathName, settings.BootstrapISO))
if err := d.deleteVMFSFiles(m, ds, file); err != nil {
log.Warnf("Image file %q is not removed for %s. Use the vSphere UI to delete content", file, err)
}
}