use of org.ovirt.engine.core.common.businessentities.VmInit 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.businessentities.VmInit 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.businessentities.VmInit 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.businessentities.VmInit in project ovirt-engine by oVirt.
the class OvfWriter method writeVmInit.
protected void writeVmInit() {
if (vmBase.getVmInit() != null) {
VmInit vmInit = vmBase.getVmInit();
_writer.writeStartElement("VmInit");
if (vmInit.getHostname() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "hostname", vmInit.getHostname());
}
if (vmInit.getDomain() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "domain", vmInit.getDomain());
}
if (vmInit.getTimeZone() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "timeZone", vmInit.getTimeZone());
}
if (vmInit.getAuthorizedKeys() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "authorizedKeys", vmInit.getAuthorizedKeys());
}
if (vmInit.getRegenerateKeys() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "regenerateKeys", vmInit.getRegenerateKeys().toString());
}
if (vmInit.getDnsSearch() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "dnsSearch", vmInit.getDnsSearch());
}
if (vmInit.getDnsServers() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "dnsServers", vmInit.getDnsServers());
}
if (vmInit.getNetworks() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "networks", VmInitUtils.networkListToJson(vmInit.getNetworks()));
}
if (vmInit.getWinKey() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "winKey", vmInit.getWinKey());
}
if (vmInit.getRootPassword() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "rootPassword", vmInit.getRootPassword());
}
if (vmInit.getCustomScript() != null) {
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "customScript", vmInit.getCustomScript());
}
_writer.writeEndElement();
}
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class BackendVmsResourceTest 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;
}
Aggregations