github.com/whamcloud/lemur@v0.0.0-20190827193804-4655df8a52af/cmd/lhsm-plugin-noop/main.go (about)

     1  // Copyright (c) 2018 DDN. All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"flag"
     9  	"os"
    10  	"path"
    11  
    12  	"github.com/pkg/errors"
    13  
    14  	"github.com/intel-hpdd/lemur/dmplugin"
    15  	"github.com/intel-hpdd/lemur/pkg/fsroot"
    16  	"github.com/intel-hpdd/logging/alert"
    17  	"github.com/intel-hpdd/logging/debug"
    18  )
    19  
    20  var (
    21  	archive uint
    22  )
    23  
    24  func init() {
    25  	flag.UintVar(&archive, "archive", 1, "archive id")
    26  }
    27  
    28  // Mover is a NOOP data mover
    29  type Mover struct {
    30  }
    31  
    32  // Start signals the mover to begin any asynchronous processing (e.g. stats)
    33  func (m *Mover) Start() {
    34  	debug.Print("noop mover started")
    35  }
    36  
    37  func noop() {
    38  	done := make(chan struct{})
    39  
    40  	plugin, err := dmplugin.New(path.Base(os.Args[0]), func(path string) (fsroot.Client, error) {
    41  		return fsroot.New(path)
    42  	})
    43  	if err != nil {
    44  		alert.Abort(errors.Wrap(err, "create plugin failed"))
    45  	}
    46  
    47  	mover := Mover{}
    48  	plugin.AddMover(&dmplugin.Config{
    49  		Mover:     &mover,
    50  		ArchiveID: uint32(archive),
    51  	})
    52  
    53  	<-done
    54  	if err = plugin.Close(); err != nil {
    55  		alert.Abort(errors.Wrap(err, "close failed"))
    56  	}
    57  }
    58  
    59  func main() {
    60  	noop()
    61  }