use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class GeniusProvider method getIpFromDpnId.
// TODO Should better use the Genius InterfaceManager to avoid duplicate code
// https://bugs.opendaylight.org/show_bug.cgi?id=8127
public Optional<String> getIpFromDpnId(DpnIdType dpnid) {
GetEndpointIpForDpnInputBuilder builder = new GetEndpointIpForDpnInputBuilder();
builder.setDpid(dpnid.getValue());
GetEndpointIpForDpnInput input = builder.build();
if (interfaceManagerRpcService == null) {
LOG.error("getIpFromDpnId({}) failed (service couldn't be retrieved)", input);
return Optional.empty();
}
try {
LOG.debug("getIpFromDpnId: invoking rpc");
RpcResult<GetEndpointIpForDpnOutput> output = interfaceManagerRpcService.getEndpointIpForDpn(input).get();
if (!output.isSuccessful()) {
LOG.error("getIpFromDpnId({}) failed: {}", input, output);
return Optional.empty();
}
LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
List<IpAddress> localIps = output.getResult().getLocalIps();
// TODO need to figure out why it returns a list, using first entry for now
return Optional.ofNullable(localIps).filter(ipAddresses -> !ipAddresses.isEmpty()).map(ipAddresses -> ipAddresses.get(0)).map(IpAddress::getIpv4Address).map(Ipv4Address::getValue);
} catch (InterruptedException | ExecutionException e) {
LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
}
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class PolicyAceFlowProgrammer method getPolicyAceFlowWrapper.
private Optional<PolicyAceFlowWrapper> getPolicyAceFlowWrapper(Matches matches) {
IngressInterface ingressInterface = matches.getAugmentation(IngressInterface.class);
if (ingressInterface != null) {
Optional<PolicyAceFlowWrapper> interfaceFlowOpt = getIngressInterfaceFlow(ingressInterface);
if (interfaceFlowOpt.isPresent()) {
return interfaceFlowOpt;
}
}
Service service = matches.getAugmentation(Service.class);
if (service != null) {
Optional<PolicyAceFlowWrapper> serviceFlowOpt = getPolicyServiceFlow(service);
if (serviceFlowOpt.isPresent()) {
return serviceFlowOpt;
}
}
return Optional.absent();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class TunnelStateChangeListener method unbindService.
private void unbindService(String tunnelInterfaceName) {
coordinator.enqueueJob(tunnelInterfaceName, () -> {
LOG.info("Unbind egress policy service on tunnel {}", tunnelInterfaceName);
BoundServices boundServices = getBoundServices(tunnelInterfaceName, Collections.emptyList());
interfaceManager.unbindService(tunnelInterfaceName, ServiceModeEgress.class, boundServices);
return null;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class TunnelStateChangeListener method bindService.
private void bindService(String tunnelInterfaceName) {
coordinator.enqueueJob(tunnelInterfaceName, () -> {
LOG.info("Bind egress policy service on tunnel {}", tunnelInterfaceName);
List<Instruction> instructions = Collections.singletonList(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_POLICY_CLASSIFIER_TABLE, 0));
BoundServices boundServices = getBoundServices(tunnelInterfaceName, instructions);
interfaceManager.bindService(tunnelInterfaceName, ServiceModeEgress.class, boundServices);
return null;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.
the class ToasterTest method testToaster.
@Test
public void testToaster() throws Exception {
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName providerOn = new ObjectName("org.opendaylight.controller:name=OpendaylightToaster,type=toaster-provider");
long toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
assertEquals(0, toastsMade);
boolean success = true;
// Make toasts using OSGi service
success &= kitchenService.makeBreakfast(EggsType.SCRAMBLED, HashBrown.class, 4).get().isSuccessful();
success &= kitchenService.makeBreakfast(EggsType.POACHED, WhiteBread.class, 8).get().isSuccessful();
assertTrue("Not all breakfasts succeeded", success);
// Verify toasts made count on provider via JMX/config-subsystem
toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
assertEquals(2, toastsMade);
}
Aggregations