static VirtualDeviceConfigSpec createNicSpec(String netName, String nicName) throws Exception { VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec(); nicSpec.setOperation(VirtualDeviceConfigSpecOperation.add); VirtualEthernetCard nic = new VirtualPCNet32(); VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo(); nicBacking.setDeviceName(netName); Description info = new Description(); info.setLabel(nicName); info.setSummary(netName); nic.setDeviceInfo(info); // type: "generated", "manual", "assigned" by VC nic.setAddressType("generated"); nic.setBacking(nicBacking); nic.setKey(0); nicSpec.setDevice(nic); return nicSpec; }
static Extension createExtensionObject(Properties props) { String companyStr = props.getProperty("companyStr"); String descStr = props.getProperty("descStr"); String keyStr = props.getProperty("keyStr"); String extUrl = props.getProperty("extUrl"); String adminEmail = props.getProperty("adminEmail"); String version = props.getProperty("version"); Description description = new Description(); description.setLabel(keyStr); description.setSummary(descStr); ExtensionServerInfo esi = new ExtensionServerInfo(); esi.setDescription(description); esi.setUrl(extUrl); esi.setCompany(companyStr); // the following type must NOT be changed esi.setType("com.vmware.vim.viClientScripts"); esi.setAdminEmail( new String[] { adminEmail } ); ExtensionClientInfo eci = new ExtensionClientInfo(); eci.setCompany(companyStr); eci.setUrl(extUrl); eci.setType("com.vmware.vim.viClientScripts"); eci.setVersion(version); eci.setDescription(description); Extension ext = new Extension(); ext.setServer(new ExtensionServerInfo[]{esi}); ext.setClient(new ExtensionClientInfo[] {eci}); ext.setDescription(description); ext.setKey(keyStr); ext.setVersion(version); ext.setLastHeartbeatTime(Calendar.getInstance()); return ext; }