apply checkstyle check during build for neutron-mapper
[groupbasedpolicy.git] / neutron-mapper / src / main / java / org / opendaylight / groupbasedpolicy / neutron / mapper / infrastructure / NetworkClient.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.groupbasedpolicy.neutron.mapper.infrastructure;
10
11 import com.google.common.base.Preconditions;
12
13 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.groupbasedpolicy.util.IidFactory;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Name;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelector;
22
23 public class NetworkClient extends ServiceUtil {
24
25     private static final Name NETWORK_CLIENT_EPG_NAME = new Name("NETWORK_CLIENT");
26     private static final Description NETWORK_CLIENT_EPG_DESC = new Description("Represents DHCP and DNS clients.");
27     /**
28      * ID of {@link #EPG}.
29      */
30     public static final EndpointGroupId EPG_ID = new EndpointGroupId("ccc5e444-573c-11e5-885d-feff819cdc9f");
31     /**
32      * Network-client endpoint-group consuming no contract.
33      */
34     public static final EndpointGroup EPG;
35
36     static {
37         EPG = createNetworkClientEpg();
38     }
39
40     private static EndpointGroup createNetworkClientEpg() {
41         return createEpgBuilder(EPG_ID, NETWORK_CLIENT_EPG_NAME, NETWORK_CLIENT_EPG_DESC).build();
42     }
43
44     /**
45      * Puts {@link #EPG} to {@link LogicalDatastoreType#CONFIGURATION}.
46      *
47      * @param tenantId location of {@link #EPG}
48      * @param writeTx transaction where {@link #EPG} is written
49      */
50     public static void writeNetworkClientEntitiesToTenant(TenantId tenantId, WriteTransaction writeTx) {
51         writeTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, EPG_ID), EPG, true);
52     }
53
54     /**
55      * Puts consumer-named-selector to {@link #EPG} in {@link LogicalDatastoreType#CONFIGURATION}.
56      *
57      * @param tenantId tenantId location of {@link #EPG}
58      * @param consumerNamedSelector is added to {@link #EPG}
59      * @param writeTx transaction where the given consumer-named-selector is written
60      */
61     public static void writeConsumerNamedSelector(TenantId tenantId, ConsumerNamedSelector consumerNamedSelector,
62             WriteTransaction writeTx) {
63         Preconditions.checkNotNull(consumerNamedSelector);
64         writeTx.put(LogicalDatastoreType.CONFIGURATION,
65                 IidFactory.consumerNamedSelectorIid(tenantId, EPG_ID, consumerNamedSelector.getName()),
66                 consumerNamedSelector, true);
67     }
68
69 }