2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
11 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.groupbasedpolicy.util.IidFactory;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Name;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup.IntraGroupPolicy;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelector;
23 import com.google.common.base.Preconditions;
25 public class NetworkClient {
27 private static final Name NETWORK_CLIENT_EPG_NAME = new Name("NETWORK_CLIENT");
28 private static final Description NETWORK_CLIENT_EPG_DESC = new Description("Represents DHCP and DNS clients.");
32 public static final EndpointGroupId EPG_ID = new EndpointGroupId("ccc5e444-573c-11e5-885d-feff819cdc9f");
34 * Network-client endpoint-group consuming no contract
36 public static final EndpointGroup EPG;
39 EPG = createNetworkClientEpg();
42 private static EndpointGroup createNetworkClientEpg() {
43 return new EndpointGroupBuilder().setId(EPG_ID)
44 .setName(NETWORK_CLIENT_EPG_NAME)
45 .setIntraGroupPolicy(IntraGroupPolicy.RequireContract)
46 .setDescription(NETWORK_CLIENT_EPG_DESC)
51 * Puts {@link #EPG} to {@link LogicalDatastoreType#CONFIGURATION}
53 * @param tenantId location of {@link #EPG}
54 * @param wTx transaction where {@link #EPG} is written
56 public static void writeNetworkClientEntitiesToTenant(TenantId tenantId, WriteTransaction wTx) {
57 wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
61 * Puts consumer-named-selector to {@link #EPG} in {@link LogicalDatastoreType#CONFIGURATION}
63 * @param tenantId tenantId location of {@link #EPG}
64 * @param consumerNamedSelector is added to {@link #EPG}
65 * @param wTx transaction where the given consumer-named-selector is written
67 public static void writeConsumerNamedSelector(TenantId tenantId, ConsumerNamedSelector consumerNamedSelector,
68 WriteTransaction wTx) {
69 Preconditions.checkNotNull(consumerNamedSelector);
70 wTx.put(LogicalDatastoreType.CONFIGURATION,
71 IidFactory.consumerNamedSelectorIid(tenantId, EPG_ID, consumerNamedSelector.getName()),
72 consumerNamedSelector, true);