2 * Copyright (c) 2015 Cisco Systems, Inc. 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
8 package org.opendaylight.lispflowmapping.implementation;
10 import javax.inject.Inject;
11 import javax.inject.Singleton;
12 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
13 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingServiceShell;
14 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder;
20 import org.opendaylight.yangtools.yang.common.Uint16;
21 import org.osgi.service.component.annotations.Activate;
22 import org.osgi.service.component.annotations.Component;
23 import org.osgi.service.component.annotations.Reference;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * Implement Karaf commands to interact with the Mapping Service.
30 * @author Lorand Jakab
34 @Component(service = IMappingServiceShell.class, immediate = true, property = "type=default")
35 public class MappingServiceShell implements IMappingServiceShell {
36 protected static final Logger LOG = LoggerFactory.getLogger(MappingServiceShell.class);
38 private final IMappingService mappingService;
42 public MappingServiceShell(final @Reference IMappingService mappingService) {
43 this.mappingService = mappingService;
47 public String printMappings() {
48 return mappingService.printMappings();
52 public String prettyPrintMappings() {
53 return mappingService.prettyPrintMappings();
57 public String printKeys() {
58 return mappingService.printKeys();
62 public String prettyPrintKeys() {
63 return mappingService.prettyPrintKeys();
67 public void addDefaultKeyIPv4() {
68 Eid eid = LispAddressUtil.toEid(new Ipv4Prefix("0.0.0.0/0"), null);
69 MappingAuthkey key = new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build();
70 mappingService.addAuthenticationKey(eid, key);
74 public void addDefaultKeyIPv6() {
75 Eid eid = LispAddressUtil.toEid(new Ipv6Prefix("::0/0"), null);
76 MappingAuthkey key = new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build();
77 mappingService.addAuthenticationKey(eid, key);