use of org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface in project ovirt-engine by oVirt.
the class ReportedDeviceMapper method map.
@Mapping(from = ReportedDevice.class, to = VmGuestAgentInterface.class)
public static VmGuestAgentInterface map(ReportedDevice model, VmGuestAgentInterface template) {
VmGuestAgentInterface entity = template != null ? template : new VmGuestAgentInterface();
if (model.isSetVm() && model.getVm().isSetId()) {
entity.setVmId(GuidUtils.asGuid(model.getVm().getId()));
}
if (model.isSetName()) {
entity.setInterfaceName(model.getName());
}
if (model.isSetMac() && model.getMac().isSetAddress()) {
entity.setMacAddress(model.getMac().getAddress());
}
if (model.isSetIps() && model.getIps().isSetIps()) {
List<String> ipv4 = new ArrayList<>();
List<String> ipv6 = new ArrayList<>();
for (Ip ip : model.getIps().getIps()) {
IpVersion version = IpHelper.getVersion(ip);
if (version != null) {
switch(version) {
case V4:
ipv4.add(ip.getAddress());
break;
case V6:
ipv6.add(ip.getAddress());
break;
}
}
}
entity.setIpv4Addresses(ipv4);
entity.setIpv6Addresses(ipv6);
}
return entity;
}
use of org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface in project ovirt-engine by oVirt.
the class VmGuestAgentInterfaceDaoTest method createVmGuestAgentInterface.
private VmGuestAgentInterface createVmGuestAgentInterface() {
VmGuestAgentInterface guestAgentInterface = new VmGuestAgentInterface();
guestAgentInterface.setVmId(FixturesTool.VM_RHEL5_POOL_50);
guestAgentInterface.setMacAddress("AA:AA:AA:AA:AA:AA");
guestAgentInterface.setInterfaceName("p2p3");
guestAgentInterface.setIpv4Addresses(Arrays.asList("1.1.1.1", "2.2.2.2", "3.3.3.3"));
guestAgentInterface.setIpv6Addresses(Collections.emptyList());
return guestAgentInterface;
}
use of org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface in project ovirt-engine by oVirt.
the class VmGuestAgentInterfaceDaoTest method save.
@Test
public void save() {
VmGuestAgentInterface guestAgentInterface = createVmGuestAgentInterface();
assertFalse(dao.getAllForVm(FixturesTool.VM_RHEL5_POOL_50).contains(guestAgentInterface));
dao.save(guestAgentInterface);
assertTrue(dao.getAllForVm(FixturesTool.VM_RHEL5_POOL_50).contains(guestAgentInterface));
}
use of org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface in project ovirt-engine by oVirt.
the class BackendVmReportedDevicesResourceTest method getEntity.
@Override
protected VmGuestAgentInterface getEntity(int index) {
VmGuestAgentInterface entity = new VmGuestAgentInterface();
entity.setInterfaceName(NAMES[index]);
entity.setIpv4Addresses(Arrays.asList(ADDRESSES));
entity.setVmId(PARENT_ID);
return entity;
}
use of org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface in project ovirt-engine by oVirt.
the class VmAnalyzer method extractVmIpsFromGuestAgentInterfaces.
private String extractVmIpsFromGuestAgentInterfaces(List<VmGuestAgentInterface> nics) {
if (nics == null || nics.isEmpty()) {
return null;
}
List<String> ips = new ArrayList<>();
List<String> ips_v6 = new ArrayList<>();
for (VmGuestAgentInterface nic : nics) {
if (nic.getIpv4Addresses() != null) {
ips.addAll(nic.getIpv4Addresses());
}
if (nic.getIpv6Addresses() != null) {
ips_v6.addAll(nic.getIpv6Addresses());
}
}
ips.addAll(ips_v6);
return ips.isEmpty() ? null : String.join(" ", ips);
}
Aggregations