1 Reply Latest reply on Nov 28, 2017 4:11 AM by doskiran

    Distributed Port Group assignment

    balajiyelmar1 Lurker

      How can we assign existing Distibuted port group to the VM using java?
      I tried with below code but it shows disconnected...

      VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec();
      nicSpec.setOperation(VirtualDeviceConfigSpecOperation.edit);
      for (int i = 0; i < vds.length; i++) {
      if ((vds[i] instanceof VirtualEthernetCard)
      && (vds[i].getDeviceInfo().getLabel().equalsIgnoreCase("Network Adapter 1"))) {
      VirtualEthernetCard nic = (VirtualEthernetCard) vds[i];
      VirtualDeviceBackingInfo properties = nic.getBacking();
      VirtualEthernetCardNetworkBackingInfo nicBaking = (VirtualEthernetCardNetworkBackingInfo) properties;
      nicBaking.setDeviceName(network);
      nic.setBacking(nicBaking);
      nicSpec.setDevice(nic);
      }
      }
      return nicSpec;