@Test public void testProcessSgtInfo() throws Exception { final SgtInfo sgtInfo1 = new SgtInfo(SGT_1, EPG_NAME_1, SGT_1_UUID); final SgtInfo sgtInfo2 = new SgtInfo(SGT_2, EPG_NAME_2, SGT_2_UUID); final CheckedFuture<Void, TransactionCommitFailedException> outcome = generator.processSgtInfo(TENANT_ID, Lists.newArrayList(sgtInfo1, sgtInfo2)); outcome.get(10, TimeUnit.SECONDS); final KeyedInstanceIdentifier<EndpointPolicyTemplateBySgt, EndpointPolicyTemplateBySgtKey> epTemplatePath1 = InstanceIdentifier.create(SxpEpMapper.class) .child(EndpointPolicyTemplateBySgt.class, new EndpointPolicyTemplateBySgtKey(SGT_1)); final EndpointPolicyTemplateBySgt epTemplate1 = new EndpointPolicyTemplateBySgtBuilder() .setSgt(SGT_1) .setEndpointGroups(Collections.singletonList(new EndpointGroupId(EPG_NAME_1))) .setTenant(TENANT_ID) .build(); final KeyedInstanceIdentifier<EndpointPolicyTemplateBySgt, EndpointPolicyTemplateBySgtKey> epTemplatePath2 = InstanceIdentifier.create(SxpEpMapper.class) .child(EndpointPolicyTemplateBySgt.class, new EndpointPolicyTemplateBySgtKey(SGT_2)); final EndpointPolicyTemplateBySgt epTemplate2 = new EndpointPolicyTemplateBySgtBuilder() .setSgt(SGT_2) .setEndpointGroups(Collections.singletonList(new EndpointGroupId(EPG_NAME_2))) .setTenant(TENANT_ID) .build(); final InOrder inOrder = Mockito.inOrder(wTx); inOrder.verify(wTx, Mockito.calls(1)).put(LogicalDatastoreType.CONFIGURATION, epTemplatePath1, epTemplate1, true); inOrder.verify(wTx, Mockito.calls(1)).put(LogicalDatastoreType.CONFIGURATION, epTemplatePath2, epTemplate2, false); inOrder.verify(wTx).submit(); Mockito.verifyZeroInteractions(wTx); }
@Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Sgt sgt = sgtInfo.getSgt(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgt.getValue(), sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtInfo.getName()); final InstanceIdentifier<EndpointPolicyTemplateBySgt> epPolicyTemplatePath = InstanceIdentifier .create(SxpEpMapper.class) .child(EndpointPolicyTemplateBySgt.class, new EndpointPolicyTemplateBySgtKey(sgt)); final EndpointPolicyTemplateBySgt epPolicyTemplate = new EndpointPolicyTemplateBySgtBuilder() .setSgt(sgt) .setEndpointGroups(Collections.singletonList(epgId)) .setTenant(tenantId) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epPolicyTemplatePath, epPolicyTemplate, createParent); createParent = false; } LOG.trace("harvested ep-policy-templates submitted: {} -> {}", tenantId, sgtInfos.size()); return wTx.submit(); }
SgtToEPTemplateGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Sgt sgt = sgtInfo.getSgt(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgt.getValue(), sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtInfo.getName()); final InstanceIdentifier<EndpointPolicyTemplateBySgt> epPolicyTemplatePath = InstanceIdentifier .create(SxpEpMapper.class) .child(EndpointPolicyTemplateBySgt.class, new EndpointPolicyTemplateBySgtKey(sgt)); final EndpointPolicyTemplateBySgt epPolicyTemplate = new EndpointPolicyTemplateBySgtBuilder() .setSgt(sgt) .setEndpointGroups(Collections.singletonList(epgId)) .setTenant(tenantId) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epPolicyTemplatePath, epPolicyTemplate, createParent); createParent = false; } LOG.trace("harvested ep-policy-templates submitted: {} -> {}", tenantId, sgtInfos.size()); return wTx.submit(); } }
SgtToEPTemplateGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Sgt sgt = sgtInfo.getSgt(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgt.getValue(), sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtInfo.getName()); final InstanceIdentifier<EndpointPolicyTemplateBySgt> epPolicyTemplatePath = InstanceIdentifier .create(SxpEpMapper.class) .child(EndpointPolicyTemplateBySgt.class, new EndpointPolicyTemplateBySgtKey(sgt)); final EndpointPolicyTemplateBySgt epPolicyTemplate = new EndpointPolicyTemplateBySgtBuilder() .setSgt(sgt) .setEndpointGroups(Collections.singletonList(epgId)) .setTenant(tenantId) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epPolicyTemplatePath, epPolicyTemplate, createParent); createParent = false; } LOG.trace("harvested ep-policy-templates submitted: {} -> {}", tenantId, sgtInfos.size()); return wTx.submit(); } SgtToEPTemplateGeneratorImpl(final DataBroker dataBroker); }
SgtToEPTemplateGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Sgt sgt = sgtInfo.getSgt(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgt.getValue(), sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtInfo.getName()); final InstanceIdentifier<EndpointPolicyTemplateBySgt> epPolicyTemplatePath = InstanceIdentifier .create(SxpEpMapper.class) .child(EndpointPolicyTemplateBySgt.class, new EndpointPolicyTemplateBySgtKey(sgt)); final EndpointPolicyTemplateBySgt epPolicyTemplate = new EndpointPolicyTemplateBySgtBuilder() .setSgt(sgt) .setEndpointGroups(Collections.singletonList(epgId)) .setTenant(tenantId) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epPolicyTemplatePath, epPolicyTemplate, createParent); createParent = false; } LOG.trace("harvested ep-policy-templates submitted: {} -> {}", tenantId, sgtInfos.size()); return wTx.submit(); } SgtToEPTemplateGeneratorImpl(final DataBroker dataBroker); @Override CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos); }
SgtToEPTemplateGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Sgt sgt = sgtInfo.getSgt(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgt.getValue(), sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtInfo.getName()); final InstanceIdentifier<EndpointPolicyTemplateBySgt> epPolicyTemplatePath = InstanceIdentifier .create(SxpEpMapper.class) .child(EndpointPolicyTemplateBySgt.class, new EndpointPolicyTemplateBySgtKey(sgt)); final EndpointPolicyTemplateBySgt epPolicyTemplate = new EndpointPolicyTemplateBySgtBuilder() .setSgt(sgt) .setEndpointGroups(Collections.singletonList(epgId)) .setTenant(tenantId) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epPolicyTemplatePath, epPolicyTemplate, createParent); createParent = false; } LOG.trace("harvested ep-policy-templates submitted: {} -> {}", tenantId, sgtInfos.size()); return wTx.submit(); } SgtToEPTemplateGeneratorImpl(final DataBroker dataBroker); @Override CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos);  }