access remote libvirtd
访问远程libvirtd服务
因为是在一个可信环境中运行,所以可以忽略安全方面的操作,步骤如下:
(1)更改libvirtd配置
1.1 更改/ect/sysconfig/libvirtd文件,打开LIBVIRTD_ARGS="--listen"设置
1.2 更改/etc/libvirt/libvirtd.conf
listen_tls = 0 #关闭tls
listen_tcp = 1 # 打开tcp
tcp_port = "16509" # 侦听关口
listen_addr="0.0.0.0" # 侦听地址
auth_tcp = "none" # 允许匿名访问
(2) 可以通过 virsh -c qemu+tcp://10.2.3.123:16509/system来访问10.2.3.123上面的libvirtd服务
(3) python代码示例如下:
import libvirt
import sys
import logging '''
enum virDomainState { VIR_DOMAIN_NOSTATE = 0 no state
VIR_DOMAIN_RUNNING = 1 the domain is running
VIR_DOMAIN_BLOCKED = 2 the domain is blocked on resource
VIR_DOMAIN_PAUSED = 3 the domain is paused by user
VIR_DOMAIN_SHUTDOWN = 4 the domain is being shut down
VIR_DOMAIN_SHUTOFF = 5 the domain is shut off
VIR_DOMAIN_CRASHED = 6 the domain is crashed
VIR_DOMAIN_PMSUSPENDED = 7 the domain is suspended by guest power management
VIR_DOMAIN_LAST = 8 NB: this enum value will increase over time as new events are added to the libvirt API. It reflects the last state supported by this version of the libvirt API. } struct virDomainInfo { unsigned char state the running state, one of virDomainState
unsigned long maxMem the maximum memory in KBytes allowed
unsigned long memory the memory in KBytes used by the domain
unsigned short nrVirtCpu the number of virtual CPUs for the domain
unsigned long long cpuTime the CPU time used in nanoseconds } '''
def get_VM_infos(host, port=16509):
'''
list domains of the specified host
'''
infos = []
try:
pass uri = 'qemu+tcp://%s:%s/system' % (host, port)
conn = libvirt.openReadOnly(uri)
# list the defined but inactive domains
domains = [conn.lookupByName(name) for name in conn.listDefinedDomains()]
# list active domains
domains.extend([conn.lookupByID(i) for i in conn.listDomainsID()]) # for dom in domains:
# print 'ID = %d' % dom.ID()
# print 'Name = %s' % dom.name()
# infos = dom.info()
# print 'State = %d' % infos[0]
# # print 'State = %s' %s dom.state(0)
# print 'Max Memory = %s' % infos[1]
# print 'Memory = %s' % info[2]
# # print 'Max Memory = %d' % dom.maxMemory
# print 'Number of virt CPUs = %d' % infos[3]
# # print 'Number of virt CPUs = %s' % dom.maxVcpus()
# print 'CPU Time (in ns) = %d' % infos[4]
# print ' '
for dom in domains:
infos.append(dom.info())
except Exception, e:
print e
return infos if __name__ == '__main__':
infos = get_VM_infos('10.2.3.250', 16509)
print infos
access remote libvirtd的更多相关文章
- How to configure ODBC DSN in Client to access remote DB2 for Windows
How to configure ODBC DSN in Client to access remote DB2 for Windows MA Gen feng (Guangdong Unito ...
- Install TightVNC Server in RHEL/CentOS and Fedora to Access Remote Desktops
Virtual Networking Computing (VNC) is a Kind of remote sharing system that makes it possible to take ...
- T-SQL Part XII: Access Remote SQL Server
要链接远程的SQL Server,需要一下几个步骤(以下的步骤都是在远程系统上进行): 确认远程SQL Server所监听的端口号 官方的文档是使用SQL Server Configuration M ...
- [中英对照]Introduction to Remote Direct Memory Access (RDMA) | RDMA概述
前言: 什么是RDMA? 简单来说,RDMA就是指不通过操作系统(OS)内核以及TCP/IP协议栈在网络上传输数据,因此延迟(latency)非常低,CPU消耗非常少. 下面给出一篇简单介绍RDMA的 ...
- Data access between different DBMS and other txt/csv data source by DB Query Analyzer
1 About DB Query Analyzer DB Query Analyzer is presented by Master Genfeng,Ma from Chinese Mainl ...
- DB Query Analyzer 6.03, the most excellent Universal DB Access tools on any Microsoft Windows OS
DB Query Analyzer 6.03, the most excellent Universal database Access tools on any Microsoft Wind ...
- Access text files using SQL statements by DB Query Analyzer
Access text files using SQL statements by DB Query Analyzer Ma Gen feng (Guangdong Unitoll Services ...
- How to configure ODBC DSN to access local DB2 for Windows
How to configure ODBC DSN to access local DB2 for Windows MA Genfeng (GuangdongUnitoll Services inco ...
- SSISWMI-Watching for the Wql query caused the following system exception: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
将带有WMI WATCH TASK的SSIS包排到sql server agent跑,报异常,这是运行账号权限的问题. Executed as user: sss. Microsoft (R) ...
随机推荐
- Centos7 下配置mysql5.6主从复制实例(一主两从)
标签:mysql 数据库 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://8941355.blog.51cto.com/89313 ...
- ssm(spring,springmvc,mybatis)
1.配置web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version=&qu ...
- 10月9日Android学习笔记:活动与服务之间的通信
最近在照着<第一行代码>这本书来学安卓,顺便记下笔记.主要的内容是Android中服务的第二种启动方式,通过活动绑定服务来启动服务,实现活动与服务之间的通信. 一. 首先创建一个服务类 p ...
- Oracle数据库备份与恢复
第一章. 理解什么是数据库恢复 当 我们使用一个数据库时,总希望数据库的内容是可靠的.正确的,但由于计算机系统的故障(硬件故障.软件故障.网络故障.进程故障和系统故障)影响数据库系 统的操作,影响数据 ...
- Linux学习 : 裸板调试 之 配置使用NAND FLASH
关于NAND FLASH的结构是以页为单位写,以块为单位来擦除: 1Gb 为大页 page=2048Kb BLOCK=128K 512Mb 为小页 page=512byte ...
- POJ 1637 Sightseeing tour (混合图欧拉路判定)
Sightseeing tour Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6986 Accepted: 2901 ...
- OD调试篇6--对一些真正的小程序进行一点点的修改
先打开这个程序看看,提醒你这是一个未注册版本的软件.会发现只能添加4个联系人,这显然是我不想看见的,于是我要对这个程序进行一些修改,嘿嘿... 通过OD载入这个程序 有一些(SEH)也就是异常,我们可 ...
- 转 TextBox的EnableViewState属性问题
问题如下: ---------------------------------------------------------------------------------------------- ...
- [Mac]关闭所有打开finder
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Light'} span.Apple-tab-span {white-sp ...
- 最短路径问题——dijkstra算法
仅谈谈个人对dijkstra的理解,dijkstra算法是基于邻接表实现的,用于处理单源最短路径问题(顺便再提一下,处理单源最短路径问题的还有bellman算法).开辟一个结构体,其变量为边的终点和边 ...