コード例 #1
0
ファイル: libvirt.go プロジェクト: ericcapricorn/flynn
func (c *VirConnection) IsAlive() (bool, error) {
	result := C.virConnectIsAlive(c.ptr)
	if result == -1 {
		return false, GetLastError()
	}
	if result == 1 {
		return true, nil
	}
	return false, nil
}
コード例 #2
0
ファイル: hypervisor.go プロジェクト: hooklift/golibvirt
func (h *Hypervisor) IsConnectionAlive() (bool, error) {
	result := C.virConnectIsAlive(h.cptr)

	if result == -1 {
		return false, GetLastError()
	}

	if result == 1 {
		return true, nil
	}

	return false, nil
}
コード例 #3
0
ファイル: libvirt.go プロジェクト: hopkings2008/catkeeper
func (c *VirConnection) IsAlive() (bool, error) {
	switch result := int(C.virConnectIsAlive(c.ptr)); result {
	case -1:
		return false, errors.New(GetLastError())
	case 0:
		return false, nil
	case 1:
		return true, nil
	default:
		return false, nil
	}

}
コード例 #4
0
// IsAlive determines if the connection to the hypervisor is still alive.
// If an error occurs, the function will also return "false" and the error
// message will be written to the log.
func (conn Connection) IsAlive() (bool, error) {
	conn.log.Println("checking whether connection is alive...")
	cRet := C.virConnectIsAlive(conn.virConnect)
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		conn.log.Printf("an error occurred: %v\n", err)
		return false, err
	}

	alive := (ret == 1)

	if alive {
		conn.log.Println("connection is alive")
	} else {
		conn.log.Println("connection is not alive")
	}

	return alive, nil
}