1 package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
3 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
4 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
5 import org.opendaylight.groupbasedpolicy.util.IidFactory;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Name;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.EndpointGroup;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.EndpointGroup.IntraGroupPolicy;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.EndpointGroupBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.endpoint.group.ConsumerNamedSelector;
15 import com.google.common.base.Preconditions;
17 public class NetworkClient {
19 private static final Name NETWORK_CLIENT_EPG_NAME = new Name("NETWORK_CLIENT");
20 private static final Description NETWORK_CLIENT_EPG_DESC = new Description("Represents DHCP and DNS clients.");
24 public static final EndpointGroupId EPG_ID = new EndpointGroupId("ccc5e444-573c-11e5-885d-feff819cdc9f");
26 * Network-client endpoint-group consuming no contract
28 public static final EndpointGroup EPG;
31 EPG = createNetworkClientEpg();
34 private static EndpointGroup createNetworkClientEpg() {
35 return new EndpointGroupBuilder().setId(EPG_ID)
36 .setName(NETWORK_CLIENT_EPG_NAME)
37 .setIntraGroupPolicy(IntraGroupPolicy.RequireContract)
38 .setDescription(NETWORK_CLIENT_EPG_DESC)
43 * Puts {@link #EPG} to {@link LogicalDatastoreType#CONFIGURATION}
45 * @param tenantId location of {@link #EPG}
46 * @param wTx transaction where {@link #EPG} is written
48 public static void writeNetworkClientEntitiesToTenant(TenantId tenantId, WriteTransaction wTx) {
49 wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
53 * Puts consumer-named-selector to {@link #EPG} in {@link LogicalDatastoreType#CONFIGURATION}
55 * @param tenantId tenantId location of {@link #EPG}
56 * @param consumerNamedSelector is added to {@link #EPG}
57 * @param wTx transaction where the given consumer-named-selector is written
59 public static void writeConsumerNamedSelector(TenantId tenantId, ConsumerNamedSelector consumerNamedSelector,
60 WriteTransaction wTx) {
61 Preconditions.checkNotNull(consumerNamedSelector);
62 wTx.put(LogicalDatastoreType.CONFIGURATION,
63 IidFactory.consumerNamedSelectorIid(tenantId, EPG_ID, consumerNamedSelector.getName()),
64 consumerNamedSelector, true);