Search in sources :

Example 1 with Ip

use of org.ovirt.engine.api.model.Ip in project ovirt-engine by oVirt.

the class HostNicMapper method mapIpv6ToModel.

private static void mapIpv6ToModel(VdsNetworkInterface entity, HostNic model) {
    BootProtocol ipv6BootProtocol = Ipv6BootProtocolMapper.map(entity.getIpv6BootProtocol());
    if (ipv6BootProtocol != null) {
        model.setIpv6BootProtocol(ipv6BootProtocol);
    }
    if (entity.getIpv6Address() != null || entity.getIpv6Gateway() != null || entity.getIpv6Prefix() != null) {
        final Ip ipv6 = new Ip();
        ipv6.setVersion(IpVersion.V6);
        if (entity.getIpv6Address() != null) {
            ipv6.setAddress(entity.getIpv6Address());
        }
        if (entity.getIpv6Gateway() != null) {
            ipv6.setGateway(entity.getIpv6Gateway());
        }
        if (entity.getIpv6Prefix() != null) {
            ipv6.setNetmask(entity.getIpv6Prefix().toString());
        }
        model.setIpv6(ipv6);
    }
}
Also used : Ip(org.ovirt.engine.api.model.Ip) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) BootProtocol(org.ovirt.engine.api.model.BootProtocol) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)

Example 2 with Ip

use of org.ovirt.engine.api.model.Ip in project ovirt-engine by oVirt.

the class InitializationMapper method createIpModel.

private static Ip createIpModel(VmInitNetworkIpInfoFetcher ipInfoFetcher) {
    Ip ip = new Ip();
    ip.setAddress(ipInfoFetcher.fetchIp());
    ip.setNetmask(ipInfoFetcher.fetchNetmask());
    ip.setGateway(ipInfoFetcher.fetchGateway());
    return ip;
}
Also used : Ip(org.ovirt.engine.api.model.Ip)

Example 3 with Ip

use of org.ovirt.engine.api.model.Ip in project ovirt-engine by oVirt.

the class VmMapper method mapConsoleSession.

/**
 * This method maps the session of the 'console user', if exists. This is the ovirt user who opened a session
 * through the user-console; the one who is said to be 'logged in' (or 'have the ticket') to this VM. Currently
 * engine makes available only the name and IP of this user. In the future it may make available also the connection
 * protocol used in the session (spice/vnc).
 */
private static Sessions mapConsoleSession(org.ovirt.engine.core.common.businessentities.VM vm, Sessions sessions) {
    // currently in format user@domain, so needs to be
    String consoleUserName = vm.getConsoleCurentUserName();
    // parsed.
    if (consoleUserName != null && !consoleUserName.isEmpty()) {
        String userName = parseUserName(consoleUserName);
        String domainName = parseDomainName(consoleUserName);
        User consoleUser = new User();
        consoleUser.setUserName(userName);
        consoleUser.setDomain(new Domain());
        consoleUser.getDomain().setName(domainName);
        Session consoleSession = new Session();
        consoleSession.setUser(consoleUser);
        if (vm.getClientIp() != null && !vm.getClientIp().isEmpty()) {
            Ip ip = new Ip();
            ip.setAddress(vm.getClientIp());
            consoleSession.setIp(ip);
        }
        consoleSession.setConsoleUser(true);
        // TODO: in the future, map the connection protocol as well
        sessions.getSessions().add(consoleSession);
    }
    return sessions;
}
Also used : User(org.ovirt.engine.api.model.User) Ip(org.ovirt.engine.api.model.Ip) Domain(org.ovirt.engine.api.model.Domain) Session(org.ovirt.engine.api.model.Session)

Example 4 with Ip

use of org.ovirt.engine.api.model.Ip 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 5 with Ip

use of org.ovirt.engine.api.model.Ip in project ovirt-engine by oVirt.

the class ReportedDeviceMapper method addIpsByVersion.

private static void addIpsByVersion(Ips ips, List<String> entityIps, IpVersion ipVersion) {
    if (entityIps != null) {
        for (String entityIp : entityIps) {
            Ip ip = new Ip();
            ip.setAddress(entityIp);
            ip.setVersion(ipVersion);
            ips.getIps().add(ip);
        }
    }
}
Also used : Ip(org.ovirt.engine.api.model.Ip)

Aggregations

Ip (org.ovirt.engine.api.model.Ip)16 IpVersion (org.ovirt.engine.api.model.IpVersion)6 Test (org.junit.Test)5 BootProtocol (org.ovirt.engine.api.model.BootProtocol)4 IpAddressAssignment (org.ovirt.engine.api.model.IpAddressAssignment)4 Ipv4BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)4 Ipv6BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)4 ArrayList (java.util.ArrayList)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 Domain (org.ovirt.engine.api.model.Domain)1 Ips (org.ovirt.engine.api.model.Ips)1 Nic (org.ovirt.engine.api.model.Nic)1 Nics (org.ovirt.engine.api.model.Nics)1 ReportedDevice (org.ovirt.engine.api.model.ReportedDevice)1 ReportedDeviceType (org.ovirt.engine.api.model.ReportedDeviceType)1 ReportedDevices (org.ovirt.engine.api.model.ReportedDevices)1 Session (org.ovirt.engine.api.model.Session)1 User (org.ovirt.engine.api.model.User)1 SystemResource (org.ovirt.engine.api.resource.SystemResource)1 VmNicsResource (org.ovirt.engine.api.resource.VmNicsResource)1