Search in sources :

Example 26 with VmInit

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;
}
Also used : VmInit(org.ovirt.engine.core.common.businessentities.VmInit) ArrayList(java.util.ArrayList)

Example 27 with VmInit

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);
}
Also used : VmInit(org.ovirt.engine.core.common.businessentities.VmInit) VmInitNetwork(org.ovirt.engine.core.common.businessentities.VmInitNetwork) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 28 with VmInit

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);
}
Also used : VmInit(org.ovirt.engine.core.common.businessentities.VmInit) VmInitNetwork(org.ovirt.engine.core.common.businessentities.VmInitNetwork) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 29 with VmInit

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);
}
Also used : VmInit(org.ovirt.engine.core.common.businessentities.VmInit) VmInitNetwork(org.ovirt.engine.core.common.businessentities.VmInitNetwork) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 30 with VmInit

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);
}
Also used : VmInit(org.ovirt.engine.core.common.businessentities.VmInit) VmInitNetwork(org.ovirt.engine.core.common.businessentities.VmInitNetwork) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

VmInit (org.ovirt.engine.core.common.businessentities.VmInit)34 VmInitNetwork (org.ovirt.engine.core.common.businessentities.VmInitNetwork)14 Pair (org.ovirt.engine.core.common.utils.Pair)10 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 Map (java.util.Map)3 SortedMap (java.util.SortedMap)3 TreeMap (java.util.TreeMap)3 Guid (org.ovirt.engine.core.compat.Guid)3 List (java.util.List)2 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)2 Ipv4BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)2 IdsQueryParameters (org.ovirt.engine.core.common.queries.IdsQueryParameters)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 XmlNode (org.ovirt.engine.core.utils.ovf.xml.XmlNode)2 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 Before (org.junit.Before)1