こんにちは私は、DRSが手動モードに設定されているときにクラスタに対してvmotionsを実行するためにpyvmomi APIを使用しています。私はvcenterを経由し、クラスタに問い合わせて、推薦を得て、それを使ってVmotionsを実行しています。コードはこのようなものです。pyvmomi:RelocateVMを呼び出すときのエラー
content=getVCContent(thisHost, {'user':username,'pwd':decoded_password},logger)
allClusterObj = content.viewManager.CreateContainerView(content.rootFolder, [pyVmomi.vim.ClusterComputeResource], True)
allCluster = allClusterObj.view
for thisDrsRecommendation in thisCluster.drsRecommendation:
print thisDrsRecommendation.reason
for thisMigration in thisDrsRecommendation.migrationList:
print ' vm:', thisMigration.vm.name
while True:
relocate_vm_to_host(thisMigration.vm.name,thisMigration.destination.name, allClusterObj.view)
#FUNCTION definition
def relocate_vm_to_host(vm, host , allCluster):
for thisCluster in allCluster:
for thisHost in thisCluster.host:
if thisHost.name == host:
for thisVm in thisHost.vm:
print 'Relocating vm:%s to host:%s on cluster:%s' %(thisVm.name,thisHost.name,thisCluster.name)
task = thisVm.RelocateVM(priority='defaultpriority')
属性が存在しないというエラーが表示されます。 はAttributeErrorは: 'vim.VirtualMachine' オブジェクトには属性がありません 'RelocateVM'
しかし、ここでpyvmomi documentaion https://github.com/vmware/pyvmomi/blob/master/docs/vim/VirtualMachine.rst は、具体的な方法 RelocateVMの説明(仕様、優先度)があります。
誰もがその理由だか知っているが方法はありませんか?私はまた、代わりに(そのために私はドキュメントを見つけることができませんでした)私は、私はVIMのドキュメントをチェックし
TypeError: For "spec" expected type vim.vm.RelocateSpec, but got str
このエラーを取得することを使用する場合RelocateVMの、RelocateVM_Taskを持つオブジェクトの利用可能な方法をチェックしてみました。 vm.RelocateSpec、私は関数内でそれを呼び出していますが、まだエラーをスローします。
def relocate_vm(VmToRelocate,destination_host,content):
allvmObj = content.viewManager.CreateContainerView(content.rootFolder, [pyVmomi.vim.VirtualMachine], True)
allvms = allvmObj.view
for vm in allvms:
if vm.name == VmToRelocate:
print 'vm:%s to relocate %s' %(vm.name , VmToRelocate)
task = vm.RelocateVM_Task(spec = destination_host)
助けていただければ幸いです。 ありがとう
私は移動可能/ RelocateVM_Task、任意のアイデアを呼び出したときに、私はエラーを取得していますか?私はホストと仕様を設定します。しかし、このエラーはスローされます。 pyVmomi.VmomiSupport.ManagedObjectNotFound:(vmodl.fault.ManagedObjectNotFound){ dynamicType =、 dynamicProperty =(vmodl.DynamicProperty)[]、 MSG = ''、 faultCause = 、 faultMessage =(vmodl.LocalizableMessage) []、 obj = 'vim.VirtualMachine:xxxx' } –
jramacha
@jramacha質問にあなたの更新されたコードを投稿できますか?新しい 'vim.vm.RelocateSpec'オブジェクトを作成する必要があります(' spec = host'を渡すことはできません)。 https://github.com/sijis/pyvmomi-examples/blob/master/migrate-vm.pyの例を参照してください。 – YSK
これは実際には機能していますが、私はタイプミスがありました。私はspec.host = host objを行った。どうもありがとう – jramacha