commands

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2017 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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("staring")
		defer logger.Info("ending")

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

		quotaControl, err := quotapkg.NewControl(imagesPath)
		if err != nil {
			logger.Error("creating-quota-control-failed", err, lager.Data{"imagesPath": imagesPath})
			return errorspkg.Wrapf(err, "creating xfs quota control %s", imagesPath)
		}

		diskLimit := ctx.Int64("disk-limit-bytes")
		quota := quotapkg.Quota{
			Size: uint64(diskLimit),
		}

		if err := quotaControl.SetQuota(imagePath, quota); err != nil {
			logger.Error("setting-quota-failed", err)
			return errorspkg.Wrapf(err, "setting quota to %s", imagePath)
		}

		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