- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我被要求编写一些 python 代码,将 VMWare ESXi 主机置于维护模式。我得到了一个虚拟中心的名称,test-vc
,以及一个 ESXi 主机的主机名,test-esxi-host
和这个链接 ...
https://github.com/vmware/pyvmomi/blob/master/docs/vim/HostSystem.rst
... 它提供了一些关于我应该使用的方法的文档,EnterMaintenanceMode(timeout, evacuatePoweredOffVms, maintenanceSpec)
。
我真的完全不知道该怎么做,需要一些帮助。我试过从 python 控制台执行此操作:
from pyVmomi import vim
vim.HostSystem.EnterMaintenanceMode(timeout=0)
导致此错误跟踪的结果:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/apps/cpm/red/env/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 574, in __call__
return self.f(*args, **kwargs)
TypeError: _InvokeMethod() takes at least 2 arguments (1 given)
此外,我对 EnterMaintenanaceMode
例程如何知道我想将主机 test-esxi-host
放在虚拟中心 test 中感到困惑-vc
?
更新:我想我已经弄明白了。这是我认为我需要做的:
from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vim
import atexit
si = SmartConnectNoSSL(host=vc_host, user=user, pwd=pwd)
cont = si.RetrieveContent()
atexit.register(Disconnect, si) # maybe. I am not really sure what this does
objview = si.content.viewManager.CreateContainerView(si.content.rootFolder, [vim.HostSystem], True)
objview.view[0].EnterMaintenanceMode(0)
当然行
objview.view[0].EnterMaintenanceMode(0)
肯定会造成严重破坏,因为我不知道那是不是主机“test-esxi-host”,我想将其置于维护模式。我想我可以做到这一点
for h in objview.view:
if h.name == 'test-esxi-host'
h.EnterMaintenanceMode(0)
我希望有更好的方法来完成上述操作。有点像
get_host(objview.view, 'test-esxi-host').EnterMaintenanceMode(0)
最佳答案
看看Getting started with VMwares ESXi/vSphere API in Python .
To get a VM object or a list of objects you can use the searchIndex class. The class had methods to search for VMs by UUID, DNS name, IP address or datastore path.
希望有几种方法可以在 vCenter 中查找对象:
其中许多还有 FindAll..
方法,可以进行更广泛的查找。
对于这种特殊情况,您可以使用 FindByDnsName
来查找您的主机。
searcher = si.content.searchIndex
host = searcher.FindByDnsName(dnsName='test-esxi-host', vmSearch=False)
host.EnterMaintenanceMode(0)
此代码要求您使用具有 Host.Config.Maintenance
权限的用户向 vCenter (@SmartConnectNoSSL
) 进行身份验证。
最后,您可以使用以下命令使您的主机退出维护模式:host.ExitMaintenanceMode(0)
关于python - 如何使用 pyvmomi 将 ESXi 主机置于维护模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52937914/
我正在使用 ESXi 6.0 主机来测试加壳器,并且一直在尝试让 vmware-iso 远程 ESXi 构建器正常工作。使用打包程序 1.0。我到了加壳器尝试使用“esxcli --formatter
我安装了 Ubuntu 13.04 和 VirtualBox。我创建了2个虚拟机: 对于 ESXi 对于 Windows XP 和 vSphere Client 在我的第一个 VirtualBox 虚
All in one 虚拟机两种模式 PVE(Proxmox VE) ESXI
ESXi命令行获取帮助的方法为<命令关键字 --help>,常用的命令一般都是以esxcli开头,如果忘记命令可以使用帮助:esxcli --help;输出如下: [root@lo
SNMP服务多数用于服务器的监控传递信息之类,比如使用Zabbix监控就可能会需要用到SNMP服务,一般企业级服务产品多数都支持SNMP服务。ESXI主机也是支持此服务的,但默认情况下,如果安装完E
我正在尝试编写一个 greasemonkey 脚本,该脚本可以使用凭据自动填充 ESXi 登录网页。以下代码填充输入字段并启用提交按钮: // ==UserScript== // @name
我有 ESXi 6.0,我需要从中复制一个大小为 ~900GB 且实际大小为 5GB 的稀疏文件到另一台 Linux 机器。 我从 SCP 开始,它需要更长的时间,因为它不知道稀疏文件。 接下来我尝试
在 ESXi 中,我看到了 vSwitch,在每个 vSwitch 中,我都可以添加端口组。我添加的每个端口组都在单独的网络上吗? 假设我配置了 2 个端口组并在其中一个上运行 DHCP 服务器。我可
我的 MySQL 服务器在 ESXi 服务器重启后停止工作...它不会自动启动,我无法从我的 Unix shell 启动它。 ~# service mysql restart restart: Unk
1、安装要求 硬件要求CPU支持虚拟化、4核;内存10G 网卡要求:最好两块虚拟网卡 (实现冗余)。 硬盘要求:最好两块,一块作为系统盘、一块作为存储盘。 2、OS镜像下载 # 前往我的
我无法弄清楚这两个程序之间有什么区别。 具体来说,我对在后台运行虚拟服务器感兴趣,作为守护进程(Linux 主机操作系统) 最佳答案 VMware Server 作为应用程序在普通操作系统 Windo
我需要知道 vmware ESXi vSphere 客户端中用于连接远程控制台的协议(protocol)是什么? 这个协议(protocol)是开源的吗? 他们的任何 vmware/第三方应用程序是否
我目前正在使用 Simics module (见第 6 章)监听指令获取和数据访问,并对所有这些事件运行回调,以便检测在 Simics x86 上运行的内核。例如,我可以创建一个 Simics 模块,
我每天或晚上都在尝试将虚拟机恢复到之前的快照。不幸的是,我还没有找到任何方法来按照我想要的方式执行此操作。 以下是我尝试过但不适合的一些方法: - snapshot.action=autoRevert
我有一个问题:如何从在VMware ESXi5.0上运行的VM获取文件 示例:我在“myVM”的文件夹C:\ Test中有一个文件Test.txt。在vSphere服务器上运行的此myVM运行wind
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
每次我尝试将文件从 ESXi 机器复制到其他 Linux 机器时,它总是失败。要么等待更长的时间,要么以超时错误告终。 使用的命令:scp local_file root@:IP:path/to/fo
Esxi Var/log 是否指向暂存分区?如果是,如果暂存分区在 RAM 磁盘上,则在 esxi 重新启动后,var/log 文件夹(hostd、vpxa、fdm 等)中的所有日志都将被删除? 最佳
在使用本地硬盘驱动器作为虚拟机存储时,我遇到了 VMware ESXi 免费管理程序 6 的非常奇怪的行为。 一个分区的所有功能都可以正常工作。 这是设置。 2TB WD RED 驱动器分为 2 个部
本文主要介绍了vmware Esxi 5.0 忘记密码重置的方法,分享给大家,具体如下: 方法1、重新安装esxi,不要覆盖datastore,这样比较简单。 方法2、
我是一名优秀的程序员,十分优秀!