Skip to content

Commit 55bbcc5

Browse files
author
Robert Read
committedDec 22, 2016
lhsm - add pool support to import and friends
1 parent d723790 commit 55bbcc5

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed
 

‎cmd/lhsm/hsm.go

+12
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ func init() {
202202
Value: 1 << 20,
203203
Usage: "Set stripe size in bytes",
204204
},
205+
cli.StringFlag{
206+
Name: "pool",
207+
Usage: "Set the start OST Pool name",
208+
},
205209
},
206210
},
207211
{
@@ -218,6 +222,10 @@ func init() {
218222
Name: "stripe_size",
219223
Usage: "Override stripe size (bytes) in target copy.",
220224
},
225+
cli.StringFlag{
226+
Name: "pool",
227+
Usage: "Set the start OST Pool name",
228+
},
221229
},
222230
},
223231
{
@@ -234,6 +242,10 @@ func init() {
234242
Name: "stripe_size",
235243
Usage: "Override stripe size (bytes) in target copy.",
236244
},
245+
cli.StringFlag{
246+
Name: "pool",
247+
Usage: "Set the start OST Pool name",
248+
},
237249
},
238250
},
239251
}

‎cmd/lhsm/hsm_import.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func hsmImportAction(c *cli.Context) error {
160160
layout := llapi.DefaultDataLayout()
161161
layout.StripeCount = c.Int("stripe_count")
162162
layout.StripeSize = c.Int("stripe_size")
163+
layout.PoolName = c.String("pool")
163164

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

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

223224
}
225+
226+
if poolName != "" {
227+
layout.PoolName = poolName
228+
}
229+
224230
//debug.Printf("%v, %v, %v, %v", archive, uuid, hash, srcPath)
225231
_, err = hsm.Import(targetPath, uint(archive), srcStat, layout)
226232
if err != nil {
@@ -246,7 +252,7 @@ func hsmCloneAction(c *cli.Context) error {
246252
return errors.New("HSM clone requires source and destination argument")
247253
}
248254

249-
return clone(args[0], args[1], c.Int("stripe_count"), c.Int("stripe_size"), llapi.HsmFileArchived)
255+
return clone(args[0], args[1], c.Int("stripe_count"), c.Int("stripe_size"), c.String("pool"), llapi.HsmFileArchived)
250256
}
251257

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

0 commit comments

Comments
 (0)
Please sign in to comment.