Search in sources :

Example 21 with Pair

use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.

the class CloudInitHandlerMetadataProtocolTest method dhcpIPv4.

/**
 * ENI after fix 1464043:
 * payload:
 * "network-interfaces" : "iface eth0 inet dhcp\n"
 *
 * cloud-init-output.log: ok
 *
 * virt-cat img:/etc/sysconfig/network-scripts/ifcfg-eth0:
 * BOOTPROTO=dhcp
 * DEVICE=eth0
 * ONBOOT=yes
 * TYPE=Ethernet
 * USERCTL=no
 *
 * cat vm:/etc/sysconfig/network-scripts/ifcfg-eth0:
 * same as in virt-cat of img + HWADDR
 *
 * -----------------------------------------------------------------------------------------------
 * openstack metadata
 *
 * payload:
 *{"links":[{"name":"eth0","id":"eth0","type":"vif"}],"networks":[{"link":"eth0","id":"eth0","type":"dhcp4"}]}
 *
 * cloud-init-output.log: ok
 * final behavior: first boot - got ip from dhcp
 *
 * virt-cat img:/etc/sysconfig/network-scripts/ifcfg-eth0:
 * BOOTPROTO=dhcp
 * DEVICE=eth0
 * ONBOOT=yes
 * TYPE=Ethernet
 * USERCTL=no
 *
 * cat vm:/etc/sysconfig/network-scripts/ifcfg-eth0 (after first boot):
 * same as in virt-cat of img
 *
 * cat vm:/etc/sysconfig/network-scripts/ifcfg-eth0 (after second boot):
 * same as after first boot + HWADDR
 */
private static Pair<VmInit, String> dhcpIPv4() {
    final VmInitNetwork underTest = new VmInitNetwork();
    underTest.setName(IFACE_NAME);
    underTest.setBootProtocol(Ipv4BootProtocol.DHCP);
    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_dhcp\",\n" + "      \"link\": \"iface name\"\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 22 with Pair

use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.

the class CloudInitHandlerMetadataProtocolTest method params.

@Parameterized.Parameters(name = "{index}: {1}")
public static Collection<Object[]> params() {
    Pair noneAndNone = noneAndNone();
    Pair staticIPv4 = staticIPv4();
    Pair staticIPv6 = staticIPv6();
    Pair staticIPv6AddressOnly = staticIPv6AddressOnly();
    Pair staticIPv4AndIPv6 = staticIPv4AndIPv6();
    Pair dhcpIPv4 = dhcpIPv4();
    Pair dhcpIPv6 = dhcpIPv6();
    Pair staticIPv4WithDns = staticIPv4WithDns();
    Pair dnsServersOnly = dnsServersOnly();
    Pair startOnBootFalse = startOnBootFalse();
    return Arrays.asList(new Object[][] { { noneAndNone.getFirst(), noneAndNone.getSecond() }, { staticIPv4.getFirst(), staticIPv4.getSecond() }, { staticIPv6.getFirst(), staticIPv6.getSecond() }, { staticIPv6AddressOnly.getFirst(), staticIPv6AddressOnly.getSecond() }, { staticIPv4AndIPv6.getFirst(), staticIPv4AndIPv6.getSecond() }, { dhcpIPv4.getFirst(), dhcpIPv4.getSecond() }, { dhcpIPv6.getFirst(), dhcpIPv6.getSecond() }, { staticIPv4WithDns.getFirst(), staticIPv4WithDns.getSecond() }, { dnsServersOnly.getFirst(), dnsServersOnly.getSecond() }, { startOnBootFalse.getFirst(), startOnBootFalse.getSecond() } });
}
Also used : Pair(org.ovirt.engine.core.common.utils.Pair)

Example 23 with Pair

use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.

the class CloudInitHandlerMetadataProtocolTest method staticIPv4WithDns.

private static Pair<VmInit, String> staticIPv4WithDns() {
    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));
    vmInit.setDnsSearch("search1 search2");
    vmInit.setDnsServers("nameserver1 nameserver2");
    String expectedOutput = "{\n" + "  \"links\": [\n" + "    {\n" + "      \"name\": \"iface name\",\n" + "      \"id\": \"iface name\",\n" + "      \"type\": \"vif\"\n" + "    }\n" + "  ],\n" + "  \"services\": [\n" + "    {\n" + "      \"address\": \"nameserver1\",\n" + "      \"type\": \"dns\"\n" + "    },\n" + "    {\n" + "      \"address\": \"nameserver2\",\n" + "      \"type\": \"dns\"\n" + "    }\n" + "  ],\n" + "  \"networks\": [\n" + "    {\n" + "      \"netmask\": \"ipv4 netmask\",\n" + "      \"dns_search\": [\n" + "        \"search1\",\n" + "        \"search2\"\n" + "      ],\n" + "      \"link\": \"iface name\",\n" + "      \"id\": \"iface name\",\n" + "      \"ip_address\": \"ipv4 address\",\n" + "      \"type\": \"ipv4\",\n" + "      \"gateway\": \"ipv4 gateway\",\n" + "      \"dns_nameservers\": [\n" + "        \"nameserver1\",\n" + "        \"nameserver2\"\n" + "      ]\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 24 with Pair

