protected List<CustomizationAdapterMapping> createCustomizationAdapterMappings( VmwareProcessClient vmwareProcessClient, VirtualMachine machine) { List<CustomizationAdapterMapping> nicSettingMap = new ArrayList<CustomizationAdapterMapping>(); // VirtualEthernetCardを取得 VirtualMachineConfigInfo configInfo = machine.getConfig(); for (VirtualDevice device : configInfo.getHardware().getDevice()) { if (device instanceof VirtualEthernetCard) { VirtualEthernetCard virtualEthernetCard = VirtualEthernetCard.class.cast(device); CustomizationAdapterMapping mapping = new CustomizationAdapterMapping(); CustomizationIPSettings settings = new CustomizationIPSettings(); // すべてのNICをDHCPにする CustomizationDhcpIpGenerator dhcpIp = new CustomizationDhcpIpGenerator(); settings.setIp(dhcpIp); mapping.setMacAddress(virtualEthernetCard.getMacAddress()); mapping.setAdapter(settings); nicSettingMap.add(mapping); } } return nicSettingMap; }
private VirtualMachineCloneSpec configureVirtualMachineCloneSpec(VirtualMachineRelocateSpec rSpec, String linuxName, boolean postConfiguration) throws Exception { VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec(); cloneSpec.setPowerOn(true); cloneSpec.setTemplate(false); //cloneSpec.setSnapshot(currentSnapshot.getMOR()); cloneSpec.setLocation(rSpec); if (postConfiguration) { CustomizationSpec customizationSpec = new CustomizationSpec(); CustomizationLinuxPrep linuxPrep = new CustomizationLinuxPrep(); CustomizationFixedName fixedName = new CustomizationFixedName(); fixedName.setName(linuxName); linuxPrep.setHostName(fixedName); linuxPrep.setDomain(""); linuxPrep.setHwClockUTC(true); //linuxPrep.setTimeZone("Etc/UTC"); customizationSpec.setIdentity(linuxPrep); customizationSpec.setGlobalIPSettings(new CustomizationGlobalIPSettings()); CustomizationAdapterMapping[] nicSettingMap = new CustomizationAdapterMapping[1]; nicSettingMap[0] = new CustomizationAdapterMapping(); nicSettingMap[0].adapter = new CustomizationIPSettings(); nicSettingMap[0].adapter.setIp(new CustomizationDhcpIpGenerator()); customizationSpec.setNicSettingMap(nicSettingMap); cloneSpec.setCustomization(customizationSpec); } return cloneSpec; }