本文整理汇总了Golang中github.com/polvi/coreup/Godeps/_workspace/src/github.com/rackspace/gophercloud.CloudServersProvider.DeleteServerById方法的典型用法代码示例。如果您正苦于以下问题:Golang CloudServersProvider.DeleteServerById方法的具体用法?Golang CloudServersProvider.DeleteServerById怎么用?Golang CloudServersProvider.DeleteServerById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/polvi/coreup/Godeps/_workspace/src/github.com/rackspace/gophercloud.CloudServersProvider
的用法示例。
在下文中一共展示了CloudServersProvider.DeleteServerById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: withServer
func withServer(api gophercloud.CloudServersProvider, f func(string)) {
id, err := createServer(api, "", "", "", "")
if err != nil {
panic(err)
}
for {
s, err := api.ServerById(id)
if err != nil {
panic(err)
}
if s.Status == "ACTIVE" {
break
}
time.Sleep(10 * time.Second)
}
f(id)
// I've learned that resizing an instance can fail if a delete request
// comes in prior to its completion. This ends up leaving the server
// in an error state, and neither the resize NOR the delete complete.
// This is a bug in OpenStack, as far as I'm concerned, but thankfully,
// there's an easy work-around -- just wait for your server to return to
// active state first!
waitForServerState(api, id, "ACTIVE")
err = api.DeleteServerById(id)
if err != nil {
panic(err)
}
}