use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class VmInitModel method buildCloudInitParameters.
public VmInit buildCloudInitParameters() {
VmInit vmInit = new VmInit();
if (getHostnameEnabled()) {
vmInit.setHostname(isWindowsOS ? getWindowsHostname().getEntity() : getHostname().getEntity());
}
if (isWindowsOS) {
vmInit.setInputLocale(getInputLocale().getEntity());
vmInit.setUiLanguage(getUiLanguage().getEntity());
vmInit.setSystemLocale(getSystemLocale().getEntity());
vmInit.setUserLocale(getUserLocale().getEntity());
vmInit.setCustomScript(getSysprepScript().getEntity());
vmInit.setActiveDirectoryOU(getActiveDirectoryOU().getEntity());
if (getSysprepPasswordEnabled()) {
vmInit.setRootPassword(getSysprepAdminPassword().getEntity());
}
vmInit.setPasswordAlreadyStored(getSysprepPasswordSet().getEntity());
vmInit.setOrgName(getSysprepOrgName().getEntity());
} else {
vmInit.setCustomScript(getCustomScript().getEntity());
if (getRootPasswordEnabled()) {
vmInit.setRootPassword(getCloudInitRootPassword().getEntity());
}
vmInit.setPasswordAlreadyStored(getCloudInitPasswordSet().getEntity());
}
vmInit.setUserName(getUserName().getEntity());
vmInit.setAuthorizedKeys(getAuthorizedKeys().getEntity());
if (getRegenerateKeysEnabled().getEntity()) {
vmInit.setRegenerateKeys(Boolean.TRUE);
}
if (getNetworkEnabled().getEntity()) {
saveNetworkFields();
if (!networkMap.isEmpty()) {
for (Map.Entry<String, VmInitNetwork> entry : networkMap.entrySet()) {
VmInitNetwork vmInitNetwork = entry.getValue();
if (vmInitNetwork.getBootProtocol() != Ipv4BootProtocol.STATIC_IP) {
vmInitNetwork.setIp(null);
vmInitNetwork.setNetmask(null);
vmInitNetwork.setGateway(null);
}
if (vmInitNetwork.getIpv6BootProtocol() != Ipv6BootProtocol.STATIC_IP) {
vmInitNetwork.setIpv6Address(null);
vmInitNetwork.setIpv6Prefix(null);
vmInitNetwork.setIpv6Gateway(null);
}
vmInitNetwork.setStartOnBoot(startOnBootNetworkNames.contains(entry.getKey()));
vmInitNetwork.setName(entry.getKey());
}
vmInit.setNetworks(new ArrayList<>(networkMap.values()));
}
}
vmInit.setDnsServers(getDnsServers().getEntity());
vmInit.setDnsSearch(getDnsSearchDomains().getEntity());
return vmInit;
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class VmInitModel method buildModelSpecificParameters.
private VmInit buildModelSpecificParameters(boolean isWindows) {
VmInit vmInit = buildCloudInitParameters();
if (isWindows && getWindowsSysprepTimeZoneEnabled().getEntity()) {
Map.Entry<String, String> entry = getWindowsSysprepTimeZone().getSelectedItem();
vmInit.setTimeZone(entry.getKey());
} else if (!isWindows && getTimeZoneEnabled().getEntity()) {
Map.Entry<String, String> entry = getTimeZoneList().getSelectedItem();
vmInit.setTimeZone(entry.getKey());
}
if (isWindows) {
vmInit.setDomain(getSysprepDomain().getSelectedItem());
}
return vmInit;
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class CloudInitHandlerMetadataProtocolTest method startOnBootFalse.
@SuppressWarnings("unchecked")
private static Pair startOnBootFalse() {
VmInit vmInit = new VmInit();
VmInitNetwork underTest = new VmInitNetwork();
underTest.setStartOnBoot(false);
vmInit.setNetworks(Collections.singletonList(underTest));
return new Pair(vmInit, new IllegalArgumentException("Malformed input", new IllegalArgumentException("'Start on boot' must be true")));
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class CloudInitHandlerMetadataProtocolTest method staticIPv4.
/**
* ENI after fix 1464043:
* payload:
* "network-interfaces" : "iface eth0 inet static\n address 192.168.122.180\n netmask 255.255.255.0\n gateway 192.168.122.1\n"
*
* cloud-init-output.log: ok
*
* virt-cat img:/etc/sysconfig/network-scripts/ifcfg-eth0:
* BOOTPROTO=static
* DEVICE=eth0
* IPADDR=192.168.122.182
* NETMASK=255.255.255.0
* ONBOOT=yes
* TYPE=Ethernet
* USERCTL=no
*
* ----------------------------------------------------------
*/
private static Pair<VmInit, String> staticIPv4() {
final VmInitNetwork underTest = new VmInitNetwork();
underTest.setName(IFACE_NAME);
underTest.setBootProtocol(Ipv4BootProtocol.STATIC_IP);
underTest.setIp(IPV4_ADDRESS);
underTest.setNetmask(IPV4_NETMASK);
underTest.setGateway(IPV4_GATEWAY);
underTest.setStartOnBoot(true);
VmInit vmInit = new VmInit();
vmInit.setNetworks(Collections.singletonList(underTest));
String expectedOutput = "{\n" + " \"links\": [\n" + " {\n" + " \"id\": \"iface name\",\n" + " \"type\": \"vif\",\n" + " \"name\": \"iface name\"\n" + " }\n" + " ],\n" + " \"networks\": [\n" + " {\n" + " \"id\": \"iface name\",\n" + " \"type\": \"ipv4\",\n" + " \"link\": \"iface name\",\n" + " \"ip_address\": \"ipv4 address\",\n" + " \"netmask\": \"ipv4 netmask\",\n" + " \"gateway\": \"ipv4 gateway\"\n" + " }\n" + " ]\n" + "}";
return new Pair<>(vmInit, expectedOutput);
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class CloudInitHandlerMetadataProtocolTest method staticIPv6AddressOnly.
/**
* payload:
* {"links":[{"name":"eth0","id":"eth0","type":"vif"}],"networks":[{"link":"eth0","id":"eth0","ip_address":"2001:cdba::3257:9652","type":"ipv6"}]}
*
* cloud-init-output.log: ok
* but cannot login to machine (because i dont have ipv6 configured on my local machine?)
*
* virt-cat img:/etc/sysconfig/network-scripts/ifcfg-eth0
* BOOTPROTO=static
* DEVICE=eth0
* IPV6ADDR=2001:cdba::3257:9652
* IPV6INIT=yes
* ONBOOT=yes
* TYPE=Ethernet
* USERCTL=no
*/
private static Pair<VmInit, String> staticIPv6AddressOnly() {
final VmInitNetwork underTest = new VmInitNetwork();
underTest.setName(IFACE_NAME);
underTest.setIpv6BootProtocol(Ipv6BootProtocol.STATIC_IP);
underTest.setIpv6Address(IPV6_ADDRESS);
underTest.setStartOnBoot(true);
VmInit vmInit = new VmInit();
vmInit.setNetworks(Collections.singletonList(underTest));
String expectedOutput = "{\n" + " \"links\": [\n" + " {\n" + " \"id\": \"iface name\",\n" + " \"type\": \"vif\",\n" + " \"name\": \"iface name\"\n" + " }\n" + " ],\n" + " \"networks\": [\n" + " {\n" + " \"id\": \"iface name\",\n" + " \"type\": \"ipv6\",\n" + " \"link\": \"iface name\",\n" + " \"ip_address\": \"ipv6 address\"\n" + " }\n" + " ]\n" + "}";
return new Pair<>(vmInit, expectedOutput);
}
Aggregations