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) ...
随机推荐
- Windows Store App 控件动画
在开发Windows应用商店应用时,开发工具中已经封装了大量的控件供开发人员使用,而其中有一部分控件,例如FlipView.ToolTip.ListView以及SemanticZoom等控件中已经默认 ...
- BZOJ2095 [Poi2010]Bridges
首先二分答案...然后这张图变成了有一些有向边,有一些无向边 然后就是混合图欧拉回路的判断 我们知道如果是有向图,它存在欧拉回路的等价条件是所有点的出度等于入度 对于混合图...先不管有向边,把无向边 ...
- set集合类型
set表示一个集合,相当于C#中的Hashtable,不同的地方在于,所有的值共用一个key. 相关操作如下图.
- 上下文菜单项(contextMenu)----长按按钮弹出菜单项
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- bzoj 3122: [Sdoi2013]随机数生成器
#include<cstdio> #include<iostream> #include<map> #include<cmath> #define ll ...
- 关于Elasticsearch单个索引文档最大数量问题
因为ElasticSearch是一个基于Lucene的搜索服务器.Lucene的索引有个难以克服的限制,导致Elasticsearch的单个分片存在最大文档数量限制,一个索引分片的最大文档数量是20亿 ...
- MagicalRecord的使用(第三方库实现的数据库)
MagicalRecord:http://cocoadocs.org/docsets/MagicalRecord/2.1/ 安装: 1.新建一个工程,注意不要勾选 Core Data. 2.利用Coc ...
- 个人开发者做一款Android App需要知道的事情
个人开发者做一款Android App需要知道的事情 在大学时, 自己是学计算机专业的,而且还和老师一起做过一年半的项目. 有时候是不是有这样的想法,做一个自己的网站.但一直未付诸行动.2012年时, ...
- WCF 发布使用
WCF发布,由于使用的是 net.tcp协议因此 需要在发布的WCF站点的管理网站-高级设置,连接协议中添加net.tcp的绑定 然后还需要在网站绑定编辑中添加net.tcp的绑定.否则访问的时候会出 ...
- linux上安装php+gd扩展
515 cd zlib-1.2.3 516 ./configure --prefix=/usr/local/zlib2 517 make && make install 518 cd ...