private CustomizationLinuxPrep getCustomizationLinuxPrep(GuestInputs guestInputs) { CustomizationLinuxPrep customizationLinuxPrep = new CustomizationLinuxPrep(); customizationLinuxPrep.setDomain(guestInputs.getDomain()); customizationLinuxPrep.setTimeZone(String.valueOf(guestInputs.getTimeZone())); CustomizationFixedName computerName = new CustomizationFixedName(); computerName.setName(guestInputs.getComputerName()); customizationLinuxPrep.setHostName(computerName); if (guestInputs.isHwClockUTC()) { customizationLinuxPrep.setHwClockUTC(true); } else { customizationLinuxPrep.setHwClockUTC(false); } return customizationLinuxPrep; }
public void customizeNic(String macAddress, String hostName, String address, SubnetState subnetState, CustomizationSpec template) { // remove existing mapping template.getNicSettingMap().removeIf(x -> Objects.equals(x.getMacAddress(), macAddress)); CustomizationAdapterMapping mapping = new CustomizationAdapterMapping(); mapping.setMacAddress(macAddress); CustomizationIPSettings adapter = new CustomizationIPSettings(); mapping.setAdapter(adapter); adapter.setSubnetMask(cidr2mask(subnetState.subnetCIDR)); adapter.getGateway().add(subnetState.gatewayAddress); adapter.setDnsDomain(subnetState.domain); CustomizationFixedIp ipGen = new CustomizationFixedIp(); ipGen.setIpAddress(address); adapter.setIp(ipGen); template.getNicSettingMap().add(mapping); if (isLinux()) { CustomizationLinuxPrep identity = new CustomizationLinuxPrep(); template.setIdentity(identity); identity.setDomain(subnetState.domain); CustomizationFixedName name = new CustomizationFixedName(); if (hostName == null || hostName.isEmpty()) { hostName = makeHostName(UriUtils.getLastPathSegment(this.state.documentSelfLink)); } name.setName(hostName); identity.setHostName(name); template.setOptions(new CustomizationLinuxOptions()); } }
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; }
private CustomizationUserData getCustomizationUserData(GuestInputs guestInputs) { CustomizationUserData userData = new CustomizationUserData(); userData.setFullName(guestInputs.getOwnerName()); userData.setOrgName(guestInputs.getOwnerOrganization()); userData.setProductId(guestInputs.getProductKey()); CustomizationFixedName computerName = new CustomizationFixedName(); computerName.setName(guestInputs.getComputerName()); userData.setComputerName(computerName); return userData; }