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);
}
}
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;
}
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;
}
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;
}
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);
}
}
}
Aggregations