use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method setUpVmInit.
private List<VmInit> setUpVmInit() {
List<VmInit> vmInits = new ArrayList<>(NAMES.length);
for (int i = 0; i < NAMES.length; i++) {
VmInit vmInit = mock(VmInit.class);
vmInits.add(vmInit);
}
return vmInits;
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class CloudInitHandlerMetadataProtocolTest method staticIPv6.
private static Pair<VmInit, String> staticIPv6() {
final VmInitNetwork underTest = new VmInitNetwork();
underTest.setName(IFACE_NAME);
underTest.setIpv6BootProtocol(Ipv6BootProtocol.STATIC_IP);
underTest.setIpv6Address(IPV6_ADDRESS);
underTest.setIpv6Prefix(IPV6_PREFIX);
underTest.setIpv6Gateway(IPV6_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\": \"ipv6\",\n" + " \"link\": \"iface name\",\n" + " \"ip_address\": \"ipv6 address\",\n" + " \"netmask\": \"666\",\n" + " \"gateway\": \"ipv6 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 noneAndNone.
/**
* ENI before fix 1464043:
* payload:
* "network-interfaces" : "iface eth0 inet none\niface eth0 inet6 none\n" - error:
* cloud-init-output.log:
* cloudinit.net.ParserError: Interface eth0 can only be defined once. Re-defined in 'None'.
*
* login: impossible
*
* -----------------------------------------------------------------------------------------------
* ENI after fix 1464043:
* payload:
* "network-interfaces" : "iface eth0 inet none\n"
* cloud-init-output.log:
* ValueError: Unknown subnet type 'none' found for interface 'eth0'
*
* /etc/sysconfig/network-scripts/ifcfg-eth0:
* DEVICE="eth0"
* BOOTPROTO="dhcp"
* ONBOOT="yes"
* TYPE="Ethernet"
* PERSISTENT_DHCLIENT="yes"
*
* login: impossible
*
* -----------------------------------------------------------------------------------------------
* Openstack Metadata Service:
*
* payload:
* {}
*
* cloud-init-output.log: ok
*
* /etc/sysconfig/network-scripts/ifcfg-eth0
* BOOTPROTO="dhcp"
* DEVICE="eth0"
* ONBOOT="yes"
* TYPE="Ethernet"
* PERSISTENT_DHCLIENT="yes"
*
* cat console:/etc/sysconfig/network-scripts/ifcfg-eth0 (after reboot)
* BOOTPROTO=dhcp
* HWADDR=...
* DEVICE=eth0
* ONBOOT=yes
* TYPE=Ethernet
* USERCTL=no
*/
private static Pair<VmInit, String> noneAndNone() {
VmInit vmInit = new VmInit();
VmInitNetwork underTest = new VmInitNetwork();
underTest.setStartOnBoot(true);
vmInit.setNetworks(Collections.singletonList(underTest));
return new Pair<>(vmInit, null);
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class CloudInitHandlerMetadataProtocolTest method staticIPv4AndIPv6.
private static Pair<VmInit, String> staticIPv4AndIPv6() {
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.setIpv6BootProtocol(Ipv6BootProtocol.STATIC_IP);
underTest.setIpv6Address(IPV6_ADDRESS);
underTest.setIpv6Prefix(IPV6_PREFIX);
underTest.setIpv6Gateway(IPV6_GATEWAY);
underTest.setStartOnBoot(true);
VmInit vmInit = new VmInit();
vmInit.setNetworks(Collections.singletonList(underTest));
String expectedOutput = "{\n" + " \"links\": [\n" + " {\n" + " \"name\": \"iface name\",\n" + " \"id\": \"iface name\",\n" + " \"type\": \"vif\"\n" + " }\n" + " ],\n" + " \"networks\": [\n" + " {\n" + " \"netmask\": \"ipv4 netmask\",\n" + " \"link\": \"iface name\",\n" + " \"id\": \"iface name\",\n" + " \"ip_address\": \"ipv4 address\",\n" + " \"type\": \"ipv4\",\n" + " \"gateway\": \"ipv4 gateway\"\n" + " },\n" + " {\n" + " \"netmask\": \"666\",\n" + " \"link\": \"iface name\",\n" + " \"id\": \"iface name\",\n" + " \"ip_address\": \"ipv6 address\",\n" + " \"type\": \"ipv6\",\n" + " \"gateway\": \"ipv6 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 dnsServersOnly.
private static Pair<VmInit, String> dnsServersOnly() {
VmInit vmInit = new VmInit();
VmInitNetwork underTest = new VmInitNetwork();
underTest.setStartOnBoot(true);
vmInit.setNetworks(Collections.singletonList(underTest));
vmInit.setDnsSearch("search1 search2");
vmInit.setDnsServers("nameserver1 nameserver2 nameserver3");
String expectedOutput = "{\n" + " \"services\": [\n" + " {\n" + " \"address\": \"nameserver1\",\n" + " \"type\": \"dns\"\n" + " },\n" + " {\n" + " \"address\": \"nameserver2\",\n" + " \"type\": \"dns\"\n" + " },\n" + " {\n" + " \"address\": \"nameserver3\",\n" + " \"type\": \"dns\"\n" + " }\n" + " ]\n" + "}";
return new Pair<>(vmInit, expectedOutput);
}
Aggregations