@Override public HostNetworkQos getHostNetworkQos() { if (networkAttachment.isQosOverridden()) { return HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos()); } else { return networkQos; } }
/** * Check whether the network attachment has any QoS configured on it, whether via its network or overridden. * * @param networkAttachment * The network interface. * @param network * The network attached to the interface. * @return true iff any QoS is applied to the interface. */ public static boolean qosConfiguredOnInterface(NetworkAttachment networkAttachment, Network network) { if (networkAttachment != null && networkAttachment.isQosOverridden()) { return networkAttachment.getHostNetworkQos() != null && !networkAttachment.getHostNetworkQos().isEmpty(); } else { return network != null && network.getQosId() != null; } }
private void verifyRelationWithHostNetworkQos(NetworkAttachment entity) { AnonymousHostNetworkQos hostNetworkQos = entity.getHostNetworkQos(); if (hostNetworkQos != null && !Objects.equals(hostNetworkQos.getId(), entity.getId())) { throw new IllegalArgumentException( String.format("Overridden HostNetworkQos using id %s which does not related to given entity id %s", hostNetworkQos.getId(), entity.getId())); } }
@Override public void save(NetworkAttachment entity) { verifyRelationWithHostNetworkQos(entity); hostNetworkQosDao.persistQosChanges(entity.getId(), asHostNetworkQos(entity.getHostNetworkQos())); DnsResolverConfiguration dnsResolverConfiguration = entity.getDnsResolverConfiguration(); if (dnsResolverConfiguration != null) { Validate.isTrue(dnsResolverConfiguration.getId() == null); dnsResolverConfigurationDao.save(dnsResolverConfiguration); } super.save(entity); }
@Override public void update(NetworkAttachment entity) { verifyRelationWithHostNetworkQos(entity); hostNetworkQosDao.persistQosChanges(entity.getId(), asHostNetworkQos(entity.getHostNetworkQos())); DnsResolverConfiguration dnsResolverConfiguration = entity.getDnsResolverConfiguration(); if (dnsResolverConfiguration == null) { dnsResolverConfigurationDao.removeByNetworkAttachmentId(entity.getId()); } else { if (dnsResolverConfiguration.getId() == null) { dnsResolverConfigurationDao.save(dnsResolverConfiguration); } else { dnsResolverConfigurationDao.update(dnsResolverConfiguration); } } super.update(entity); }
AnonymousHostNetworkQos hostNetworkQos = entity.getHostNetworkQos(); if (hostNetworkQos != null) { model.setQos(QosMapper.map(HostNetworkQos.fromAnonymousHostNetworkQos(hostNetworkQos), null));
private void storeAttachmentParamsBeforeDetach() { NetworkAttachment networkAttachment = networkModel.getNetworkAttachment(); if (networkAttachment == null) { return; } NetworkParameters netParams = new NetworkParameters(); IPv4Address ipv4Address = networkAttachment.getIpConfiguration().getIpv4PrimaryAddress(); if (ipv4Address != null) { netParams.setIpv4BootProtocol(ipv4Address.getBootProtocol()); netParams.setIpv4Address(ipv4Address.getAddress()); netParams.setIpv4Netmask(ipv4Address.getNetmask()); netParams.setIpv4Gateway(ipv4Address.getGateway()); } IpV6Address ipv6Address = networkAttachment.getIpConfiguration().getIpv6PrimaryAddress(); if (ipv6Address != null) { netParams.setIpv6BootProtocol(ipv6Address.getBootProtocol()); netParams.setIpv6Address(ipv6Address.getAddress()); netParams.setIpv6Prefix(ipv6Address.getPrefix()); netParams.setIpv6Gateway(ipv6Address.getGateway()); } netParams.setHostNetworkQos(HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos())); netParams.setQosOverridden(networkAttachment.isQosOverridden()); netParams.setCustomProperties(networkAttachment.getProperties()); netParams.setDnsResolverConfiguration(networkAttachment.getDnsResolverConfiguration()); networkModel.getSetupModel().getNetworkToLastDetachParams().put(networkModel.getName(), netParams); }