use of org.ovirt.engine.api.model.Network in project ovirt-engine by oVirt.
the class IscsiBondMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.IscsiBond.class, to = IscsiBond.class)
public static IscsiBond map(org.ovirt.engine.core.common.businessentities.IscsiBond from, IscsiBond to) {
IscsiBond iscsiBond = (to != null) ? to : new IscsiBond();
DataCenter dataCenter = new DataCenter();
dataCenter.setId(from.getStoragePoolId().toString());
iscsiBond.setDataCenter(dataCenter);
iscsiBond.setName(from.getName());
iscsiBond.setDescription(from.getDescription());
if (from.getId() != null) {
iscsiBond.setId(from.getId().toString());
}
Networks networks = new Networks();
for (Guid id : from.getNetworkIds()) {
Network network = new Network();
network.setId(id.toString());
networks.getNetworks().add(network);
}
iscsiBond.setNetworks(networks);
StorageConnections connections = new StorageConnections();
for (String id : from.getStorageConnectionIds()) {
StorageConnection conn = new StorageConnection();
conn.setId(id);
connections.getStorageConnections().add(conn);
}
iscsiBond.setStorageConnections(connections);
return iscsiBond;
}
use of org.ovirt.engine.api.model.Network in project ovirt-engine by oVirt.
the class NetworkAttachmentMapper method getModelNetwork.
private static Network getModelNetwork(NetworkAttachment model) {
Network network = model.getNetwork();
if (network == null) {
network = new Network();
model.setNetwork(network);
}
return network;
}
use of org.ovirt.engine.api.model.Network in project ovirt-engine by oVirt.
the class NetworkAttachmentMapper method map.
@Mapping(from = NetworkAttachment.class, to = org.ovirt.engine.core.common.businessentities.network.NetworkAttachment.class)
public static org.ovirt.engine.core.common.businessentities.network.NetworkAttachment map(NetworkAttachment model, org.ovirt.engine.core.common.businessentities.network.NetworkAttachment template) {
org.ovirt.engine.core.common.businessentities.network.NetworkAttachment entity = template == null ? new org.ovirt.engine.core.common.businessentities.network.NetworkAttachment() : template;
if (model.isSetId()) {
entity.setId(GuidUtils.asGuid(model.getId()));
}
if (model.isSetNetwork()) {
Network networkModel = model.getNetwork();
if (networkModel.isSetId()) {
entity.setNetworkId(GuidUtils.asGuid(networkModel.getId()));
}
if (networkModel.isSetName()) {
entity.setNetworkName(networkModel.getName());
}
}
if (model.isSetHostNic()) {
HostNic hostNic = model.getHostNic();
if (hostNic.isSetId()) {
entity.setNicId(GuidUtils.asGuid(hostNic.getId()));
} else {
entity.setNicId(null);
}
if (hostNic.isSetName()) {
entity.setNicName(hostNic.getName());
} else {
entity.setNicName(null);
}
}
if (model.isSetProperties()) {
entity.setProperties(CustomPropertiesParser.toMap(model.getProperties()));
}
if (model.isSetIpAddressAssignments()) {
entity.setIpConfiguration(new org.ovirt.engine.core.common.businessentities.network.IpConfiguration());
IpAddressAssignments ipAddressAssignments = model.getIpAddressAssignments();
entity.getIpConfiguration().setIPv4Addresses(new ArrayList<>());
entity.getIpConfiguration().setIpV6Addresses(new ArrayList<>());
for (IpAddressAssignment ipAddressAssignment : ipAddressAssignments.getIpAddressAssignments()) {
if (IpVersion.V6 == getIpVersion(ipAddressAssignment)) {
entity.getIpConfiguration().getIpV6Addresses().add(mapIpv6AddressAssignment(ipAddressAssignment));
} else {
entity.getIpConfiguration().getIPv4Addresses().add(mapIpv4AddressAssignment(ipAddressAssignment));
}
}
}
if (model.isSetDnsResolverConfiguration()) {
entity.setDnsResolverConfiguration(DnsResolverConfigurationMapper.map(entity.getDnsResolverConfiguration(), model.getDnsResolverConfiguration()));
}
if (model.isSetQos()) {
HostNetworkQos hostNetworkQos = (HostNetworkQos) QosMapper.map(model.getQos(), null);
entity.setHostNetworkQos(AnonymousHostNetworkQos.fromHostNetworkQos(hostNetworkQos));
}
return entity;
}
use of org.ovirt.engine.api.model.Network in project ovirt-engine by oVirt.
the class BackendHostNicsResource method setCustomProperties.
private void setCustomProperties(Map<Guid, NetworkAttachment> attachmentsByNetworkId, Map<String, Guid> networkNameToNetworkIdMap, HostNic hostNic) {
Network network = hostNic.getNetwork();
if (network == null) {
return;
}
String networkName = network.getName();
NetworkAttachment networkAttachment = attachmentsByNetworkId.get(networkNameToNetworkIdMap.get(networkName));
if (networkAttachment == null) {
return;
}
Map<String, String> properties = networkAttachment.getProperties();
if (properties != null) {
hostNic.setProperties(CustomPropertiesParser.fromMap(properties));
}
}
use of org.ovirt.engine.api.model.Network in project ovirt-engine by oVirt.
the class BackendNetworkLabelResource method get.
@Override
public NetworkLabel get() {
NetworkLabels labels = parent.list();
if (labels != null) {
for (NetworkLabel label : labels.getNetworkLabels()) {
if (label.getId().equals(id)) {
label.setNetwork(new Network());
label.getNetwork().setId(parent.getNetworkId().toString());
return addLinks(label);
}
}
}
return notFound();
}
Aggregations