commands

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2017 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandleOpqWhiteoutsCommand = cli.Command{
	Name:        "handle-opqwhiteouts",
	Usage:       "handle-opqwhiteouts --opaque-path <path>",
	Description: "Handle opaque whiteouts for a volume",

	Flags: []cli.Flag{
		cli.StringSliceFlag{
			Name:  "opaque-path",
			Usage: "Path to whiteout file",
		},
	},

	Action: func(ctx *cli.Context) error {
		logger := lager.NewLogger("tardis")
		logger.RegisterSink(lager.NewWriterSink(os.Stderr, lager.DEBUG))

		for _, opaqueWhiteout := range ctx.StringSlice("opaque-path") {
			if err := system.Lsetxattr(opaqueWhiteout, "trusted.overlay.opaque", []byte("y"), 0); err != nil {
				return errorspkg.Wrapf(err, "set xattr for %s", opaqueWhiteout)
			}
		}
		return nil
	},
}
View Source
var LimitCommand = cli.Command{
	Name:        "limit",
	Usage:       "limit --disk-limit-bytes 102400 --image-path <path>",
	Description: "Add disk limits to the volume.",

	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "image-path",
			Usage: "Path to the volume",
		},
		cli.Int64Flag{
			Name:  "disk-limit-bytes",
			Usage: "Disk limit in bytes",
		},
	},

	Action: func(ctx *cli.Context) error {
		logger := lager.NewLogger("tardis")
		logger.RegisterSink(lager.NewWriterSink(os.Stderr, lager.DEBUG))
		logger.Info("starting")
		defer logger.Info("ending")

		imagePath := ctx.String("image-path")
		imagesPath := filepath.Dir(imagePath)

		diskLimit := uint64(ctx.Int64("disk-limit-bytes"))
		idDiscoverer := ids.NewDiscoverer(filepath.Join(filepath.Dir(imagesPath), overlayxfs.IDDir))
		projectID, err := idDiscoverer.Alloc(logger)
		if err != nil {
			logger.Error("allocating-project-id", err)
			return errorspkg.Wrap(err, "allocating project id")
		}

		return func(logger lager.Logger) error {
			logger = logger.Session("set-quota")
			logger.Debug("starting")
			defer logger.Debug("ending")

			if err := quotapkg.Set(logger, projectID, imagePath, diskLimit); err != nil {
				logger.Error("setting-quota-failed", err)
				return errorspkg.Wrapf(err, "setting quota to %s", imagePath)
			}
			return nil
		}(logger)
	},
}
View Source
var StatsCommand = cli.Command{
	Name:        "stats",
	Usage:       "stats --volume-path <path>",
	Description: "Get stats for a volume",

	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "volume-path",
			Usage: "Path to the volume",
		},
	},

	Action: func(ctx *cli.Context) error {
		logger := lager.NewLogger("tardis")
		logger.RegisterSink(lager.NewWriterSink(os.Stderr, lager.DEBUG))

		volumeStats, err := stats.VolumeStats(
			logger,
			ctx.String("volume-path"),
		)

		if err != nil {
			logger.Error("fetching-volume-stats", err)
			return cli.NewExitError(err.Error(), 1)
		}

		jsonStats, err := json.Marshal(volumeStats)
		if err != nil {
			logger.Error("marshaling-volume-stats", err)
			return cli.NewExitError(err.Error(), 2)
		}

		if _, err := os.Stdout.Write(jsonStats); err != nil {
			logger.Error("printing-stats", err)
			return cli.NewExitError(err.Error(), 3)
		}

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL