Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Pyvmomi为来宾定义Pvlan ID_Python_Ansible_Vmware_Pyvmomi - Fatal编程技术网

Python 使用Pyvmomi为来宾定义Pvlan ID

Python 使用Pyvmomi为来宾定义Pvlan ID,python,ansible,vmware,pyvmomi,Python,Ansible,Vmware,Pyvmomi,我目前正在进行一个项目,基于模板自动化VM部署。为了继续,我使用Ansible 2.10和Pyvmomi 7.0.1 我在尝试定义Pvlan id(51)时遇到了一个问题,对于我的客人,这是我的剧本: --- - hosts: localhost gather_facts: no vars: vcenter_server: "100.64.31.5" vcenter_user: "xxxxx" vcenter_pass: '

我目前正在进行一个项目,基于模板自动化VM部署。为了继续,我使用Ansible 2.10和Pyvmomi 7.0.1

我在尝试定义Pvlan id(51)时遇到了一个问题,对于我的客人,这是我的剧本:

---
- hosts: localhost
  gather_facts: no
  vars:
    vcenter_server: "100.64.31.5"
    vcenter_user: "xxxxx"
    vcenter_pass: 'xxxxxx'
    datacenter_name: "xxxxxx"
    cluster_name: "xxxxxx"
  tasks:
  - name: Clone the template
    vmware_guest:
      hostname: "{{ vcenter_server }}"
      username: "{{ vcenter_user }}"
      password: "{{ vcenter_pass }}"
      validate_certs: False
      name: NewVmName    
      template: "mytemplate"
      datacenter: "{{ datacenter_name }}"
      folder: "/vm"
      cluster: "{{ cluster_name }}"
      datastore: "SAN08T2lunHDS1"
      networks:
      - vlan: 51
        ip: 100.64.67.13
        netmask: 255.255.240.0
        type: static
但我一直得到以下错误:
AttributeError:'vim.dvs.VmwareDistributedVirtualSwitch.PvlanSpec'对象没有属性“vlanId”


我已经检查了我在Vswitch、数据存储和VM上的用户权限,这方面没有要声明的内容。

好的,刚刚了解了如何继续,您应该使用端口组名称,而不是使用vlan ID

要继续,连接到Vcenter后:

  • 单击VMware主机客户端资源清册中的网络,然后单击端口组。(或Ctrl+Shift+N)
  • 右键单击您的vlan=>更新设置
  • 端口组名称是“名称”字段

  • 由于我在错误中没有看到与变量相关的任何其他内容,我怀疑这是与“mytemplate”相关的问题。这看起来更像是个问题。但是,在将问题转移到那里之前,您应该添加更多的调试信息,更具体地说是
    vim.dvs.VmwareDistributedVirtualSwitch.PvlanSpec
    ,在这里声明并准确地使用它,因为在您的帖子中没有关于它的任何线索。