Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly created PortGroup not found when supplied to create VM #92

Open
nhi-vanye opened this issue Jun 3, 2020 · 0 comments
Open

Newly created PortGroup not found when supplied to create VM #92

nhi-vanye opened this issue Jun 3, 2020 · 0 comments
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@nhi-vanye
Copy link

DATACENTER  = vsphere.get_datacenter(name=ENV.VMWARE_DATACENTER)
HOST        = vsphere.get_host(name=ENV.VSPHERE_HOST,datacenter_id=DATACENTER.id)
DATASTORE   = vsphere.get_datastore(name=ENV.VMWARE_DATASTORE, datacenter_id=DATACENTER.id)
POOL        = vsphere.get_resource_pool( name="{}/Resources".format(ENV.VMWARE_CLUSTER), datacenter_id=DATACENTER.id)
NETWORK     = vsphere.get_network(name=ENV.VMWARE_VM_PORTGROUP, datacenter_id=DATACENTER.id)
TEMPLATE    = vsphere.get_virtual_machine(name=OS.TEMPLATE, datacenter_id=DATACENTER.id)

INTERFACES  = [{"network_id": NETWORK.id, "adapter_type": "vmxnet3",}]

# with no physical NICs attached to the switch, this is internal to the host
INTERNAL_NET = vsphere.HostVirtualSwitch(
        "vswitch",
        active_nics=[""],
        host_system_id=HOST.id,
        network_adapters=[""],
        standby_nics=[""])

PORT_GROUP = vsphere.HostPortGroup(
        "port-group",
        host_system_id=HOST.id,
        virtual_switch_name=INTERNAL_NET.name,
        opts=pulumi.ResourceOptions(depends_on=[INTERNAL_NET]))


INTERFACES.append( {"network_id": PORT_GROUP.id, "adapter_type": "vmxnet3",} )

vm = vsphere.VirtualMachine(
        m["name"],
        opts=pulumi.ResourceOptions(depends_on=[PORT_GROUP]),
        num_cpus=m["hw"]["cpu"],
        memory=m["hw"]["ram"],
        resource_pool_id=POOL.id,
        datastore_id=DATASTORE.id,
        guest_id=TEMPLATE.guest_id,
        network_interfaces=INTERFACES,
        clone={
            "template_uuid": TEMPLATE.id,
        },
        disks=[
            {
                "label": "disk0",
                "size": TEMPLATE.disks[0]["size"],
                "eagerly_scrub": False,
                "thin_provisioned": True,
            }
        ],
        # we need a CDROM device to access cloud-config
        cdrom={"client_device": True},
        vapp=m["vapp"],
    )
Previewing update (testing):
     Type                                Name              Plan
 +   pulumi:pulumi:Stack                 XXXXXXXX-testing  create
 +   ├─ vsphere:index:HostVirtualSwitch  vswitch           create
 +   ├─ vsphere:index:HostPortGroup      port-group        create
 +   ├─ vsphere:index:VirtualMachine     rmo-cc-1          create
 +   ├─ vsphere:index:VirtualMachine     rmo-su-1          create
 +   ├─ vsphere:index:VirtualMachine     rmo-revo-1        create
 +   ├─ vsphere:index:VirtualMachine     rmo-revo-2        create
 +   └─ vsphere:index:VirtualMachine     rmo-ui-1          create

The vSwitch and PortGroup are created but fail a lookup

Diagnostics:
  vsphere:index:VirtualMachine (rmo-cc-1):
    error: error reconfiguring virtual machine: error processing network device changes post-clone: network_interface.1: could not find network with ID "tf-HostPortGroup:host-41:port-group-daeb3ed"
govc host.portgroup.info -host 192.168.0.41
Name:                    VM Network
Virtual switch:          vSwitch0
VLAN ID:                 0
Active ports:            6
Allow promiscuous mode:  No
Allow forged transmits:  Yes
Allow MAC changes:       Yes

Name:                    Management Network
Virtual switch:          vSwitch0
VLAN ID:                 0
Active ports:            1
Allow promiscuous mode:  No
Allow forged transmits:  Yes
Allow MAC changes:       Yes

Name:                    Storage Management Network
Virtual switch:          vSwitch1
VLAN ID:                 0
Active ports:            1
Allow promiscuous mode:  No
Allow forged transmits:  No
Allow MAC changes:       No

Name:                    port-group-daeb3ed
Virtual switch:          vswitch-d1c3553
VLAN ID:                 0
Active ports:            0
Allow promiscuous mode:  No
Allow forged transmits:  Yes
Allow MAC changes:       Yes
@leezen leezen added the bug label Jun 3, 2020
@infin8x infin8x added kind/bug Some behavior is incorrect or out of spec and removed bug labels Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

3 participants