本文整理匯總了Golang中github.com/flynn/flynn/pkg/cluster.Host.DestroyVolume方法的典型用法代碼示例。如果您正苦於以下問題:Golang Host.DestroyVolume方法的具體用法?Golang Host.DestroyVolume怎麽用?Golang Host.DestroyVolume使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/flynn/flynn/pkg/cluster.Host
的用法示例。
在下文中一共展示了Host.DestroyVolume方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doVolumeTransmitAPI
func (s *VolumeSuite) doVolumeTransmitAPI(h0, h1 *cluster.Host, t *c.C) {
clus := s.clusterClient(t)
// create a volume!
vol, err := h0.CreateVolume("default")
t.Assert(err, c.IsNil)
defer func() {
t.Assert(h0.DestroyVolume(vol.ID), c.IsNil)
}()
// create a job and use it to add data to the volume
cmd, service, err := makeIshApp(clus, h0, s.discoverdClient(t), host.ContainerConfig{
Volumes: []host.VolumeBinding{{
Target: "/vol",
VolumeID: vol.ID,
Writeable: true,
}},
})
t.Assert(err, c.IsNil)
defer cmd.Kill()
resp, err := runIshCommand(service, "echo 'testcontent' > /vol/alpha ; echo $?")
t.Assert(err, c.IsNil)
t.Assert(resp, c.Equals, "0\n")
// take a snapshot
snapInfo, err := h0.CreateSnapshot(vol.ID)
t.Assert(err, c.IsNil)
defer func() {
t.Assert(h0.DestroyVolume(snapInfo.ID), c.IsNil)
}()
// make a volume on another host to yank the snapshot content into
vol2, err := h1.CreateVolume("default")
t.Assert(err, c.IsNil)
defer func() {
t.Assert(h1.DestroyVolume(vol2.ID), c.IsNil)
}()
// transfer the snapshot to the new volume on the other host
snapInfo2, err := h1.PullSnapshot(vol2.ID, h0.ID(), snapInfo.ID)
t.Assert(err, c.IsNil)
defer func() {
t.Assert(h1.DestroyVolume(snapInfo2.ID), c.IsNil)
}()
// start a job on the other host that mounts and inspects the transmitted volume
cmd, service, err = makeIshApp(clus, h1, s.discoverdClient(t), host.ContainerConfig{
Volumes: []host.VolumeBinding{{
Target: "/vol",
VolumeID: vol2.ID,
Writeable: false,
}},
})
t.Assert(err, c.IsNil)
defer cmd.Kill()
// read data back from the volume
resp, err = runIshCommand(service, "cat /vol/alpha")
t.Assert(err, c.IsNil)
t.Assert(resp, c.Equals, "testcontent\n")
}