use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateCustomProperties.
ValidationResult validateCustomProperties(SimpleCustomPropertiesUtil util, Map<String, String> validPropertiesForVm, Map<String, String> validPropertiesForNonVm) {
for (NetworkAttachment attachment : params.getNetworkAttachments()) {
Network network = existingNetworkRelatedToAttachment(attachment);
if (attachment.hasProperties()) {
List<ValidationError> errors = util.validateProperties(network.isVmNetwork() ? validPropertiesForVm : validPropertiesForNonVm, attachment.getProperties());
if (!errors.isEmpty()) {
handleCustomPropertiesError(util, errors);
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_NETWORK_CUSTOM_PROPERTIES_BAD_INPUT;
return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, network.getName()));
}
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateQosNotPartiallyConfigured.
/**
* Ensure that either none or all of the networks on a single interface have QoS configured on them.
*/
ValidationResult validateQosNotPartiallyConfigured(Collection<NetworkAttachment> attachmentsToConfigure) {
Set<String> someSubInterfacesHaveQos = new HashSet<>();
Set<String> notAllSubInterfacesHaveQos = new HashSet<>();
// first map which interfaces have some QoS configured on them, and which interfaces lack some QoS configuration
for (NetworkAttachment networkAttachment : attachmentsToConfigure) {
Network network = getNetworkRelatedToAttachment(networkAttachment);
if (NetworkUtils.qosConfiguredOnInterface(networkAttachment, network)) {
someSubInterfacesHaveQos.add(networkAttachment.getNicName());
} else {
notAllSubInterfacesHaveQos.add(networkAttachment.getNicName());
}
}
// if any base interface has some sub-interfaces with QoS and some without - this is a partial configuration
for (String ifaceName : someSubInterfacesHaveQos) {
if (notAllSubInterfacesHaveQos.contains(ifaceName)) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_INTERFACES_WITHOUT_QOS, ReplacementUtils.createSetVariableString("ACTION_TYPE_FAILED_HOST_NETWORK_QOS_INTERFACES_WITHOUT_QOS_LIST", ifaceName));
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method getAttachmentsToConfigure.
/**
* @return all attachments passed in {@link HostSetupNetworksParameters#networkAttachments} plus
* all previously existing attachments not mentioned in user request, but except for those listed in
* {@link org.ovirt.engine.core.common.action.HostSetupNetworksParameters#removedNetworkAttachments}
*/
Collection<NetworkAttachment> getAttachmentsToConfigure() {
Map<Guid, NetworkAttachment> networkAttachmentsMap = new HashMap<>(existingAttachments.size() + params.getNetworkAttachments().size());
List<NetworkAttachment> newAttachments = new ArrayList<>();
for (NetworkAttachment attachment : params.getNetworkAttachments()) {
if (attachment.getId() == null) {
newAttachments.add(attachment);
} else {
networkAttachmentsMap.put(attachment.getId(), attachment);
}
}
for (NetworkAttachment existingAttachment : existingAttachments) {
Guid existingAttachmentId = existingAttachment.getId();
if (!networkAttachmentsMap.containsKey(existingAttachmentId) && !params.getRemovedNetworkAttachments().contains(existingAttachmentId)) {
networkAttachmentsMap.put(existingAttachmentId, existingAttachment);
}
}
List<NetworkAttachment> result = new ArrayList<>(networkAttachmentsMap.values());
result.addAll(newAttachments);
return result;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NicNameNicIdCompleterTest method testProperNetworkAttachmentBindingToNicNameAndNicIdAccessors.
@Test
public void testProperNetworkAttachmentBindingToNicNameAndNicIdAccessors() {
NetworkAttachment networkAttachment = new NetworkAttachment();
networkAttachment.setNicId(Guid.newGuid());
networkAttachment.setNicName("nic name");
NicNameAndNicIdAccessors accessors = new NicNameAndNicIdAccessors.FromNetworkAttachment(networkAttachment);
assertThat("id should be bound to nicId", accessors.getId(), is(networkAttachment.getNicId()));
assertThat("name should be bound to nicName", accessors.getName(), is(networkAttachment.getNicName()));
accessors.setId(Guid.newGuid());
accessors.setName("another name");
assertThat("id should be bound to nicId", networkAttachment.getNicId(), is(accessors.getId()));
assertThat("name should be bound to nicName", networkAttachment.getNicName(), is(accessors.getName()));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class ReportedConfigurationsFillerTest method testFillReportedConfiguration.
/**
* @param network network which will contain qos and will be attached to nic.
* @param nic nic to which network should be attached
* @param networkQos qos of network
*/
private void testFillReportedConfiguration(Network network, VdsNetworkInterface nic, HostNetworkQos networkQos) {
nic.setNetworkName(network.getName());
when(interfaceDao.getAllInterfacesForVds(eq(hostId))).thenReturn(Arrays.asList(baseNic, vlanNic));
when(networkDao.getAllForCluster(eq(clusterId))).thenReturn(Collections.singletonList(network));
NetworkAttachment networkAttachment = new NetworkAttachment();
networkAttachment.setNicId(baseNic.getId());
networkAttachment.setNicName(baseNic.getName());
networkAttachment.setNetworkId(network.getId());
when(effectiveHostNetworkQos.getQos(networkAttachment, network)).thenReturn(networkQos);
filler.fillReportedConfiguration(networkAttachment, hostId);
verify(filler).createNetworkInSyncWithVdsNetworkInterface(networkAttachment, nic, network, reportedDnsResolverConfiguration, cluster);
}
Aggregations