Add CRD for l2-sdx entity

Changes:
- Add CRD commands for l2-sdx
- Add name completer for l2-sdx
- Define CRD in Sdxl2Service
- First implementation of Sdxl2Service
- Define CRD in storage service
- First implementation of storage service
- Add CRD tests for l2-sdx

Change-Id: Ie4797282186b504e95293a252785e28ccecf2ff3
diff --git a/sdx-l2/pom.xml b/sdx-l2/pom.xml
index 3929c23..d55b2e7 100644
--- a/sdx-l2/pom.xml
+++ b/sdx-l2/pom.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~ Copyright 2016 Open Networking Laboratory
+  ~ Copyright 2016-present Open Networking Laboratory
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
@@ -13,7 +13,8 @@
   ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
-  --><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">
+  -->
+<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>
     <artifactId>onos-app-samples</artifactId>
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java
index 6370ddc..fafb9d3 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java
index adbc246..698bc31 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2DistributedStore.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2DistributedStore.java
new file mode 100644
index 0000000..6b33025
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2DistributedStore.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2;
+
+import com.google.common.collect.ImmutableSet;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.store.primitives.DefaultDistributedSet;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.DistributedPrimitive;
+import org.onosproject.store.service.DistributedSet;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+
+/**
+ * SDXL2 Store implementation backed by different distributed primitives.
+ */
+@Component(immediate = true)
+@Service
+public class SdxL2DistributedStore implements SdxL2Store {
+
+    private static Logger log = LoggerFactory.getLogger(SdxL2DistributedStore.class);
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private StorageService storageService;
+
+    private DistributedSet<String> sdxL2s;
+
+    private static String errorAddSdx = "It is not possible to add ";
+    private static String errorRemoveSdx = "It is not possible to remove ";
+
+    @Activate
+    public void activate() {
+
+        KryoNamespace custom = KryoNamespace.newBuilder()
+                .register(KryoNamespaces.API)
+                .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
+                .register(new SdxL2ConnectionPointSerializer(), new Class[]{SdxL2ConnectionPoint.class})
+                .build();
+
+        sdxL2s = new DefaultDistributedSet<>(this.storageService
+                .<String>setBuilder()
+                .withSerializer(Serializer.using(custom))
+                .withName("sdxl2s")
+                .build(), DistributedPrimitive.DEFAULT_OPERTATION_TIMEOUT_MILLIS);
+
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        log.info("Stopped");
+    }
+
+    /**
+     * Create a named sdx-l2.
+     *
+     * @param sdxl2 sdx-l2 name
+     * @throws SdxL2Exception if sdxl2 exists
+     */
+    @Override
+    public void putSdxL2(String sdxl2) throws SdxL2Exception {
+        boolean inserted = sdxL2s.add(sdxl2);
+        if (!inserted) {
+            throw new SdxL2Exception(errorAddSdx + sdxl2);
+        }
+    }
+
+    /**
+     * Remove a named sdx-l2.
+     *
+     * @param sdxl2 sdx-l2 name
+     * @throws SdxL2Exception if sdxl2 does not exist
+     */
+    @Override
+    public void removeSdxL2(String sdxl2) throws SdxL2Exception {
+        boolean removed = sdxL2s.remove(sdxl2);
+        if (!removed) {
+            throw new SdxL2Exception(errorRemoveSdx + sdxl2);
+        }
+    }
+
+    /**
+     * Returns a set of sdxl2 names.
+     *
+     * @return a set of sdxl2 names
+     */
+    @Override
+    public Set<String> getSdxL2s() {
+        return ImmutableSet.copyOf(sdxL2s);
+    }
+
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Exception.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Exception.java
new file mode 100644
index 0000000..c69e670
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Exception.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2;
+
+/**
+ * SdxL2 exception for errors.
+ */
+public class SdxL2Exception extends Exception {
+
+    public SdxL2Exception(String message) {
+        super(message);
+    }
+
+}
+
+
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Manager.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Manager.java
new file mode 100644
index 0000000..d9c77e3
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Manager.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2;
+
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+/**
+ * Implementation of the Interface SdxL2Service.
+ */
+@Component(immediate = true)
+@Service
+public class SdxL2Manager implements SdxL2Service {
+
+    private static final String SDXL2_APP = "org.onosproject.sdxl2";
+    private static Logger log = LoggerFactory.getLogger(SdxL2Manager.class);
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected SdxL2Store sdxL2Store;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+    protected ApplicationId appId;
+
+    @Activate
+    protected void activate(ComponentContext context) {
+        appId = coreService.registerApplication(SDXL2_APP);
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        log.info("Stopped");
+    }
+
+    /**
+     * Create a named sdxl2.
+     *
+     * @param sdxl2 sdxl2 name
+     */
+    @Override
+    public void createSdxL2(String sdxl2) {
+        checkNotNull(sdxl2, "sdxl2 name cannot be null");
+        checkState(!sdxl2.contains(","), "sdxl2 names cannot contain commas");
+        checkState(!sdxl2.contains("|"), "sdxl2 names cannot contain pipe");
+        checkState(!sdxl2.contains("-"), "sdxl2 names cannot contain dash");
+        checkState(!sdxl2.contains(":"), "sdxl2 names cannot contain colon");
+
+        try {
+            this.sdxL2Store.putSdxL2(sdxl2);
+        } catch (SdxL2Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * Delete a named sdxl2.
+     *
+     * @param sdxl2 sdxl2 name
+     */
+    @Override
+    public void deleteSdxL2(String sdxl2) {
+        checkNotNull(sdxl2, "sdxl2 name cannot be null");
+
+        try {
+            this.sdxL2Store.removeSdxL2(sdxl2);
+        } catch (SdxL2Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * Returns a set of sdxl2 names.
+     *
+     * @return a set of sdxl2 names
+     */
+    @Override
+    public Set<String> getSdxL2s() {
+        return this.sdxL2Store.getSdxL2s();
+    }
+
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Service.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Service.java
new file mode 100644
index 0000000..e61d121
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Service.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2;
+
+import java.util.Set;
+
+/**
+ * Service that allows to create virtual named SDXL2s
+ * In which it is possible to provide connectivity
+ * (layer 2 Virtual Circuits - VC) between edge ports.
+ */
+public interface SdxL2Service {
+
+    /**
+     * Create a named SDXL2.
+     *
+     * @param sdxl2 SDXL2 name
+     */
+    void createSdxL2(String sdxl2);
+
+    /**
+     * Delete a named SDXL2.
+     *
+     * @param sdxl2 SDXL2 name
+     */
+    void deleteSdxL2(String sdxl2);
+
+    /**
+     * Returns a set of SDXL2 names.
+     *
+     * @return a set of SDXL2 names
+     */
+    Set<String> getSdxL2s();
+
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Store.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Store.java
new file mode 100644
index 0000000..6380a65
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Store.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2;
+
+import java.util.Set;
+
+/**
+ * Storage service of sdxl2 application.
+ */
+public interface SdxL2Store {
+
+    /**
+     * Create a named sdx-l2.
+     *
+     * @param sdxl2 sdx-l2 name
+     * @throws SdxL2Exception if sdxl2 exists
+     */
+    void putSdxL2(String sdxl2) throws SdxL2Exception;
+
+    /**
+     * Remove a named sdx-l2.
+     *
+     * @param sdxl2 sdx-l2 name
+     * @throws SdxL2Exception if sdxl2 does not exist
+     */
+    void removeSdxL2(String sdxl2) throws SdxL2Exception;
+
+    /**
+     * Returns a set of sdxl2 names.
+     *
+     * @return a set of sdxl2 names
+     */
+    Set<String> getSdxL2s();
+
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCommand.java
new file mode 100644
index 0000000..141f2f3
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCommand.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.sdxl2.SdxL2Service;
+
+/**
+ * CLI to create sdxl2.
+ */
+@Command(scope = "sdxl2", name = "sdxl2-add", description = "Create a sdxl2")
+public class SdxL2AddCommand extends AbstractShellCommand {
+
+    @Argument(index = 0, name = "sdxl2name", description = "Sdxl2 name", required = true, multiValued = false)
+    String sdxl2 = null;
+
+    @Override
+    protected void execute() {
+        SdxL2Service sdxl2Service = get(SdxL2Service.class);
+        sdxl2Service.createSdxL2(sdxl2);
+    }
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2ListCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2ListCommand.java
new file mode 100644
index 0000000..e027d11
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2ListCommand.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.sdxl2.SdxL2Service;
+
+import java.util.Set;
+
+/**
+ * CLI to list sdxl2.
+ */
+@Command(scope = "sdxl2", name = "sdxl2-list", description = "Lists the sdxl2s")
+public class SdxL2ListCommand extends AbstractShellCommand {
+
+    private static final String HEADER           = "\n\u001B[1;37mSDXL2\u001B[0m";
+    private static final String SEPARATOR        = "\u001B[1;37m--------------\u001B[0m";
+    private static final String FORMAT_SDXL2     = "\u001B[1;37m%s\u001B[0m";
+
+    @Override
+    protected void execute() {
+        SdxL2Service sdxl2Service = get(SdxL2Service.class);
+        Set<String> sdxl2s = sdxl2Service.getSdxL2s();
+        if (sdxl2s.size() > 0) {
+            print(HEADER);
+            print(SEPARATOR);
+            for (String sdxl2 : sdxl2s) {
+                print(FORMAT_SDXL2, sdxl2);
+            }
+            print("");
+        }
+    }
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCommand.java
new file mode 100644
index 0000000..4a01a61
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCommand.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.sdxl2.SdxL2Service;
+
+/**
+ * CLI to delete a named sdxl2.
+ */
+@Command(scope = "sdxl2", name = "sdxl2-remove", description = "Delete a sdxl2")
+public class SdxL2RemoveCommand extends AbstractShellCommand {
+
+    @Argument(index = 0, name = "sdxl2name", description = "Sdxl2 name",
+            required = true, multiValued = false)
+    String sdxl2 = null;
+
+    @Override
+    protected void execute() {
+        SdxL2Service networkService = get(SdxL2Service.class);
+        networkService.deleteSdxL2(sdxl2);
+    }
+}
+
+
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2NameCompleter.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2NameCompleter.java
new file mode 100644
index 0000000..bd64da1
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2NameCompleter.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2.cli.completer;
+
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.sdxl2.SdxL2Service;
+
+import java.util.List;
+
+/**
+ * Completes SDXL2 names.
+ */
+public class SdxL2NameCompleter implements Completer {
+
+    @Override
+    public int complete(String buffer, int cursor, List<String> candidates) {
+        StringsCompleter delegate = new StringsCompleter();
+        SdxL2Service service = AbstractShellCommand.get(SdxL2Service.class);
+        delegate.getStrings().addAll(service.getSdxL2s());
+        return delegate.complete(buffer, cursor, candidates);
+    }
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/package-info.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/package-info.java
new file mode 100644
index 0000000..7920073
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides the implementation of L2-SDX CLI completers.
+ */
+package org.onosproject.sdxl2.cli.completer;
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/package-info.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/package-info.java
new file mode 100644
index 0000000..ba9de9e
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides the implementation of L2-SDX CLI commands.
+ */
+package org.onosproject.sdxl2.cli;
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/package-info.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/package-info.java
index 0e134d7..8d622ca 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/package-info.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/sdx-l2/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/sdx-l2/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..e81d722
--- /dev/null
+++ b/sdx-l2/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,35 @@
+<!--
+  ~ Copyright 2016-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+        <command>
+            <action class="org.onosproject.sdxl2.cli.SdxL2AddCommand"/>
+        </command>
+        <command>
+            <action class="org.onosproject.sdxl2.cli.SdxL2RemoveCommand"/>
+            <completers>
+                <ref component-id="sdxl2Completer"/>
+            </completers>
+        </command>
+        <command>
+            <action class="org.onosproject.sdxl2.cli.SdxL2ListCommand"/>
+        </command>
+    </command-bundle>
+
+    <bean id="sdxl2Completer" class="org.onosproject.sdxl2.cli.completer.SdxL2NameCompleter"/>
+
+</blueprint>
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
index bea7ccc..9a3419a 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
new file mode 100644
index 0000000..fbe1ce4
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.TestApplicationId;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+
+/**
+ * Test network manager.
+ */
+public class SdxL2ManagerTest {
+
+    protected SdxL2Manager manager;
+
+    @Before
+    public void setUp() {
+        manager = new SdxL2Manager();
+        manager.appId = new TestApplicationId("sdxl2-test");
+        manager.sdxL2Store = new SdxL2TestStore();
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    public static final String SDXL2 = "test";
+    public static final String SDXL2_2 = "test2";
+
+
+    @Test
+    public void testCreateSdxL2s() {
+
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+        manager.createSdxL2(SDXL2);
+    }
+
+    @Test
+    public void testRemoveSdxL2s() {
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+        manager.deleteSdxL2(SDXL2);
+        manager.deleteSdxL2(SDXL2_2);
+        manager.deleteSdxL2(SDXL2);
+    }
+
+    @Test
+    public void testGetSdxL2s() {
+        Set<String> old = new HashSet<String>();
+        old.add(SDXL2_2);
+        old.add(SDXL2);
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+        Set<String> sdxl2 = manager.getSdxL2s();
+        assertEquals(sdxl2, old);
+        manager.deleteSdxL2(SDXL2);
+        sdxl2 = manager.getSdxL2s();
+        assertNotEquals(sdxl2, old);
+    }
+
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java
new file mode 100644
index 0000000..6cf3ef2
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.sdxl2;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+import java.util.Set;
+
+/**
+ * Stub class that emulates the behaviours of the SdxL2Store.
+ */
+public final class SdxL2TestStore implements SdxL2Store {
+
+    private Set<String> sdxL2s = Sets.newHashSet();
+
+    private static String errorAddSdx = "It is not possible to add ";
+    private static String errorRemoveSdx = "It is not possible to remove ";
+
+    /**
+     * Create a named sdx-l2.
+     *
+     * @param sdxl2 sdx-l2 name
+     * @throws SdxL2Exception if sdxl2 exists
+     */
+    @Override
+    public void putSdxL2(String sdxl2) throws SdxL2Exception {
+        boolean inserted = sdxL2s.add(sdxl2);
+        if (!inserted) {
+            throw new SdxL2Exception(errorAddSdx + sdxl2);
+        }
+    }
+
+    /**
+     * Remove a named sdx-l2.
+     *
+     * @param sdxl2 sdx-l2 name
+     * @throws SdxL2Exception if sdxl2 does not exist
+     */
+    @Override
+    public void removeSdxL2(String sdxl2) throws SdxL2Exception {
+        boolean removed = sdxL2s.remove(sdxl2);
+        if (!removed) {
+            throw new SdxL2Exception(errorRemoveSdx + sdxl2);
+        }
+    }
+
+    /**
+     * Returns a set of sdxl2 names.
+     *
+     * @return a set of sdxl2 names
+     */
+    @Override
+    public Set<String> getSdxL2s() {
+        return ImmutableSet.copyOf(sdxL2s);
+    }
+
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
index 4a06994..de39d20 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.