@Test public void testRemoveServicePath() throws Exception { LOG.debug("scenario: fail with service path present, no writeOnlyTransaction"); PowerMockito.stub(PowerMockito.method(PolicyWriterUtil.class, NETCONF_READ)).toReturn(new ClassBuilder().build()); final ServiceChain serviceChain = new ServiceChainBuilder() .setServicePath(Collections.singletonList(new ServicePathBuilder() .setServicePathId(42L) .build())) .build(); assertFalse(PolicyWriterUtil.removeServicePath(serviceChain, getLocation())); LOG.debug("scenario: fail with service path present, available writeOnlyTransaction, no submit future"); PowerMockito.stub(PowerMockito.method(NetconfTransactionCreator.class, NETCONF_WRITE_ONLY_TRANSACTION)).toReturn(wTxOptional); assertFalse(PolicyWriterUtil.removeServicePath(serviceChain, getLocation())); LOG.debug("scenario: fail with service path present, available writeOnlyTransaction, available future"); when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null)); assertTrue(PolicyWriterUtil.removeServicePath(serviceChain, getLocation())); }
public static boolean removeServicePath(final ServiceChain serviceChain, final PolicyManagerImpl.PolicyMapLocation location) { final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); if (serviceChain == null) { return true; } boolean result = true; List<ServicePath> servicePaths = serviceChain.getServicePath(); if (servicePaths == null || servicePaths.isEmpty()) { return true; } for (ServicePath servicePath : servicePaths) { final InstanceIdentifier<ServicePath> servicePathIid = servicePathInstanceIdentifier(servicePath.getKey()); if (netconfDeleteIfPresent(mountpoint, servicePathIid)) { LOG.trace("Service-path with ID: {} removed from node {}", servicePath.getServicePathId(), nodeId.getValue()); } else { LOG.warn("Failed to remove service-path with ID: {} from node {}", servicePath.getServicePathId(), nodeId.getValue()); result = false; } } return result; }
PolicyWriterUtil { public static boolean removeServicePath(final ServiceChain serviceChain, final PolicyManagerImpl.PolicyMapLocation location) { final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); if (serviceChain == null) { return true; } boolean result = true; List<ServicePath> servicePaths = serviceChain.getServicePath(); if (servicePaths == null || servicePaths.isEmpty()) { return true; } for (ServicePath servicePath : servicePaths) { final InstanceIdentifier<ServicePath> servicePathIid = servicePathInstanceIdentifier(servicePath.getKey()); if (netconfDeleteIfPresent(mountpoint, servicePathIid)) { LOG.trace("Service-path with ID: {} removed from node {}", servicePath.getServicePathId(), nodeId.getValue()); } else { LOG.warn("Failed to remove service-path with ID: {} from node {}", servicePath.getServicePathId(), nodeId.getValue()); result = false; } } return result; } }
PolicyWriterUtil { public static boolean removeServicePath(final ServiceChain serviceChain, final PolicyManagerImpl.PolicyMapLocation location) { final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); if (serviceChain == null) { return true; } boolean result = true; List<ServicePath> servicePaths = serviceChain.getServicePath(); if (servicePaths == null || servicePaths.isEmpty()) { return true; } for (ServicePath servicePath : servicePaths) { final InstanceIdentifier<ServicePath> servicePathIid = servicePathInstanceIdentifier(servicePath.getKey()); if (netconfDeleteIfPresent(mountpoint, servicePathIid)) { LOG.trace("Service-path with ID: {} removed from node {}", servicePath.getServicePathId(), nodeId.getValue()); } else { LOG.warn("Failed to remove service-path with ID: {} from node {}", servicePath.getServicePathId(), nodeId.getValue()); result = false; } } return result; } private  PolicyWriterUtil(); }
PolicyWriterUtil { public static boolean removeServicePath(final ServiceChain serviceChain, final PolicyManagerImpl.PolicyMapLocation location) { final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); if (serviceChain == null) { return true; } boolean result = true; List<ServicePath> servicePaths = serviceChain.getServicePath(); if (servicePaths == null || servicePaths.isEmpty()) { return true; } for (ServicePath servicePath : servicePaths) { final InstanceIdentifier<ServicePath> servicePathIid = servicePathInstanceIdentifier(servicePath.getKey()); if (netconfDeleteIfPresent(mountpoint, servicePathIid)) { LOG.trace("Service-path with ID: {} removed from node {}", servicePath.getServicePathId(), nodeId.getValue()); } else { LOG.warn("Failed to remove service-path with ID: {} from node {}", servicePath.getServicePathId(), nodeId.getValue()); result = false; } } return result; } private  PolicyWriterUtil(); static boolean writeClassMap(@Nonnull final ClassMap classMap,
                                        final PolicyManagerImpl.PolicyMapLocation policyMapLocation); static boolean removeClassMap(final ClassMap classMap, final PolicyManagerImpl.PolicyMapLocation location); static boolean writePolicyMap(final PolicyMap policyMap, final PolicyManagerImpl.PolicyMapLocation location); static boolean removePolicyMap(final PolicyManagerImpl.PolicyMapLocation location); static boolean writePolicyMapEntry(final Class policyMapEntry,
                                              final PolicyManagerImpl.PolicyMapLocation location); static boolean removePolicyMapEntry(final Class policyMapEntry, final PolicyManagerImpl.PolicyMapLocation location); static boolean writeInterface(final PolicyManagerImpl.PolicyMapLocation location); static boolean removeInterface(final PolicyManagerImpl.PolicyMapLocation location); static boolean writeRemote(final ServiceFfName remoteForwarder,
                                      final PolicyManagerImpl.PolicyMapLocation location); static boolean removeRemote(final ServiceFfName remoteForwarder, final PolicyManagerImpl.PolicyMapLocation location); static boolean writeServicePath(final ServiceChain serviceChain,
                                           final PolicyManagerImpl.PolicyMapLocation location); static boolean removeServicePath(final ServiceChain serviceChain, final PolicyManagerImpl.PolicyMapLocation location); static InstanceIdentifier<PolicyMap> policyMapInstanceIdentifier(final String policyMapName); static InstanceIdentifier<ServicePolicy> interfaceInstanceIdentifier(final String ethernetName); static U netconfRead(final DataBroker mountpoint,
                                                       final InstanceIdentifier<U> readIID); }
