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);
}
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() } });
}
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);
}
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);
}
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);
}
Aggregations