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) ...
随机推荐
- 如何根据不同的浏览器写不同的css样式达到兼容
做前端静态页面的时候总是发现,ie的兼容性很差,总会出点问题.然后就去改代码 ,改完以后 又发现 火狐 谷歌又挂了,这可咋整. 后来发现做个判断吧 哪里有问题哪里就做个判断呗 ,咋判断呢,这么 ...
- Android开发--Intent的应用
1.概述 Intent负责对应用中一次操作的动作,动作涉及的数据,附加的数据进行描述,起到媒介的作用.通过Intent对象指定一个activity,利用startActivity或 startActi ...
- PHP判断变量是否为整型
1.使用is_int() 2.使用is_numeric() 两个函数的区别,当变量为'1'时, is_int()的返回值为false, is_numeric()的返回值为true 当变量为1时, 两个 ...
- SEO命令之”site“运用详解
一.“site”基本介绍: 都知道要想查询一个特定网站的收录状况一般会分为两种情况:一.结果中有返回数据,则表明该网站已被收录:二.如果返回数据为空,则该网站未被收录.如果是以前已被收录的,现在来查没 ...
- PL/sql语法单元
1.字符集 PL/SQL的字符集包括: 所有大小写字母:包括A~Z和a~z. 数字:包括0~9. 空白字符:包括制表符.空格和回车符 其他常用英文符号 2.标识符 标识符用于定义PL/sql变量.常量 ...
- In close() at SocketHttpClientConnection in Android
In close() at SocketHttpClientConnection Error In Android. when i tried to acess network data on Mai ...
- C语言获得数组长度的函数
<转自百度知道> 1.c语言中,定义数组后可以用sizeof命令获得数组的长度(可容纳元素个数). 例如: int data[4]; int length; length=sizeof(d ...
- HDU 5373 (大水坑题---被11整除原来有规律)
题意:告诉一个数n,然后求出所有的位数和,插在n的尾部,重复求t次,判断最终的数是否能被11整除. 分析:直接模拟的过程,并且模拟的除的过程,却TLE,以为是方法错了,因为每次都得循环求一遍位数和: ...
- HDU 1829 分组并查集
题意:有两种性别,每组数据表示是男女朋友,判断输入的几组数据是否有同性恋 思路:http://blog.csdn.net/iaccepted/article/details/24304087 分组并查 ...
- 不让padding影响元素的宽度
CSS3 新增了 box-sizing 属性. 以前,如果指定 div 的宽度为 div { width: 100px; height: 100px; padding: 10px; } 则包含 pad ...