use of org.ovirt.engine.api.model.Ips in project ovirt-engine by oVirt.
the class V3ReportedDeviceInAdapter method adapt.
@Override
public ReportedDevice adapt(V3ReportedDevice from) {
ReportedDevice to = new ReportedDevice();
if (from.isSetLinks()) {
to.getLinks().addAll(adaptIn(from.getLinks()));
}
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetIps()) {
to.setIps(new Ips());
to.getIps().getIps().addAll(adaptIn(from.getIps().getIPs()));
}
if (from.isSetMac()) {
to.setMac(adaptIn(from.getMac()));
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetType()) {
to.setType(ReportedDeviceType.fromValue(from.getType()));
}
if (from.isSetVm()) {
to.setVm(adaptIn(from.getVm()));
}
return to;
}
use of org.ovirt.engine.api.model.Ips in project ovirt-engine by oVirt.
the class V3VmHelper method addGuestIp.
/**
* If the V4 virtual machine has IP addresses reported, then add them to the V3 {@code guest_info} element.
*/
public static void addGuestIp(V3VM vm) {
String vmId = vm.getId();
if (vmId != null) {
SystemResource systemResource = BackendApiResource.getInstance();
VmsResource vmsResource = systemResource.getVmsResource();
VmResource vmResource = vmsResource.getVmResource(vmId);
VmNicsResource nicsResource = vmResource.getNicsResource();
try {
Nics fromNics = nicsResource.list();
List<Ip> fromIps = new ArrayList<>();
for (Nic fromNic : fromNics.getNics()) {
ReportedDevices fromDevices = fromNic.getReportedDevices();
if (fromDevices != null) {
for (ReportedDevice fromDevice : fromDevices.getReportedDevices()) {
Ips deviceIps = fromDevice.getIps();
if (deviceIps != null) {
fromIps.addAll(deviceIps.getIps());
}
}
}
}
if (!fromIps.isEmpty()) {
V3GuestInfo guestInfo = vm.getGuestInfo();
if (guestInfo == null) {
guestInfo = new V3GuestInfo();
vm.setGuestInfo(guestInfo);
}
V3IPs ips = guestInfo.getIps();
if (ips == null) {
ips = new V3IPs();
guestInfo.setIps(ips);
}
ips.getIPs().addAll(adaptOut(fromIps));
}
} catch (WebApplicationException exception) {
// If an application exception is generated while retrieving the details of the NICs is safe to ignore
// it, as it may be that the user just doesn't have permission to see the NICs, but she may still have
// permissions to see the other details of the virtual machine.
}
}
}
use of org.ovirt.engine.api.model.Ips in project ovirt-engine by oVirt.
the class ReportedDeviceMapper method mapIps.
private static void mapIps(VmGuestAgentInterface vmGuestAgentInterface, ReportedDevice model) {
List<String> ipv4 = vmGuestAgentInterface.getIpv4Addresses();
List<String> ipv6 = vmGuestAgentInterface.getIpv6Addresses();
if (ipv4 != null && !ipv4.isEmpty() || ipv6 != null && !ipv6.isEmpty()) {
Ips ips = new Ips();
model.setIps(ips);
addIpsByVersion(ips, ipv4, IpVersion.V4);
addIpsByVersion(ips, ipv6, IpVersion.V6);
}
}
Aggregations