Skip to content

Commit

Permalink
lhsm - add pool support to import and friends
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Read committed Dec 22, 2016
1 parent d723790 commit 55bbcc5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions cmd/lhsm/hsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ func init() {
Value: 1 << 20,
Usage: "Set stripe size in bytes",
},
cli.StringFlag{
Name: "pool",
Usage: "Set the start OST Pool name",
},
},
},
{
Expand All @@ -218,6 +222,10 @@ func init() {
Name: "stripe_size",
Usage: "Override stripe size (bytes) in target copy.",
},
cli.StringFlag{
Name: "pool",
Usage: "Set the start OST Pool name",
},
},
},
{
Expand All @@ -234,6 +242,10 @@ func init() {
Name: "stripe_size",
Usage: "Override stripe size (bytes) in target copy.",
},
cli.StringFlag{
Name: "pool",
Usage: "Set the start OST Pool name",
},
},
},
}
Expand Down
12 changes: 9 additions & 3 deletions cmd/lhsm/hsm_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func hsmImportAction(c *cli.Context) error {
layout := llapi.DefaultDataLayout()
layout.StripeCount = c.Int("stripe_count")
layout.StripeSize = c.Int("stripe_size")
layout.PoolName = c.String("pool")

debug.Printf("%v, %v, %v, %v", archive, uuid, hash, args[0])
_, err = hsm.Import(args[0], archive, fi, layout)
Expand All @@ -178,7 +179,7 @@ func hsmImportAction(c *cli.Context) error {
return nil
}

func clone(srcPath, targetPath string, stripeCount, stripeSize int, requiredState llapi.HsmStateFlag) error {
func clone(srcPath, targetPath string, stripeCount, stripeSize int, poolName string, requiredState llapi.HsmStateFlag) error {
srcStat, err := os.Stat(srcPath)
if err != nil {
return errors.Wrap(err, srcPath)
Expand Down Expand Up @@ -221,6 +222,11 @@ func clone(srcPath, targetPath string, stripeCount, stripeSize int, requiredStat
layout.StripeSize = stripeSize

}

if poolName != "" {
layout.PoolName = poolName
}

//debug.Printf("%v, %v, %v, %v", archive, uuid, hash, srcPath)
_, err = hsm.Import(targetPath, uint(archive), srcStat, layout)
if err != nil {
Expand All @@ -246,7 +252,7 @@ func hsmCloneAction(c *cli.Context) error {
return errors.New("HSM clone requires source and destination argument")
}

return clone(args[0], args[1], c.Int("stripe_count"), c.Int("stripe_size"), llapi.HsmFileArchived)
return clone(args[0], args[1], c.Int("stripe_count"), c.Int("stripe_size"), c.String("pool"), llapi.HsmFileArchived)
}

// tempName returns a tempname based on path provided
Expand All @@ -260,7 +266,7 @@ func hsmRestripeAction(c *cli.Context) error {
return errors.New("Can only restripe one file at a time.")
}
tempFile := tempName(args[0])
err := clone(args[0], tempFile, c.Int("stripe_count"), c.Int("stripe_size"), llapi.HsmFileReleased)
err := clone(args[0], tempFile, c.Int("stripe_count"), c.Int("stripe_size"), c.String("pool"), llapi.HsmFileReleased)
if err != nil {
os.Remove(tempFile)
return errors.Wrap(err, "Unable to restripe")
Expand Down

0 comments on commit 55bbcc5

Please sign in to comment.