<name>ODL :: sfc :: ${project.artifactId}</name>
<dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>odl-sfc-shell</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-sfc-genius</artifactId>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+
+<!--
+ Copyright (c) Ericsson Inc. and others. All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>single-feature-parent</artifactId>
+ <version>2.0.2</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.opendaylight.sfc</groupId>
+ <artifactId>odl-sfc-shell</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+ <name>ODL :: sfc :: ${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>odl-mdsal-broker</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.sfc</groupId>
+ <artifactId>sfc-shell</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
<module>odl-sfc-test-consumer</module>
<module>odl-sfc-vnfm-tacker</module>
<module>odl-sfc-genius</module>
+ <module>odl-sfc-shell</module>
</modules>
<scm>
<module>sfc-karaf</module>
<module>sfc-renderers</module>
<module>sfc-genius</module>
+ <module>sfc-shell</module>
</modules>
<properties>
<artifactId>sfc-genius</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.sfc</groupId>
+ <artifactId>sfc-shell</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- YANG tools -->
<dependency>
return sf;
}
- protected static ServiceFunctions readAllServiceFunctions() {
+ public static ServiceFunctions readAllServiceFunctions() {
ServiceFunctions sfs;
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctions> sfsIID = InstanceIdentifier.builder(ServiceFunctions.class).build();
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.sfc</groupId>
+ <artifactId>sfc-parent</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </parent>
+
+
+ <artifactId>sfc-shell</artifactId>
+ <groupId>org.opendaylight.sfc</groupId>
+ <packaging>bundle</packaging>
+ <name>ODL :: sfc :: ${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.sfc</groupId>
+ <artifactId>sfc-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <!-- This bundle works with Karaf 3 and 4.0 -->
+ <Import-Package>
+ org.apache.karaf.shell.commands;version="[3.0.0,4.1)",
+ org.apache.karaf.shell.console;version="[3.0.0,4.1)",
+ *
+ </Import-Package>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Karaf-Commands>*</Karaf-Commands>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+/**
+ * Copyright (c) 2017 Ericsson S.A. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.sfc.shell;
+
+import java.io.PrintStream;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.console.Session;
+
+/**
+ * Abstract command with some common functionality to be inherited by the rest
+ * of the commands.
+ *
+ *
+ */
+public abstract class AbstractCommand implements Action {
+
+ // Default value for fields that are not present
+ protected static final String NO_VALUE = "------";
+
+ @Reference
+ protected Session session;
+
+ public Session getSession() {
+ return session;
+ }
+
+ public PrintStream getConsole() {
+ return getSession().getConsole();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2017 Ericsson S.A. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.sfc.shell;
+
+import java.util.List;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.Col;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Karaf command to show the Service Function provisioned.
+ *
+ *
+ */
+@Service
+@Command(scope = "sfc", name = "sf-list", description = "Show the provisioned Service Functions")
+public class ServiceFunctionsCommand extends AbstractCommand {
+
+ @Option(name = "-name", aliases = {
+ "--name" }, description = "Name of the Service Function", required = false, multiValued = false)
+ private String name;
+
+ private final ShellTable table;
+
+ private static final Logger LOG = LoggerFactory.getLogger(ServiceFunctionsCommand.class);
+
+ public ServiceFunctionsCommand() {
+ table = new ShellTable();
+ table.column(new Col("Name"));
+ table.column(new Col("Type"));
+ table.column(new Col("Mgmt. Addr."));
+ table.column(new Col("REST Uri"));
+ table.column(new Col("DPL Type"));
+ }
+
+ @Override
+ public Object execute() throws Exception {
+ LOG.debug("Service Function name: {}", name);
+
+ if (name != null) {
+ renderContent(SfcProviderServiceFunctionAPI.readServiceFunction(new SfName(name)));
+ } else {
+ LOG.debug("Getting the list of Service Functions");
+ ServiceFunctions sfs = SfcProviderServiceFunctionAPI.readAllServiceFunctions();
+ if (sfs != null) {
+ List<ServiceFunction> serviceFunctions = sfs.getServiceFunction();
+ serviceFunctions.forEach(this::renderContent);
+ }
+ }
+ table.print(getConsole());
+ return null;
+ }
+
+ private void renderContent(ServiceFunction serviceFunction) {
+ if (serviceFunction != null) {
+ LOG.debug("Service Function data: {}", serviceFunction);
+ table.addRow().addContent(serviceFunction.getName().getValue(),
+ serviceFunction.getType() == null ? NO_VALUE : serviceFunction.getType().getValue(),
+ serviceFunction.getIpMgmtAddress() == null ? NO_VALUE
+ : serviceFunction.getIpMgmtAddress().getIpv4Address().getValue(),
+ serviceFunction.getRestUri() == null ? NO_VALUE : serviceFunction.getRestUri().getValue(),
+ serviceFunction.getSfDataPlaneLocator() == null
+ || serviceFunction.getSfDataPlaneLocator().get(0) == null ? NO_VALUE
+ : serviceFunction.getSfDataPlaneLocator().get(0).getLocatorType());
+ }
+ }
+}