CORD-176 Added a store to hold service networks and ports
Change-Id: I67846144eefb620927c93b8642e8b43b6eff3b4b
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java b/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
new file mode 100644
index 0000000..d6d7a9b
--- /dev/null
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
@@ -0,0 +1,91 @@
+/*
+ * 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.opencord.cordvtn.api;
+
+import java.util.Set;
+
+/**
+ * Manages VTN service networks and ports.
+ */
+public interface CordVtnStore {
+
+ /**
+ * Creates service network.
+ *
+ * @param serviceNet the new service network
+ */
+ void createServiceNetwork(ServiceNetwork serviceNet);
+
+ /**
+ * Updates the service network.
+ *
+ * @param serviceNet the updated service network
+ */
+ void updateServiceNetwork(ServiceNetwork serviceNet);
+
+ /**
+ * Returns the service network with the given network id.
+ *
+ * @param netId network id
+ * @return service network
+ */
+ ServiceNetwork getServiceNetwork(NetworkId netId);
+
+ /**
+ * Returns all service networks.
+ *
+ * @return set of service networks
+ */
+ Set<ServiceNetwork> getServiceNetworks();
+
+ /**
+ * Removes the service network.
+ *
+ * @param netId network id
+ */
+ void removeServiceNetwork(NetworkId netId);
+
+ /**
+ * Creates service port.
+ *
+ * @param servicePort the new service port
+ */
+ void createServicePort(ServicePort servicePort);
+
+ /**
+ * Returns the service port with the given port id.
+ *
+ * @param portId port id
+ * @return service port
+ */
+ ServicePort getServicePort(PortId portId);
+
+ /**
+ * Returns all service ports.
+ *
+ * @return set of service ports
+ */
+ Set<ServicePort> getServicePorts();
+
+ /**
+ * Removes service port.
+ *
+ * @param portId port id
+ */
+ void removeServicePort(PortId portId);
+
+ // TODO add apis for the virtual network and port
+}
diff --git a/src/main/java/org/opencord/cordvtn/impl/DistributedCordVtnStore.java b/src/main/java/org/opencord/cordvtn/impl/DistributedCordVtnStore.java
new file mode 100644
index 0000000..11b1e83
--- /dev/null
+++ b/src/main/java/org/opencord/cordvtn/impl/DistributedCordVtnStore.java
@@ -0,0 +1,110 @@
+/*
+ * 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.opencord.cordvtn.impl;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Service;
+import org.opencord.cordvtn.api.CordVtnStore;
+import org.opencord.cordvtn.api.NetworkId;
+import org.opencord.cordvtn.api.PortId;
+import org.opencord.cordvtn.api.ServiceNetwork;
+import org.opencord.cordvtn.api.ServicePort;
+import org.slf4j.Logger;
+
+import java.util.Set;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Implementation of the cordvtn service.
+ */
+@Component(immediate = true)
+@Service
+public class DistributedCordVtnStore implements CordVtnStore {
+ protected final Logger log = getLogger(getClass());
+
+ private static final String MSG_SERVICE_NET = "Service network %s %s";
+ private static final String MSG_SERVICE_PORT = "Service port %s %s";
+ private static final String CREATED = "created";
+ private static final String UPDATED = "updated";
+ private static final String REMOVED = "removed";
+
+ @Activate
+ protected void activate() {
+ log.info("Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ log.info("Stopped");
+ }
+
+ @Override
+ public void createServiceNetwork(ServiceNetwork serviceNet) {
+ // TODO implement
+ log.info(String.format(MSG_SERVICE_NET, CREATED, serviceNet));
+ }
+
+ @Override
+ public void updateServiceNetwork(ServiceNetwork serviceNet) {
+ // TODO implement
+ log.info(String.format(MSG_SERVICE_NET, UPDATED, serviceNet));
+ }
+
+ @Override
+ public ServiceNetwork getServiceNetwork(NetworkId netId) {
+ // TODO implement
+ return null;
+ }
+
+ @Override
+ public Set<ServiceNetwork> getServiceNetworks() {
+ // TODO implement
+ return null;
+ }
+
+ @Override
+ public void removeServiceNetwork(NetworkId netId) {
+ // TODO implement
+ log.info(String.format(MSG_SERVICE_NET, REMOVED, netId));
+ }
+
+ @Override
+ public void createServicePort(ServicePort servicePort) {
+ // TODO implement
+ log.info(String.format(MSG_SERVICE_PORT, CREATED, servicePort));
+ }
+
+ @Override
+ public ServicePort getServicePort(PortId portId) {
+ // TODO implement
+ return null;
+ }
+
+ @Override
+ public Set<ServicePort> getServicePorts() {
+ // TODO implement
+ return null;
+ }
+
+ @Override
+ public void removeServicePort(PortId portId) {
+ // TODO implement
+ log.info(String.format(MSG_SERVICE_PORT, REMOVED, portId));
+ }
+}