2 * Copyright (c) 2013 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
8 package org.opendaylight.controller.routing.dijkstra_implementation.internal;
10 import java.util.Dictionary;
11 import java.util.Hashtable;
13 import org.apache.felix.service.command.Descriptor;
14 import org.opendaylight.controller.sal.core.Node;
15 import org.opendaylight.controller.sal.core.Path;
16 import org.opendaylight.controller.sal.routing.IRouting;
17 import org.opendaylight.controller.sal.utils.ServiceHelper;
18 import org.osgi.framework.ServiceRegistration;
20 public class DijkstraImplementationCLI {
21 @SuppressWarnings("rawtypes")
22 private ServiceRegistration sr = null;
27 public void destroy() {
31 final Dictionary<String, Object> props = new Hashtable<String, Object>();
32 props.put("osgi.command.scope", "odpcontroller");
33 props.put("osgi.command.function", new String[] { "getRoute" });
34 this.sr = ServiceHelper.registerGlobalServiceWReg(DijkstraImplementationCLI.class, this, props);
38 if (this.sr != null) {
44 @Descriptor("Retrieves a Route between two Nodes in the discovered Topology DB")
46 @Descriptor("Container on the context of which the routing service need to be looked up") String container,
47 @Descriptor("String representation of the Source Node, this need to be consumable from Node.fromString()") String srcNode,
48 @Descriptor("String representation of the Destination Node") String dstNode) {
49 final IRouting r = (IRouting) ServiceHelper.getInstance(IRouting.class, container, this);
52 System.out.println("Cannot find the routing instance on container:" + container);
56 final Node src = Node.fromString(srcNode);
57 final Node dst = Node.fromString(dstNode);
58 final Path p = r.getRoute(src, dst);
60 System.out.println("Route between srcNode:" + src + " and dstNode:" + dst + " = " + p);
62 System.out.println("There is no route between srcNode:" + src + " and dstNode:" + dst);