Search in sources :

Example 6 with VmGuestAgentInterface

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;
}
Also used : VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) IpVersion(org.ovirt.engine.api.model.IpVersion) Ip(org.ovirt.engine.api.model.Ip) ArrayList(java.util.ArrayList)

Example 7 with VmGuestAgentInterface

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;
}
Also used : VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface)

Example 8 with VmGuestAgentInterface

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));
}
Also used : VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) Test(org.junit.Test)

Example 9 with VmGuestAgentInterface

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;
}
Also used : VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface)

Example 10 with VmGuestAgentInterface

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);
}
Also used : VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) ArrayList(java.util.ArrayList)

Aggregations

VmGuestAgentInterface (org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface)12 ArrayList (java.util.ArrayList)7 DListElement (com.google.gwt.dom.client.DListElement)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 StringJoiner (java.util.StringJoiner)1 Column (org.gwtbootstrap3.client.ui.Column)1 Row (org.gwtbootstrap3.client.ui.Row)1 Span (org.gwtbootstrap3.client.ui.html.Span)1 Test (org.junit.Test)1 Ip (org.ovirt.engine.api.model.Ip)1 IpVersion (org.ovirt.engine.api.model.IpVersion)1 ReportedDevice (org.ovirt.engine.api.model.ReportedDevice)1