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) ...
随机推荐
- sql server 自增长id 允许插入显示值
--允许插入显示插入主键id的值SET IDENTITY_INSERT [T0002_SType] ON 执行insert插入语句------------------ --关闭 插入显示值SET ID ...
- 并发编程 12—— 任务取消与关闭 之 shutdownNow 的局限性
Java并发编程实践 目录 并发编程 01—— ThreadLocal 并发编程 02—— ConcurrentHashMap 并发编程 03—— 阻塞队列和生产者-消费者模式 并发编程 04—— 闭 ...
- 51nod1693 水群
题目链接:51nod1693 水群 题解参考大神的博客:http://www.cnblogs.com/fighting-to-the-end/p/5874763.html 这题时限0.4秒,真的够狠的 ...
- Windows Store App 变形特效
在应用程序的开发过程中,为了让界面按照期望的效果显示,有时会对界面元素应用变形特效,例如图片的缩放.旋转.移动等.与3D特效不同,在界面元素实现变形特效之后,其平行关系不会发生改变,只不过是位置.大小 ...
- iOS开发UI篇—九宫格坐标计算
iOS开发UI篇—九宫格坐标计算 一.要求 完成下面的布局 二.分析 寻找左边的规律,每一个uiview的x坐标和y坐标. 三.实现思路 (1)明确每一块用得是什么view (2)明确每个view之间 ...
- PHPCMS出错Call to undefined function sitename()
一站点使用PHPCMS V9.4.2,因很久未升级,在使用后台的在线升级,升级到9.5.4后,出现“Call to undefined function sitename()”错误(注原模板未升级), ...
- Mike的农场 (BZOJ 4177)
题目大意: 给N个东西分AB类,分到A类和B类分别得到相应的钱记为A[i],B[i],然后有一些冲突关系<x,y,z>,如果物品x,y不同类需要付出z的钱.还有一些外快<S,x,y& ...
- Node.js GET/POST请求
在很多场景中,我们的服务器都需要跟用户的浏览器打交道,如表单提交. 表单提交到服务器一般都使用GET/POST请求. 我将为大家介绍 Node.js GET/POST请求. 获取GET请求内容 由于G ...
- ACE - ACE_Task源码剖析及线程池实现
原文出自http://www.cnblogs.com/binchen-china,禁止转载. 上篇提到用Reactor模式,利用I/O复用,获得Socket数据并且实现I/O层单线程并发,和dispa ...
- 1、datatable与datagrid之间的绑定
1.前台代码: 插入一个datagrid控件,设置几列. 这里有两点要注意: 1)为了显示所要查询的日期,我将前台的列名与后台查询出来的日期绑定了,用了x:Name这个属性 2)与后台datatabl ...