本文整理匯總了Golang中github.com/heketi/heketi/executors.Executor.VolumeDestroyCheck方法的典型用法代碼示例。如果您正苦於以下問題:Golang Executor.VolumeDestroyCheck方法的具體用法?Golang Executor.VolumeDestroyCheck怎麽用?Golang Executor.VolumeDestroyCheck使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/heketi/heketi/executors.Executor
的用法示例。
在下文中一共展示了Executor.VolumeDestroyCheck方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Destroy
func (v *VolumeEntry) Destroy(db *bolt.DB, executor executors.Executor) error {
logger.Info("Destroying volume %v", v.Info.Id)
// Get the entries from the database
brick_entries := make([]*BrickEntry, len(v.Bricks))
var sshhost string
db.View(func(tx *bolt.Tx) error {
for index, id := range v.BricksIds() {
brick, err := NewBrickEntryFromId(tx, id)
if err != nil {
logger.LogError("Brick %v not found in db: %v", id, err)
continue
}
brick_entries[index] = brick
// Set ssh host to send volume commands
if sshhost == "" {
node, err := NewNodeEntryFromId(tx, brick.Info.NodeId)
if err != nil {
logger.LogError("Unable to determine brick node: %v", err)
return err
}
sshhost = node.ManageHostName()
}
}
return nil
})
// Determine if we can destroy the volume
err := executor.VolumeDestroyCheck(sshhost, v.Info.Name)
if err != nil {
logger.Err(err)
return err
}
// Determine if the bricks can be destroyed
err = v.checkBricksCanBeDestroyed(db, executor, brick_entries)
if err != nil {
logger.Err(err)
return err
}
// :TODO: What if the host is no longer available, we may need to try others
// Stop volume
err = executor.VolumeDestroy(sshhost, v.Info.Name)
if err != nil {
logger.LogError("Unable to delete volume: %v", err)
return err
}
// Destroy bricks
err = DestroyBricks(db, executor, brick_entries)
if err != nil {
logger.LogError("Unable to delete bricks: %v", err)
return err
}
// Remove from entries from the db
err = db.Update(func(tx *bolt.Tx) error {
for _, brick := range brick_entries {
err = v.removeBrickFromDb(tx, brick)
if err != nil {
logger.Err(err)
// Everything is destroyed anyways, just keep deleting the others
// Do not return here
}
}
// Remove volume from cluster
cluster, err := NewClusterEntryFromId(tx, v.Info.Cluster)
if err != nil {
logger.Err(err)
// Do not return here.. keep going
}
cluster.VolumeDelete(v.Info.Id)
err = cluster.Save(tx)
if err != nil {
logger.Err(err)
// Do not return here.. keep going
}
// Delete volume
v.Delete(tx)
return nil
})
return err
}