本文整理匯總了Golang中github.com/heketi/heketi/executors.Executor.VolumeExpand方法的典型用法代碼示例。如果您正苦於以下問題:Golang Executor.VolumeExpand方法的具體用法?Golang Executor.VolumeExpand怎麽用?Golang Executor.VolumeExpand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/heketi/heketi/executors.Executor
的用法示例。
在下文中一共展示了Executor.VolumeExpand方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Expand
func (v *VolumeEntry) Expand(db *bolt.DB,
executor executors.Executor,
allocator Allocator,
sizeGB int) (e error) {
// Allocate new bricks in the cluster
brick_entries, err := v.allocBricksInCluster(db, allocator, v.Info.Cluster, sizeGB)
if err != nil {
return err
}
// Setup cleanup function
defer func() {
if e != nil {
logger.Debug("Error detected, cleaning up")
// Remove from db
db.Update(func(tx *bolt.Tx) error {
for _, brick := range brick_entries {
v.removeBrickFromDb(tx, brick)
}
err := v.Save(tx)
godbc.Check(err == nil)
return nil
})
}
}()
// Create bricks
err = CreateBricks(db, executor, brick_entries)
if err != nil {
logger.Err(err)
return err
}
// Setup cleanup function
defer func() {
if e != nil {
logger.Debug("Error detected, cleaning up")
DestroyBricks(db, executor, brick_entries)
}
}()
// Create a volume request to send to executor
// so that it can add the new bricks
vr, host, err := v.createVolumeRequest(db, brick_entries)
if err != nil {
return err
}
// Expand the volume
_, err = executor.VolumeExpand(host, vr)
if err != nil {
return err
}
// Increase the recorded volume size
v.Info.Size += sizeGB
// Save volume entry
err = db.Update(func(tx *bolt.Tx) error {
// Save brick entries
for _, brick := range brick_entries {
err := brick.Save(tx)
if err != nil {
return err
}
}
return v.Save(tx)
})
return err
}