View Javadoc

1   /*
2    * Copyright (c) 2014, 2015 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.lispflowmapping.neutron;
10  
11  import java.util.List;
12  
13  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
14  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
15  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord.Action;
16  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
17  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput;
18  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder;
19  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput;
20  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInputBuilder;
21  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInput;
22  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInputBuilder;
23  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyInput;
24  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyInputBuilder;
25  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingInput;
26  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingInputBuilder;
27  import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkeyBuilder;
28  
29  /**
30   * LispUtil class has util functions for building inputs for LISP service RPCs.
31   *
32   *
33   *
34   */
35  
36  
37  public final class LispUtil {
38      // Utility class, should not be instantiated
39      private LispUtil() {
40      }
41  
42    //  private static final Logger LOG = LoggerFactory.getLogger(LispUtil.class);
43  
44      public static AddMappingInput buildAddMappingInput(Eid eid, List<LocatorRecord> locators) {
45          MappingRecordBuilder mrb = new MappingRecordBuilder();
46  
47          mrb.setAction(Action.NoAction).setAuthoritative(true).setEid(eid)
48                  .setLocatorRecord(locators).setMapVersion((short) 0)
49                  .setRecordTtl(1440);
50  
51          AddMappingInputBuilder mib = new AddMappingInputBuilder();
52          mib.setMappingRecord(mrb.build());
53  
54          return mib.build();
55      }
56  
57      public static AddKeyInput buildAddKeyInput(Eid eid, String net) {
58          AddKeyInputBuilder kib = new AddKeyInputBuilder();
59  
60          kib.setEid(eid).setMappingAuthkey(new MappingAuthkeyBuilder().setKeyString(net).setKeyType(1).build());
61          return kib.build();
62      }
63  
64      public static GetMappingInput buildGetMappingInput(Eid eid) {
65          return new GetMappingInputBuilder().setEid(eid).build();
66      }
67  
68      public static RemoveMappingInput buildRemoveMappingInput(Eid eid) {
69          RemoveMappingInputBuilder rmib = new RemoveMappingInputBuilder();
70          rmib.setEid(eid);
71          return rmib.build();
72      }
73      public static RemoveKeyInput buildRemoveKeyInput(Eid eid) {
74          RemoveKeyInputBuilder kib = new RemoveKeyInputBuilder();
75  
76          kib.setEid(eid);
77          return kib.build();
78      }
79  }