PolicyWriterUtil { public static boolean removeServicePath(final ServiceChain serviceChain, final PolicyManagerImpl.PolicyMapLocation location) { final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); if (serviceChain == null) { return true; } boolean result = true; List<ServicePath> servicePaths = serviceChain.getServicePath(); if (servicePaths == null || servicePaths.isEmpty()) { return true; } for (ServicePath servicePath : servicePaths) { final InstanceIdentifier<ServicePath> servicePathIid = servicePathInstanceIdentifier(servicePath.getKey()); if (netconfDeleteIfPresent(mountpoint, servicePathIid)) { LOG.trace("Service-path with ID: {} removed from node {}", servicePath.getServicePathId(), nodeId.getValue()); } else { LOG.warn("Failed to remove service-path with ID: {} from node {}", servicePath.getServicePathId(), nodeId.getValue()); result = false; } } return result; } private  PolicyWriterUtil(); static boolean writeClassMap(@Nonnull final ClassMap classMap,
                                        final PolicyManagerImpl.PolicyMapLocation policyMapLocation); static boolean removeClassMap(final ClassMap classMap, final PolicyManagerImpl.PolicyMapLocation location); static boolean writePolicyMap(final PolicyMap policyMap, final PolicyManagerImpl.PolicyMapLocation location); static boolean removePolicyMap(final PolicyManagerImpl.PolicyMapLocation location); static boolean writePolicyMapEntry(final Class policyMapEntry,
                                              final PolicyManagerImpl.PolicyMapLocation location); static boolean removePolicyMapEntry(final Class policyMapEntry, final PolicyManagerImpl.PolicyMapLocation location); static boolean writeInterface(final PolicyManagerImpl.PolicyMapLocation location); static boolean removeInterface(final PolicyManagerImpl.PolicyMapLocation location); static boolean writeRemote(final ServiceFfName remoteForwarder,
                                      final PolicyManagerImpl.PolicyMapLocation location); static boolean removeRemote(final ServiceFfName remoteForwarder, final PolicyManagerImpl.PolicyMapLocation location); static boolean writeServicePath(final ServiceChain serviceChain,
                                           final PolicyManagerImpl.PolicyMapLocation location); static boolean removeServicePath(final ServiceChain serviceChain, final PolicyManagerImpl.PolicyMapLocation location); static InstanceIdentifier<PolicyMap> policyMapInstanceIdentifier(final String policyMapName); static InstanceIdentifier<ServicePolicy> interfaceInstanceIdentifier(final String ethernetName); static U netconfRead(final DataBroker mountpoint,
                                                       final InstanceIdentifier<U> readIID);  }