Добавление хоста в группу портов с помощью pyvomim
Я пытаюсь добавить хост в группу портов в vshere, используя pyvmomi. связь и все работает очень хорошо. когда я пытаюсь добавить хост в группу портов, я получаю следующую ошибку.
Traceback (most recent call last):
File "/home/vkm/PycharmProjects/cdm/cdmapp/cdm/helper/switch.py", line 40, in <module>
vcenter.AddHostPortgroup(host,inputs['dvs_name'],inputs['dv_port_name'])
File "/home/vkm/PycharmProjects/cdm/cdmapp/cdm/helper/vcenter.py", line 239, in AddHostPortgroup
host.configManager.networkSystem.AddPortGroup(portgroup_spec)
File "/home/vkm/PycharmProjects/cdm/cmdenv/lib/python3.5/site-packages/pyVmomi/VmomiSupport.py", line 580, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "/home/vkm/PycharmProjects/cdm/cmdenv/lib/python3.5/site-packages/pyVmomi/VmomiSupport.py", line 386, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/home/vkm/PycharmProjects/cdm/cmdenv/lib/python3.5/site-packages/pyVmomi/SoapAdapter.py", line 1366, in InvokeMethod
raise obj # pylint: disable-msg=E0702
pyVmomi.VmomiSupport.NotFound: (vim.fault.NotFound) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = 'The object or item referred to could not be found.',
faultCause = <unset>,
faultMessage = (vmodl.LocalizableMessage) []
}
Вот мой код:
def AddHostPortgroup(self,host, vswitchName, portgroupName):
portgroup_spec = vim.host.PortGroup.Specification()
portgroup_spec.vswitchName = vswitchName
portgroup_spec.name = portgroupName
network_policy = vim.host.NetworkPolicy()
network_policy.security = vim.host.NetworkPolicy.SecurityPolicy()
network_policy.security.allowPromiscuous = True
network_policy.security.macChanges = False
network_policy.security.forgedTransmits = False
portgroup_spec.policy = network_policy
host.configManager.networkSystem.AddPortGroup(portgroup_spec)
Пожалуйста, помогите в этом.