@Test public void testRemoveInterface() throws Exception { PowerMockito.stub(PowerMockito.method(NetconfTransactionCreator.class, NETCONF_WRITE_ONLY_TRANSACTION)).toReturn(wTxOptional); when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null)); PolicyWriterUtil.writeInterface(getLocation()); PowerMockito.stub(PowerMockito.method(PolicyWriterUtil.class, NETCONF_READ)).toReturn(new ClassBuilder().build()); assertTrue(PolicyWriterUtil.removeInterface(getLocation())); PowerMockito.stub(PowerMockito.method(PolicyWriterUtil.class, NETCONF_READ)).toReturn(null); assertTrue(PolicyWriterUtil.removeInterface(getLocation())); PowerMockito.stub(PowerMockito.method(PolicyWriterUtil.class, NETCONF_READ)).toReturn(new ClassBuilder().build()); when(wTx.submit()).thenThrow(TransactionCommitFailedException.class); assertFalse(PolicyWriterUtil.removeInterface(getLocation())); }
public static boolean removeInterface(final PolicyManagerImpl.PolicyMapLocation location) { final String policyMapName = location.getPolicyMapName(); final String interfaceName = location.getInterfaceName(); final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); final InstanceIdentifier<ServicePolicy> servicePolicyIid = interfaceInstanceIdentifier(interfaceName); if (netconfDeleteIfPresent(mountpoint, servicePolicyIid)) { LOG.trace("Service-policy interface {}, removed from node {}", interfaceName, policyMapName, nodeId.getValue()); return true; } else { LOG.warn("Failed to remove service-policy interface {} from node {}", interfaceName, policyMapName, nodeId.getValue()); return false; } }
PolicyWriterUtil { public static boolean removeInterface(final PolicyManagerImpl.PolicyMapLocation location) { final String policyMapName = location.getPolicyMapName(); final String interfaceName = location.getInterfaceName(); final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); final InstanceIdentifier<ServicePolicy> servicePolicyIid = interfaceInstanceIdentifier(interfaceName); if (netconfDeleteIfPresent(mountpoint, servicePolicyIid)) { LOG.trace("Service-policy interface {}, removed from node {}", interfaceName, policyMapName, nodeId.getValue()); return true; } else { LOG.warn("Failed to remove service-policy interface {} from node {}", interfaceName, policyMapName, nodeId.getValue()); return false; } } }
PolicyWriterUtil { public static boolean removeInterface(final PolicyManagerImpl.PolicyMapLocation location) { final String policyMapName = location.getPolicyMapName(); final String interfaceName = location.getInterfaceName(); final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); final InstanceIdentifier<ServicePolicy> servicePolicyIid = interfaceInstanceIdentifier(interfaceName); if (netconfDeleteIfPresent(mountpoint, servicePolicyIid)) { LOG.trace("Service-policy interface {}, removed from node {}", interfaceName, policyMapName, nodeId.getValue()); return true; } else { LOG.warn("Failed to remove service-policy interface {} from node {}", interfaceName, policyMapName, nodeId.getValue()); return false; } } private  PolicyWriterUtil(); }
PolicyWriterUtil { public static boolean removeInterface(final PolicyManagerImpl.PolicyMapLocation location) { final String policyMapName = location.getPolicyMapName(); final String interfaceName = location.getInterfaceName(); final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); final InstanceIdentifier<ServicePolicy> servicePolicyIid = interfaceInstanceIdentifier(interfaceName); if (netconfDeleteIfPresent(mountpoint, servicePolicyIid)) { LOG.trace("Service-policy interface {}, removed from node {}", interfaceName, policyMapName, nodeId.getValue()); return true; } else { LOG.warn("Failed to remove service-policy interface {} from node {}", interfaceName, policyMapName, nodeId.getValue()); return false; } } 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 removeInterface(final PolicyManagerImpl.PolicyMapLocation location) { final String policyMapName = location.getPolicyMapName(); final String interfaceName = location.getInterfaceName(); final DataBroker mountpoint = location.getMountpoint(); final NodeId nodeId = location.getNodeId(); final InstanceIdentifier<ServicePolicy> servicePolicyIid = interfaceInstanceIdentifier(interfaceName); if (netconfDeleteIfPresent(mountpoint, servicePolicyIid)) { LOG.trace("Service-policy interface {}, removed from node {}", interfaceName, policyMapName, nodeId.getValue()); return true; } else { LOG.warn("Failed to remove service-policy interface {} from node {}", interfaceName, policyMapName, nodeId.getValue()); return false; } } 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);  }