@Test public void testWriteNetworkServiceEntitiesToTenant() throws Exception { DataBroker dataBroker = getDataBroker(); ReadWriteTransaction rwTx = dataBroker.newReadWriteTransaction(); NetworkService.writeNetworkServiceEntitiesToTenant(new TenantId(tenantId), rwTx); rwTx.submit().get(); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DHCP_IPV4_CLIENT_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DHCP_IPV4_SERVER_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DHCP_IPV6_CLIENT_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DHCP_IPV6_SERVER_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_UDP_IPV4_CLIENT_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_UDP_IPV4_SERVER_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_UDP_IPV6_CLIENT_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_UDP_IPV6_SERVER_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_TCP_IPV4_CLIENT_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_TCP_IPV4_SERVER_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_TCP_IPV6_CLIENT_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, DNS_TCP_IPV6_SERVER_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, SSH_IPV4_SERVER_TO_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, SSH_IPV6_SERVER_TO_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, SSH_IPV4_CLIENT_TO_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, SSH_IPV6_CLIENT_TO_SERVER_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, ICMP_IPV4_BETWEEN_SERVER_CLIENT_NAME); PolicyAssert.assertClassifierInstanceExists(dataBroker, tenantId, ICMP_IPV6_BETWEEN_SERVER_CLIENT_NAME); PolicyAssert.assertContractExists(dataBroker, tenantId, NetworkService.DHCP_CONTRACT_ID.getValue()); PolicyAssert.assertContractExists(dataBroker, tenantId, NetworkService.DNS_CONTRACT_ID.getValue()); PolicyAssert.assertContractExists(dataBroker, tenantId, NetworkService.MGMT_CONTRACT_ID.getValue()); PolicyAssert.assertEndpointGroupExists(dataBroker, tenantId, NetworkService.EPG_ID.getValue()); }
public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) { Set<ClassifierInstance> classifierInstances = getAllClassifierInstances(); for (ClassifierInstance ci : classifierInstances) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci, true); } for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true); } writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID), DHCP_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID), MGMT_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true); }
NetworkService extends ServiceUtil { public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) { Set<ClassifierInstance> classifierInstances = getAllClassifierInstances(); for (ClassifierInstance ci : classifierInstances) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci, true); } for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true); } writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID), DHCP_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID), MGMT_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true); } }
NetworkService extends ServiceUtil { public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) { Set<ClassifierInstance> classifierInstances = getAllClassifierInstances(); for (ClassifierInstance ci : classifierInstances) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci, true); } for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true); } writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID), DHCP_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID), MGMT_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true); }  }
NetworkService extends ServiceUtil { public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) { Set<ClassifierInstance> classifierInstances = getAllClassifierInstances(); for (ClassifierInstance ci : classifierInstances) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci, true); } for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true); } writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID), DHCP_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID), MGMT_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true); }  static void writeDhcpClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
            WriteTransaction writeTx); static void writeDnsClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
            WriteTransaction writeTx); static void writeMgmtClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
            WriteTransaction writeTx); static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx); static Set<ClassifierInstance> getAllClassifierInstances(); }
NetworkService extends ServiceUtil { public static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) { Set<ClassifierInstance> classifierInstances = getAllClassifierInstances(); for (ClassifierInstance ci : classifierInstances) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierInstanceIid(tenantId, ci.getName()), ci, true); } for (ActionInstance ai : Collections.singleton(MappingUtils.ACTION_ALLOW)) { writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.actionInstanceIid(tenantId, ai.getName()), ai, true); } writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DHCP_CONTRACT_ID), DHCP_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, DNS_CONTRACT_ID), DNS_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.contractIid(tenantId, MGMT_CONTRACT_ID), MGMT_CONTRACT, true); writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true); }  static void writeDhcpClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
            WriteTransaction writeTx); static void writeDnsClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
            WriteTransaction writeTx); static void writeMgmtClauseWithConsProvEic(TenantId tenantId, @Nullable IpPrefix ipPrefix,
            WriteTransaction writeTx); static void writeNetworkServiceEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx); static Set<ClassifierInstance> getAllClassifierInstances(); static final ContractId DHCP_CONTRACT_ID; static final Contract DHCP_CONTRACT; static final ConsumerNamedSelector DHCP_CONTRACT_CONSUMER_SELECTOR; static final ContractId DNS_CONTRACT_ID; static final Contract DNS_CONTRACT; static final ConsumerNamedSelector DNS_CONTRACT_CONSUMER_SELECTOR; static final ContractId MGMT_CONTRACT_ID; static final Contract MGMT_CONTRACT; static final ConsumerNamedSelector MGMT_CONTRACT_CONSUMER_SELECTOR; static final EndpointGroupId EPG_ID; static final EndpointGroup EPG; }