use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class NetworkAttachmentMapper method getModelHostNic.
private static HostNic getModelHostNic(NetworkAttachment model) {
HostNic hostNic = model.getHostNic();
if (hostNic == null) {
hostNic = new HostNic();
model.setHostNic(hostNic);
}
return hostNic;
}
use of org.ovirt.engine.api.model.HostNic 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.HostNic in project ovirt-engine by oVirt.
the class BackendHostNicsResource method idToHref.
private String idToHref(String id) {
HostNic master = new HostNic();
master.setId(id);
master.setHost(new Host());
master.getHost().setId(hostId);
return LinkHelper.addLinks(master).getHref();
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class BackendHostNicsResource method addLinks.
@Override
protected HostNic addLinks(HostNic hostNic, String... subCollectionsToExclude) {
if (hostNic.isSetVirtualFunctionsConfiguration()) {
return super.addLinks(hostNic, subCollectionsToExclude);
} else {
final HostNic resultHostNic = super.addLinks(hostNic, ArrayUtils.concat(PF_SUB_COLLECTIONS, subCollectionsToExclude));
final Iterator<Link> linkIterator = resultHostNic.getActions().getLinks().iterator();
while (linkIterator.hasNext()) {
final Link link = linkIterator.next();
if (link.getRel().equals(UPDATE_VFS_CONFIG_ACTION)) {
linkIterator.remove();
}
}
if (isBond(resultHostNic)) {
removeLldpLink(resultHostNic);
}
return resultHostNic;
}
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class BackendHostResource method toParameters.
private HostSetupNetworksParameters toParameters(Action action) {
HostSetupNetworksParameters parameters = new HostSetupNetworksParameters(guid);
Map<Guid, NetworkAttachment> attachmentsById = getBackendNetworkAttachments();
if (action.isSetModifiedNetworkAttachments()) {
for (org.ovirt.engine.api.model.NetworkAttachment model : action.getModifiedNetworkAttachments().getNetworkAttachments()) {
NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
parameters.getNetworkAttachments().add(attachment);
}
}
if (action.isSetSynchronizedNetworkAttachments()) {
Map<Guid, NetworkAttachment> networkAttachmentFromParams = Entities.businessEntitiesById(parameters.getNetworkAttachments());
for (org.ovirt.engine.api.model.NetworkAttachment model : action.getSynchronizedNetworkAttachments().getNetworkAttachments()) {
if (model.isSetId()) {
Guid networkAttachmentId = asGuid(model.getId());
if (networkAttachmentFromParams.containsKey(networkAttachmentId)) {
networkAttachmentFromParams.get(networkAttachmentId).setOverrideConfiguration(true);
} else if (attachmentsById.containsKey(networkAttachmentId)) {
NetworkAttachment networkAttachment = attachmentsById.get(networkAttachmentId);
networkAttachment.setOverrideConfiguration(true);
parameters.getNetworkAttachments().add(networkAttachment);
} else {
return handleError(new EntityNotFoundException("NetworkAttachment.id: " + model.getId()), true);
}
}
}
}
if (action.isSetModifiedLabels()) {
for (NetworkLabel label : action.getModifiedLabels().getNetworkLabels()) {
NicLabel nicLabel = new NicLabel();
nicLabel.setLabel(label.getId());
if (label.isSetHostNic()) {
nicLabel.setNicId(label.getHostNic().isSetId() ? asGuid(label.getHostNic().getId()) : null);
nicLabel.setNicName(label.getHostNic().getName());
}
parameters.getLabels().add(nicLabel);
}
}
if (action.isSetRemovedLabels()) {
for (NetworkLabel label : action.getRemovedLabels().getNetworkLabels()) {
parameters.getRemovedLabels().add(label.getId());
}
}
if (action.isSetRemovedNetworkAttachments()) {
for (org.ovirt.engine.api.model.NetworkAttachment model : action.getRemovedNetworkAttachments().getNetworkAttachments()) {
NetworkAttachment attachment = mapNetworkAttachment(attachmentsById, model);
parameters.getRemovedNetworkAttachments().add(attachment.getId());
}
}
BusinessEntityMap<Bond> bonds = getBackendHostBonds();
if (action.isSetModifiedBonds()) {
BusinessEntityMap<VdsNetworkInterface> nicsFromBackend = getBackendNics();
for (HostNic bond : action.getModifiedBonds().getHostNics()) {
completeSlaveNames(nicsFromBackend, bond);
parameters.getCreateOrUpdateBonds().add(mapBonds(bonds, bond));
}
}
if (action.isSetRemovedBonds()) {
for (HostNic bond : action.getRemovedBonds().getHostNics()) {
parameters.getRemovedBonds().add(mapBonds(bonds, bond).getId());
}
}
if (action.isSetCheckConnectivity()) {
parameters.setRollbackOnFailure(action.isCheckConnectivity());
}
if (action.isSetConnectivityTimeout()) {
parameters.setConectivityTimeout(action.getConnectivityTimeout());
}
return parameters;
}
Aggregations