Пример #1
0
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
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
}