本文整理汇总了Golang中dmzhang/catkeeper/libvirt.VirConnection.LookupByUUIDString方法的典型用法代码示例。如果您正苦于以下问题:Golang VirConnection.LookupByUUIDString方法的具体用法?Golang VirConnection.LookupByUUIDString怎么用?Golang VirConnection.LookupByUUIDString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmzhang/catkeeper/libvirt.VirConnection
的用法示例。
在下文中一共展示了VirConnection.LookupByUUIDString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: readLibvirtVM
func readLibvirtVM(HostIpAddress string, UUIDString string) (VirtualMachine, error) {
var conn libvirt.VirConnection
var err error
ok := ipaddressConnectionCache.Check(HostIpAddress)
if ok == false {
conn, err = libvirt.NewVirConnection("qemu+ssh://[email protected]" + HostIpAddress + "/system")
if err != nil {
return VirtualMachine{}, err
}
ipaddressConnectionCache.Set(HostIpAddress, conn)
} else {
//?How to deal with connection's not alive
conn = ipaddressConnectionCache.Get(HostIpAddress).(libvirt.VirConnection)
if ok, _ := conn.IsAlive(); !ok {
log.Printf("remote %s is not alive", HostIpAddress)
conn, err = libvirt.NewVirConnection("qemu+ssh://[email protected]" + HostIpAddress + "/system")
if err != nil {
ipaddressConnectionCache.Delete(HostIpAddress)
return VirtualMachine{}, err
}
/*TODO Write Lock*/
ipaddressConnectionCache.Set(HostIpAddress, conn)
}
}
domain, err := conn.LookupByUUIDString(UUIDString)
if err != nil {
return VirtualMachine{}, err
}
vm := fillVmData(domain, conn)
return vm, nil
}