use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.

the class CloudInitHandlerMetadataProtocolTest method dhcpIPv6.

/**
 * payload:
 * {"links":[{"name":"eth0","id":"eth0","type":"vif"}],"networks":[{"link":"eth0","id":"eth0","type":"dhcp6"}]}
 *
 * virt-cat img:/etc/sysconfig/network-scripts/ifcfg-eth0:
 * BOOTPROTO=dhcp
 * DEVICE=eth0
 * ONBOOT=yes
 * TYPE=Ethernet
 * USERCTL=no
 *
 * cat vm:/etc/sysconfig/network-scripts/ifcfg-eth0 (after first boot):
 * same as in virt-cat img
 *
 * cat vm:/etc/sysconfig/network-scripts/ifcfg-eth0 (after second boot):
 * same as after first boot + HWADDR
 */
private static Pair<VmInit, String> dhcpIPv6() {
    final VmInitNetwork underTest = new VmInitNetwork();
    underTest.setName(IFACE_NAME);
    underTest.setIpv6BootProtocol(Ipv6BootProtocol.DHCP);
    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_dhcp\",\n" + "      \"link\": \"iface name\"\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 25 with Pair

use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.

the class VolumeGeoRepListModel method updateConfig.

private void updateConfig() {
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    List<IFrontendActionAsyncCallback> callbacks;
    final GlusterVolumeGeoReplicationSessionConfigModel geoRepConfigModel = (GlusterVolumeGeoReplicationSessionConfigModel) getWindow();
    LinkedHashMap<String, String> oldConfigs = geoRepConfigModel.getConfigs();
    geoRepConfigModel.startProgress();
    for (EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>> newConfigEntity : geoRepConfigModel.getConfigsModel().getItems()) {
        Pair<Boolean, GlusterGeoRepSessionConfiguration> newConfigPair = newConfigEntity.getEntity();
        GlusterGeoRepSessionConfiguration newConfig = newConfigPair.getSecond();
        boolean isOldConfigNull = oldConfigs.get(newConfig.getKey()) == null;
        boolean isNewConfigNull = newConfig.getValue() == null;
        if (!isNewConfigNull && !newConfig.getValue().isEmpty() && (isOldConfigNull || !newConfig.getValue().equals(oldConfigs.get(newConfig.getKey())))) {
            actionTypes.add(ActionType.SetGeoRepConfig);
            parameters.add(geoRepConfigModel.formGeoRepConfigParameters(newConfig));
        }
        if (newConfigPair.getFirst()) {
            actionTypes.add(ActionType.ResetDefaultGeoRepConfig);
            parameters.add(geoRepConfigModel.formGeoRepConfigParameters(newConfig));
        }
    }
    int numberOfConfigUpdates = parameters.size();
    if (numberOfConfigUpdates == 0) {
        geoRepConfigModel.stopProgress();
        closeWindow();
        return;
    }
    callbacks = new ArrayList<>(Collections.nCopies(numberOfConfigUpdates, (IFrontendActionAsyncCallback) null));
    callbacks.set(numberOfConfigUpdates - 1, result -> {
        geoRepConfigModel.stopProgress();
        closeWindow();
    });
    // Failure call back. Update the config list just to reflect any new changes and default error msg
    // dialog is thrown.
    Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, result -> fetchConfigForSession(geoRepConfigModel.getGeoRepSession()), this);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

Pair (org.ovirt.engine.core.common.utils.Pair)147 ArrayList (java.util.ArrayList)61 Guid (org.ovirt.engine.core.compat.Guid)61 HashMap (java.util.HashMap)30 VDS (org.ovirt.engine.core.common.businessentities.VDS)26 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)25 Test (org.junit.Test)24 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)19 List (java.util.List)16 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)16 Map (java.util.Map)13 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)13 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)12 VM (org.ovirt.engine.core.common.businessentities.VM)12 HashSet (java.util.HashSet)10 VmInit (org.ovirt.engine.core.common.businessentities.VmInit)10 VmInitNetwork (org.ovirt.engine.core.common.businessentities.VmInitNetwork)10 EngineException (org.ovirt.engine.core.common.errors.EngineException)9 Callable (java.util.concurrent.Callable)8 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)8