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) ...
随机推荐
- HTML 段落<p>标签
<p> 标签定义段落. p 元素会自动在其前后创建一些空白.浏览器会自动添加这些空间,您也可以在样式表中规定. 段间距IE默认为19px,通过p的margin-top属性设置FF默认为1. ...
- iOS开发UI篇—无限轮播(循环展示)
iOS开发UI篇—无限轮播(循环展示) 一.简单说明 之前的程序还存在一个问题,那就是不能循环展示,因为plist文件中只有五个数组,因此第一个和最后一个之后就没有了,下面介绍处理这种循环展示问题的小 ...
- IT自学论坛
http://yun.baidu.com/share/home?uk=4113898546&view=share#category/type=0
- IT公司100题-28-整数的二进制表示中1的个数
问题描述: 输入一个整数n,求n的二进制表示中,一共有多少个1.例如n=8,二进制表示为00001000,二进制表示中有1个1. 分析: 如果一个数n不为0,那么n-1的二进制表示,与n的二进 ...
- bzoj1211: prufer序列 | [HNOI2004]树的计数
题目大意: 告诉你树上每个节点的度数,让你构建出这样一棵树,问能够构建出树的种树 这里注意数量为0的情况,就是 当 n=1时,节点度数>0 n>1时,所有节点度数相加-n!=n-2 可以通 ...
- 使用xca生成SSL证书
先下载安装xca工具,地址是http://xca.hohnstaedt.de/ 先用xca创建一本ca证书 xca打开的界面 依次File, New DataBase,选择xdb文件保存路径,再输入密 ...
- goldengate 12.2中通过restful查看OGG状态
安装ogg 12.2之后 GGSCI>create datestore 然后重启mgr 和其它进程, 通过浏览器http://ogg-server-ip:mgr-port/groups 可以看到 ...
- 关于servlet的filter
Servlet过滤器 2009-12-08 23:12:44| 分类: Java|举报|字号 订阅 一.什么是Servlet过滤器 过滤器是在数据交互之间过滤数据的中间组件,独立于任何平台或 ...
- mysql 日期类型比较
MySQL 日期类型:日期格式.所占存储空间.日期范围 比较. 日期类型 存储空间 日期格式 日期范围 ------------ ------ ...
- sublime福音:微信小程序组件及API补全插件
微信自带的编辑器操作起来各种不顺手,调试的时候需要用到,但是编辑的时候还是用自己熟悉的编辑器好一点. 将文件目录导入到sublime,在sublime编辑保存后,回到小程序开发工具刷新页面即可. 下面 ...