示例#1
0
文件: store_files.go 项目: vmware/vic
func (d *Dispatcher) deleteVMFSFiles(m *object.FileManager, ds *object.Datastore, dsPath string) error {
	defer trace.End(trace.Begin(dsPath))

	if _, err := tasks.WaitForResult(d.ctx, func(ctx context.Context) (tasks.Task, error) {
		return m.DeleteDatastoreFile(ctx, dsPath, d.session.Datacenter)
	}); err != nil {
		log.Debugf("Failed to delete %q: %s", dsPath, err)
	}
	return nil
}
示例#2
0
文件: datastore.go 项目: vmware/vic
func mkdir(ctx context.Context, sess *session.Session, fm *object.FileManager, createParentDirectories bool, path string) (string, error) {
	log.Infof("Creating directory %s", path)

	if err := fm.MakeDirectory(ctx, path, sess.Datacenter, createParentDirectories); err != nil {
		if soap.IsSoapFault(err) {
			soapFault := soap.ToSoapFault(err)
			if _, ok := soapFault.VimFault().(types.FileAlreadyExists); ok {
				log.Debugf("File already exists: %s", path)
				return "", os.ErrExist
			}
		}
		log.Debugf("Creating %s error: %s", path, err)
		return "", err
	}

	return path, nil
}