当我使用pyVmomi创建资源池时,我收到Invalid parameter
错误。我的代码如下:
from pyVim import connect
import atexit
import logging
from pyVmomi import vim
import datetime
from keystoneauth1.identity import v3
from keystoneauth1 import session
from novaclient import client
from pyVim import connect
import atexit
import logging
from pyVmomi import vim
import datetime
auth = v3.Password(auth_url="http://192.168.3.201:5000/v3", username="admin",password="admin",
project_name="admin",user_domain_id="default", project_domain_id="default")
sess = session.Session(auth=auth)
nova = client.Client('2.1',session=sess)
si = connect.SmartConnect(host='192.168.3.13', user='administrator@vsphere.local', pwd='!QAZ2wsx')
atexit.register(connect.Disconnect, si)
dc = si.content.rootFolder.childEntity[0]
cr = dc.hostFolder.childEntity[0]
import pdb
pdb.set_trace()
rootResourcePool = cr.resourcePool
#rootResourcePool = vim.ResourcePool('cxl')
rp_spec = vim.ResourceConfigSpec()
alla = vim.ResourceAllocationInfo()
alla.limit = -1
alla.expandableReservation = True
alla.reservation = 12
rp_spec.cpuAllocation = alla
blla = vim.ResourceAllocationInfo()
blla.limit = -1
blla.expandableReservation = True
blla.reservation = 12
rp_spec.memoryAllocation = blla
rp_obj = rootResourcePool.CreateResourcePool('123', rp_spec)
我收到以下错误:
(Pdb) rootResourcePool.CreateResourcePool('123', rp_spec)
*** vmodl.fault.InvalidArgument: (vmodl.fault.InvalidArgument) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = u'\u6307\u5b9a\u7684\u53c2\u6570\u4e0d\u6b63\u786e: ',
faultCause = <unset>,
faultMessage = (vmodl.LocalizableMessage) [],
invalidProperty = <unset>
}
我不明白为什么会收到此错误?
我用github尝试了这个,但它仍然不起作用。
答案 0 :(得分:0)
除了 overheadLimit 之外,我们必须指定alla = vim.ResourceAllocationInfo()
对象的所有属性。
添加:
alla.shares (vim.SharesInfo):
blla.shares (vim.SharesInfo):