use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class OvfOvaReader method getNetworkInterface.
@Override
protected VmNetworkInterface getNetworkInterface(XmlNode node) {
VmNetworkInterface iface = new VmNetworkInterface();
iface.setId(Guid.newGuid());
interfaces.add(iface);
return iface;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class OvfOvirtReader method buildNicReference.
protected void buildNicReference() {
XmlNodeList list = selectNodes(_document, "//*/Nic", _xmlNS);
for (XmlNode node : list) {
VmNetworkInterface iface = new VmNetworkInterface();
iface.setId(new Guid(node.attributes.get("ovf:id").getValue()));
interfaces.add(iface);
}
if (!list.iterator().hasNext()) {
String pattern = "//*/Item[" + VMD_RESOURCE_TYPE + "=" + OvfHardware.Network + "]";
list = selectNodes(_document, pattern, _xmlNS);
int nicIdx = 0;
for (XmlNode node : list) {
VmNetworkInterface iface = new VmNetworkInterface();
iface.setId(Guid.newGuid());
updateSingleNic(node, iface, ++nicIdx);
interfaces.add(iface);
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class OvfOvirtReader method getNetworkInterface.
@Override
protected VmNetworkInterface getNetworkInterface(XmlNode node) {
// prior to 3.0 the instanceId is int , in 3.1 and on this is Guid
String str = selectSingleNode(node, "rasd:InstanceId", _xmlNS).innerText;
if (!StringUtils.isNumeric(str)) {
// 3.1 and above OVF format
final Guid guid = new Guid(str);
VmNetworkInterface iface = interfaces.stream().filter(i -> i.getId().equals(guid)).findFirst().orElse(null);
if (iface == null) {
iface = new VmNetworkInterface();
iface.setId(guid);
interfaces.add(iface);
}
return iface;
} else {
// 3.0 and below OVF format
VmNetworkInterface iface = new VmNetworkInterface();
iface.setId(Guid.newGuid());
interfaces.add(iface);
return iface;
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class OvfWriter method writeNetwork.
private void writeNetwork() {
for (VmNetworkInterface iface : vmBase.getInterfaces()) {
_writer.writeStartElement("Item");
_writer.writeStartElement(RASD_URI, "Caption");
String networkName = iface.getNetworkName() != null ? iface.getNetworkName() : "[No Network]";
_writer.writeRaw("Ethernet adapter on " + networkName);
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "InstanceId");
_writer.writeRaw(iface.getId().toString());
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "ResourceType");
_writer.writeRaw(OvfHardware.Network);
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "OtherResourceType");
if (StringUtils.isNotEmpty(iface.getVnicProfileName())) {
_writer.writeRaw(iface.getVnicProfileName());
}
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "ResourceSubType");
if (iface.getType() != null) {
_writer.writeRaw(iface.getType().toString());
}
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "Connection");
if (iface.getNetworkName() != null) {
_writer.writeRaw(iface.getNetworkName());
}
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "Linked");
_writer.writeRaw(String.valueOf(iface.isLinked()));
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "Name");
_writer.writeRaw(iface.getName());
_writer.writeEndElement();
_writer.writeStartElement(RASD_URI, "ElementName");
_writer.writeRaw(iface.getName());
_writer.writeEndElement();
writeMacAddress(iface);
_writer.writeStartElement(RASD_URI, "speed");
// version prior to 2.3 may not have speed so we get it by type
if (iface.getSpeed() != null) {
_writer.writeRaw(iface.getSpeed().toString());
} else {
_writer.writeRaw(String.valueOf(VmInterfaceType.forValue(iface.getType()).getSpeed()));
}
_writer.writeEndElement();
writeManagedDeviceInfo(vmBase, iface.getId());
// item
_writer.writeEndElement();
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class AddVmAndCloneImageCommand method addVmNetwork.
@Override
protected void addVmNetwork() {
VnicProfileHelper vnicProfileHelper = new VnicProfileHelper(getClusterId(), getStoragePoolId(), AuditLogType.ADD_VM_FROM_SNAPSHOT_INVALID_INTERFACES);
for (VmNetworkInterface iface : getVmFromConfiguration().getInterfaces()) {
vnicProfileHelper.updateNicWithVnicProfileForUser(iface, getCurrentUser());
}
vnicProfileHelper.auditInvalidInterfaces(getVmName());
super.addVmNetwork();
}
Aggregations