Initial implementation of kubevirt network with CRUD ops support

Change-Id: I6a366fcd301e67f62a74fb828eea1ac67f2a2128
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtNetwork.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtNetwork.java
new file mode 100644
index 0000000..dc221ab
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtNetwork.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
+import org.onlab.packet.IpAddress;
+
+import java.util.Objects;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetwork.Type.FLAT;
+
+/**
+ * Default implementation class of kubevirt network.
+ */
+public final class DefaultKubevirtNetwork implements KubevirtNetwork {
+
+    private static final String NOT_NULL_MSG = "Network % cannot be null";
+
+    private final String networkId;
+    private final Type type;
+    private final String name;
+    private final Integer mtu;
+    private final String segmentId;
+    private final IpAddress gatewayIp;
+    private final String cidr;
+    private final Set<KubevirtHostRoute> hostRouts;
+    private final KubevirtIpPool ipPool;
+
+    /**
+     * Default constructor.
+     *
+     * @param networkId         network identifier
+     * @param type              type of network
+     * @param name              network name
+     * @param mtu               network MTU
+     * @param segmentId         segment identifier
+     * @param gatewayIp         gateway IP address
+     * @param cidr              CIDR of network
+     * @param hostRouts         a set of host routes
+     * @param ipPool            IP pool
+     */
+    public DefaultKubevirtNetwork(String networkId, Type type, String name,
+                                  Integer mtu, String segmentId, IpAddress gatewayIp,
+                                  String cidr, Set<KubevirtHostRoute> hostRouts,
+                                  KubevirtIpPool ipPool) {
+        this.networkId = networkId;
+        this.type = type;
+        this.name = name;
+        this.mtu = mtu;
+        this.segmentId = segmentId;
+        this.gatewayIp = gatewayIp;
+        this.cidr = cidr;
+        this.hostRouts = hostRouts;
+        this.ipPool = ipPool;
+    }
+
+    @Override
+    public String networkId() {
+        return networkId;
+    }
+
+    @Override
+    public Type type() {
+        return type;
+    }
+
+    @Override
+    public String name() {
+        return name;
+    }
+
+    @Override
+    public Integer mtu() {
+        return mtu;
+    }
+
+    @Override
+    public String segmentId() {
+        return segmentId;
+    }
+
+    @Override
+    public IpAddress gatewayIp() {
+        return gatewayIp;
+    }
+
+    @Override
+    public String cidr() {
+        return cidr;
+    }
+
+    @Override
+    public Set<KubevirtHostRoute> hostRouts() {
+        return ImmutableSet.copyOf(hostRouts);
+    }
+
+    @Override
+    public KubevirtIpPool ipPool() {
+        return ipPool;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        DefaultKubevirtNetwork that = (DefaultKubevirtNetwork) o;
+        return networkId.equals(that.networkId) && type == that.type &&
+                name.equals(that.name) && mtu.equals(that.mtu) &&
+                gatewayIp.equals(that.gatewayIp) &&
+                cidr.equals(that.cidr) && hostRouts.equals(that.hostRouts) &&
+                ipPool.equals(that.ipPool);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(networkId, type, name, mtu, segmentId, gatewayIp,
+                cidr, hostRouts, ipPool);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("networkId", networkId)
+                .add("type", type)
+                .add("name", name)
+                .add("mtu", mtu)
+                .add("segmentId", segmentId)
+                .add("gatewayIp", gatewayIp)
+                .add("cidr", cidr)
+                .add("hostRouts", hostRouts)
+                .add("ipPool", ipPool)
+                .toString();
+    }
+
+    /**
+     * Returns new builder instance.
+     *
+     * @return kubevirt port builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static final class Builder implements KubevirtNetwork.Builder {
+
+        private String networkId;
+        private Type type;
+        private String name;
+        private Integer mtu;
+        private String segmentId;
+        private IpAddress gatewayIp;
+        private String cidr;
+        private Set<KubevirtHostRoute> hostRouts;
+        private KubevirtIpPool ipPool;
+
+        @Override
+        public KubevirtNetwork build() {
+            checkArgument(networkId != null, NOT_NULL_MSG, "networkId");
+            checkArgument(type != null, NOT_NULL_MSG, "type");
+            checkArgument(name != null, NOT_NULL_MSG, "name");
+            checkArgument(mtu != null, NOT_NULL_MSG, "mtu");
+            checkArgument(gatewayIp != null, NOT_NULL_MSG, "gatewayIp");
+            checkArgument(cidr != null, NOT_NULL_MSG, "cidr");
+            checkArgument(ipPool != null, NOT_NULL_MSG, "ipPool");
+
+            if (type != FLAT) {
+                checkArgument(segmentId != null, NOT_NULL_MSG, "segmentId");
+            }
+
+            return new DefaultKubevirtNetwork(networkId, type, name, mtu, segmentId,
+                    gatewayIp, cidr, hostRouts, ipPool);
+        }
+
+        @Override
+        public Builder networkId(String networkId) {
+            this.networkId = networkId;
+            return this;
+        }
+
+        @Override
+        public Builder name(String name) {
+            this.name = name;
+            return this;
+        }
+
+        @Override
+        public Builder type(Type type) {
+            this.type = type;
+            return this;
+        }
+
+        @Override
+        public Builder mtu(Integer mtu) {
+            this.mtu = mtu;
+            return this;
+        }
+
+        @Override
+        public Builder segmentId(String segmentId) {
+            this.segmentId = segmentId;
+            return this;
+        }
+
+        @Override
+        public Builder gatewayIp(IpAddress ipAddress) {
+            this.gatewayIp = ipAddress;
+            return this;
+        }
+
+        @Override
+        public Builder cidr(String cidr) {
+            this.cidr = cidr;
+            return this;
+        }
+
+        @Override
+        public Builder ipPool(KubevirtIpPool ipPool) {
+            this.ipPool = ipPool;
+            return this;
+        }
+
+        @Override
+        public Builder hostRoutes(Set<KubevirtHostRoute> hostRoutes) {
+            this.hostRouts = hostRoutes;
+            return this;
+        }
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtHostRoute.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtHostRoute.java
new file mode 100644
index 0000000..37cfc6b
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtHostRoute.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+import java.util.Objects;
+
+/**
+ * HostRoute class.
+ */
+public class KubevirtHostRoute {
+    private final IpPrefix destination;
+    private final IpAddress nexthop;
+
+    /**
+     * Default constructor.
+     *
+     * @param destination   destination CIDR
+     * @param nexthop       nexthop IP address
+     */
+    public KubevirtHostRoute(IpPrefix destination, IpAddress nexthop) {
+        this.destination = destination;
+        this.nexthop = nexthop;
+    }
+
+    /**
+     * Returns the destination CIDR.
+     *
+     * @return destination CIDR
+     */
+    public IpPrefix getDestination() {
+        return destination;
+    }
+
+    /**
+     * Returns the nexthop IP address.
+     *
+     * @return nexthop IP address
+     */
+    public IpAddress getNexthop() {
+        return nexthop;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        KubevirtHostRoute kubevirtHostRoute = (KubevirtHostRoute) o;
+        return destination.equals(kubevirtHostRoute.destination) &&
+                nexthop.equals(kubevirtHostRoute.nexthop);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(destination, nexthop);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("destination", destination)
+                .add("nexthop", nexthop)
+                .toString();
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtIpPool.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtIpPool.java
new file mode 100644
index 0000000..9b42b61
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtIpPool.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+
+import java.util.Objects;
+
+/**
+ * Kubevirt IP Pool.
+ */
+public class KubevirtIpPool {
+
+    private final IpAddress start;
+    private final IpAddress end;
+
+    /**
+     * Default constructor.
+     *
+     * @param start     start address of IP pool
+     * @param end       end address of IP pool
+     */
+    public KubevirtIpPool(IpAddress start, IpAddress end) {
+        this.start = start;
+        this.end = end;
+    }
+
+    /**
+     * Returns the start address of IP pool.
+     *
+     * @return start address of IP pool
+     */
+    public IpAddress getStart() {
+        return start;
+    }
+
+    /**
+     * Returns the end address of IP pool.
+     *
+     * @return end address of IP pool
+     */
+    public IpAddress getEnd() {
+        return end;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        KubevirtIpPool that = (KubevirtIpPool) o;
+        return start.equals(that.start) && end.equals(that.end);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(start, end);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("start", start)
+                .add("end", end)
+                .toString();
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetwork.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetwork.java
new file mode 100644
index 0000000..5492c9f
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetwork.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import org.onlab.packet.IpAddress;
+
+import java.util.Set;
+
+/**
+ * Representation of kubevirt network.
+ */
+public interface KubevirtNetwork {
+
+    /**
+     * Lists of network type.
+     */
+    enum Type {
+
+        /**
+         * VXLAN typed virtual network.
+         */
+        VXLAN,
+
+        /**
+         * GRE typed virtual network.
+         */
+        GRE,
+
+        /**
+         * GENEVE typed virtual network.
+         */
+        GENEVE,
+
+        /**
+         * FLAT typed provider network.
+         */
+        FLAT,
+    }
+
+    /**
+     * Returns the kubernetes network ID.
+     *
+     * @return kubernetes network ID
+     */
+    String networkId();
+
+    /**
+     * Returns kubernetes network type.
+     *
+     * @return kubernetes network type
+     */
+    Type type();
+
+    /**
+     * Returns kubernetes network name.
+     *
+     * @return kubernetes network name
+     */
+    String name();
+
+    /**
+     * Returns maximum transmission unit (MTU) value to address fragmentation.
+     *
+     * @return maximum transmission unit (MTU) value to address fragmentation
+     */
+    Integer mtu();
+
+    /**
+     * Returns segmentation ID.
+     *
+     * @return segmentation ID
+     */
+    String segmentId();
+
+    /**
+     * Returns gateway IP address.
+     *
+     * @return gateway IP address
+     */
+    IpAddress gatewayIp();
+
+    /**
+     * Returns network CIDR.
+     *
+     * @return network CIDR
+     */
+    String cidr();
+
+    /**
+     * Returns host routes.
+     *
+     * @return host routes
+     */
+    Set<KubevirtHostRoute> hostRouts();
+
+    /**
+     * Returns the IP pool.
+     *
+     * @return IP pool
+     */
+    KubevirtIpPool ipPool();
+
+    /**
+     * Builder of new network.
+     */
+    interface Builder {
+
+        /**
+         * Builds an immutable network instance.
+         *
+         * @return kubernetes network
+         */
+        KubevirtNetwork build();
+
+        /**
+         * Returns network builder with supplied network ID.
+         *
+         * @param networkId network ID
+         * @return network builder
+         */
+        Builder networkId(String networkId);
+
+        /**
+         * Returns network builder with supplied network name.
+         *
+         * @param name network name
+         * @return network builder
+         */
+        Builder name(String name);
+
+        /**
+         * Returns network builder with supplied network type.
+         *
+         * @param type network type
+         * @return network builder
+         */
+        Builder type(Type type);
+
+        /**
+         * Returns network builder with supplied MTU.
+         *
+         * @param mtu maximum transmission unit
+         * @return network builder
+         */
+        Builder mtu(Integer mtu);
+
+        /**
+         * Returns network builder with supplied segment ID.
+         *
+         * @param segmentId segment ID
+         * @return network builder
+         */
+        Builder segmentId(String segmentId);
+
+        /**
+         * Returns network builder with supplied gateway IP address.
+         *
+         * @param ipAddress gateway IP address
+         * @return network builder
+         */
+        Builder gatewayIp(IpAddress ipAddress);
+
+        /**
+         * Returns network builder with supplied network CIDR.
+         *
+         * @param cidr Classless Inter-Domain Routing
+         * @return network builder
+         */
+        Builder cidr(String cidr);
+
+        /**
+         * Returns the IP pool.
+         *
+         * @param ipPool IP pool
+         * @return network builder
+         */
+        Builder ipPool(KubevirtIpPool ipPool);
+
+        /**
+         * Returns host routes.
+         *
+         * @param hostRoutes host routes
+         * @return network builder
+         */
+        Builder hostRoutes(Set<KubevirtHostRoute> hostRoutes);
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkAdminService.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkAdminService.java
new file mode 100644
index 0000000..f0fa716
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkAdminService.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+public interface KubevirtNetworkAdminService extends KubevirtNetworkService {
+
+    /**
+     * Creates a kubevirt network with the given information.
+     *
+     * @param network the new network
+     */
+    void createNetwork(KubevirtNetwork network);
+
+    /**
+     * Updates the kubevirt network with the given information.
+     *
+     * @param network the updated network
+     */
+    void updateNetwork(KubevirtNetwork network);
+
+    /**
+     * Removes the network.
+     *
+     * @param networkId network identifier
+     */
+    void removeNetwork(String networkId);
+
+    void clear();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkEvent.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkEvent.java
new file mode 100644
index 0000000..ee3487f
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkEvent.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Describes kubevirt network service event.
+ */
+public class KubevirtNetworkEvent extends AbstractEvent<KubevirtNetworkEvent.Type, KubevirtNetwork> {
+
+    public KubevirtNetworkEvent(Type type, KubevirtNetwork subject) {
+        super(type, subject);
+    }
+
+    /**
+     * kubevirt network events.
+     */
+    public enum Type {
+
+        /**
+         * Signifies that a new kubevirt network is created.
+         */
+        KUBEVIRT_NETWORK_CREATED,
+
+        /**
+         * Signifies that the kubevirt network is updated.
+         */
+        KUBEVIRT_NETWORK_UPDATED,
+
+        /**
+         * Signifies that the kubevirt network is removed.
+         */
+        KUBEVIRT_NETWORK_REMOVED,
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkListener.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkListener.java
new file mode 100644
index 0000000..5faaf9b
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Listener for kubevirt network event.
+ */
+public interface KubevirtNetworkListener extends EventListener<KubevirtNetworkEvent> {
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkService.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkService.java
new file mode 100644
index 0000000..574f365
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkService.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import org.onosproject.event.ListenerService;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetwork.Type;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the inventory of kubevirt network.
+ */
+public interface KubevirtNetworkService
+        extends ListenerService<KubevirtNetworkEvent, KubevirtNetworkListener> {
+
+    /**
+     * Returns the kubevirt network with the supplied network identifier.
+     *
+     * @param networkId network identifier
+     * @return kubevirt network
+     */
+    KubevirtNetwork network(String networkId);
+
+    /**
+     * Returns all kubevirt networks registered in the service.
+     *
+     * @return set of kubevirt networks
+     */
+    Set<KubevirtNetwork> networks();
+
+    /**
+     * Returns the kubevirt networks with the given network type.
+     *
+     * @param type virtual network type
+     * @return set of kubevirt networks
+     */
+    Set<KubevirtNetwork> networks(Type type);
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkStore.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkStore.java
new file mode 100644
index 0000000..7452de8
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkStore.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import org.onosproject.store.Store;
+
+import java.util.Set;
+
+/**
+ * Manages inventory of kubevirt network states; not intended for direct use.
+ */
+public interface KubevirtNetworkStore
+        extends Store<KubevirtNetworkEvent, KubevirtNetworkStoreDelegate> {
+
+    /**
+     * Creates the new kubevirt network.
+     *
+     * @param network kubevirt network
+     */
+    void createNetwork(KubevirtNetwork network);
+
+    /**
+     * Update the kubevirt network.
+     *
+     * @param network kubevirt network
+     */
+    void updateNetwork(KubevirtNetwork network);
+
+    /**
+     * Removes the kubevirt network with the given network identifier.
+     *
+     * @param networkId network identifier
+     * @return removed kubevirt network; null if failed
+     */
+    KubevirtNetwork removeNetwork(String networkId);
+
+    /**
+     * Returns the kubevirt network with the given network identifier.
+     *
+     * @param networkId network identifier
+     * @return network; null if not found
+     */
+    KubevirtNetwork network(String networkId);
+
+    /**
+     * Returns all kubevirt networks.
+     *
+     * @return set of kubevirt networks
+     */
+    Set<KubevirtNetwork> networks();
+
+    /**
+     * Removes all kubevirt networks.
+     */
+    void clear();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkStoreDelegate.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkStoreDelegate.java
new file mode 100644
index 0000000..e375b6a
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtNetworkStoreDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * Kubevirt network store delegate abstraction.
+ */
+public interface KubevirtNetworkStoreDelegate extends StoreDelegate<KubevirtNetworkEvent> {
+}
diff --git a/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtNetworkTest.java b/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtNetworkTest.java
new file mode 100644
index 0000000..32ca958
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtNetworkTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.api;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetwork.Type.FLAT;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetwork.Type.VXLAN;
+
+/**
+ * Unit tests for the default kubevirt network class.
+ */
+public class DefaultKubevirtNetworkTest {
+    private static final String NETWORK_ID_1 = "net-1";
+    private static final String NETWORK_ID_2 = "net-2";
+    private static final KubevirtNetwork.Type TYPE_1 = FLAT;
+    private static final KubevirtNetwork.Type TYPE_2 = VXLAN;
+    private static final String NAME_1 = "net-1";
+    private static final String NAME_2 = "net-2";
+    private static final Integer MTU_1 = 1500;
+    private static final Integer MTU_2 = 1400;
+    private static final String SEGMENT_ID_1 = null;
+    private static final String SEGMENT_ID_2 = "2";
+    private static final IpAddress GATEWAY_IP_1 = IpAddress.valueOf("10.10.10.1");
+    private static final IpAddress GATEWAY_IP_2 = IpAddress.valueOf("20.20.20.1");
+    private static final String CIDR_1 = "10.10.10.0/24";
+    private static final String CIDR_2 = "20.20.20.0/24";
+    private static final IpAddress IP_POOL_START_1 = IpAddress.valueOf("10.10.10.100");
+    private static final IpAddress IP_POOL_START_2 = IpAddress.valueOf("20.20.20.100");
+    private static final IpAddress IP_POOL_END_1 = IpAddress.valueOf("10.10.10.200");
+    private static final IpAddress IP_POOL_END_2 = IpAddress.valueOf("20.20.20.200");
+
+    private KubevirtNetwork network1;
+    private KubevirtNetwork sameAsNetwork1;
+    private KubevirtNetwork network2;
+
+    /**
+     * Tests class immutability.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(DefaultKubevirtNetwork.class);
+    }
+
+    /**
+     * Initial setup for this unit test.
+     */
+    @Before
+    public void setUp() {
+        network1 = DefaultKubevirtNetwork.builder()
+                .networkId(NETWORK_ID_1)
+                .name(NAME_1)
+                .type(TYPE_1)
+                .mtu(MTU_1)
+                .segmentId(SEGMENT_ID_1)
+                .gatewayIp(GATEWAY_IP_1)
+                .cidr(CIDR_1)
+                .ipPool(new KubevirtIpPool(IP_POOL_START_1, IP_POOL_END_1))
+                .hostRoutes(ImmutableSet.of())
+                .build();
+
+        sameAsNetwork1 = DefaultKubevirtNetwork.builder()
+                .networkId(NETWORK_ID_1)
+                .name(NAME_1)
+                .type(TYPE_1)
+                .mtu(MTU_1)
+                .segmentId(SEGMENT_ID_1)
+                .gatewayIp(GATEWAY_IP_1)
+                .cidr(CIDR_1)
+                .ipPool(new KubevirtIpPool(IP_POOL_START_1, IP_POOL_END_1))
+                .hostRoutes(ImmutableSet.of())
+                .build();
+
+        network2 = DefaultKubevirtNetwork.builder()
+                .networkId(NETWORK_ID_2)
+                .name(NAME_2)
+                .type(TYPE_2)
+                .mtu(MTU_2)
+                .segmentId(SEGMENT_ID_2)
+                .gatewayIp(GATEWAY_IP_2)
+                .cidr(CIDR_2)
+                .ipPool(new KubevirtIpPool(IP_POOL_START_2, IP_POOL_END_2))
+                .hostRoutes(ImmutableSet.of())
+                .build();
+    }
+
+    /**
+     * Tests object equality.
+     */
+    @Test
+    public void testEquality() {
+        new EqualsTester().addEqualityGroup(network1, sameAsNetwork1)
+                .addEqualityGroup(network2)
+                .testEquals();
+    }
+
+    /**
+     * Test object construction.
+     */
+    @Test
+    public void testConstruction() {
+        KubevirtNetwork network = network1;
+
+        assertEquals(NETWORK_ID_1, network.networkId());
+        assertEquals(TYPE_1, network.type());
+        assertEquals(NAME_1, network.name());
+        assertEquals(MTU_1, network.mtu());
+        assertEquals(GATEWAY_IP_1, network.gatewayIp());
+        assertEquals(CIDR_1, network.cidr());
+        assertEquals(new KubevirtIpPool(IP_POOL_START_1, IP_POOL_END_1), network.ipPool());
+    }
+}
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/DistributedKubevirtNetworkStore.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/DistributedKubevirtNetworkStore.java
new file mode 100644
index 0000000..74c6f03
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/DistributedKubevirtNetworkStore.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.impl;
+
+import com.google.common.collect.ImmutableSet;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.kubevirtnetworking.api.DefaultKubevirtNetwork;
+import org.onosproject.kubevirtnetworking.api.KubevirtHostRoute;
+import org.onosproject.kubevirtnetworking.api.KubevirtIpPool;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetwork;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkStore;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkStoreDelegate;
+import org.onosproject.store.AbstractStore;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.MapEvent;
+import org.onosproject.store.service.MapEventListener;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.Versioned;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.slf4j.Logger;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.concurrent.Executors.newSingleThreadExecutor;
+import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent.Type.KUBEVIRT_NETWORK_CREATED;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent.Type.KUBEVIRT_NETWORK_REMOVED;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent.Type.KUBEVIRT_NETWORK_UPDATED;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Implementation of kubevirt network store using consistent map.
+ */
+@Component(immediate = true, service = KubevirtNetworkStore.class)
+public class DistributedKubevirtNetworkStore
+        extends AbstractStore<KubevirtNetworkEvent, KubevirtNetworkStoreDelegate>
+        implements KubevirtNetworkStore {
+    private final Logger log = getLogger(getClass());
+
+    private static final String ERR_NOT_FOUND = " does not exist";
+    private static final String ERR_DUPLICATE = " already exists";
+    private static final String APP_ID = "org.onosproject.kubevirtnetwork";
+
+    private static final KryoNamespace SERIALIZER_KUBEVIRT_NETWORK = KryoNamespace.newBuilder()
+            .register(KryoNamespaces.API)
+            .register(KubevirtNetwork.class)
+            .register(KubevirtNetwork.Type.class)
+            .register(DefaultKubevirtNetwork.class)
+            .register(KubevirtIpPool.class)
+            .register(KubevirtHostRoute.class)
+            .register(Collection.class)
+            .build();
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    protected CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    protected StorageService storageService;
+
+    private final ExecutorService eventExecutor = newSingleThreadExecutor(
+            groupedThreads(this.getClass().getSimpleName(), "event-handler", log));
+
+    private final MapEventListener<String, KubevirtNetwork> networkMapListener =
+            new KubevirtNetworkMapListener();
+
+    private ConsistentMap<String, KubevirtNetwork> networkStore;
+
+    @Activate
+    protected void activate() {
+        ApplicationId appId = coreService.registerApplication(APP_ID);
+        networkStore = storageService.<String, KubevirtNetwork>consistentMapBuilder()
+                .withSerializer(Serializer.using(SERIALIZER_KUBEVIRT_NETWORK))
+                .withName("kubevirt-networkstore")
+                .withApplicationId(appId)
+                .build();
+
+        networkStore.addListener(networkMapListener);
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        networkStore.removeListener(networkMapListener);
+        eventExecutor.shutdown();
+        log.info("Stopped");
+    }
+
+    @Override
+    public void createNetwork(KubevirtNetwork network) {
+        networkStore.compute(network.networkId(), (networkId, existing) -> {
+            final String error = network.networkId() + ERR_DUPLICATE;
+            checkArgument(existing == null, error);
+            return network;
+        });
+    }
+
+    @Override
+    public void updateNetwork(KubevirtNetwork network) {
+        networkStore.compute(network.networkId(), (networkId, existing) -> {
+            final String error = network.networkId() + ERR_NOT_FOUND;
+            checkArgument(existing != null, error);
+            return network;
+        });
+    }
+
+    @Override
+    public KubevirtNetwork removeNetwork(String networkId) {
+        Versioned<KubevirtNetwork> network = networkStore.remove(networkId);
+        if (network == null) {
+            final String error = networkId + ERR_NOT_FOUND;
+            throw new IllegalArgumentException(error);
+        }
+        return network.value();
+    }
+
+    @Override
+    public KubevirtNetwork network(String networkId) {
+        return networkStore.asJavaMap().get(networkId);
+    }
+
+    @Override
+    public Set<KubevirtNetwork> networks() {
+        return ImmutableSet.copyOf(networkStore.asJavaMap().values());
+    }
+
+    @Override
+    public void clear() {
+        networkStore.clear();
+    }
+
+    private class KubevirtNetworkMapListener implements MapEventListener<String, KubevirtNetwork> {
+
+        @Override
+        public void event(MapEvent<String, KubevirtNetwork> event) {
+
+            switch (event.type()) {
+                case INSERT:
+                    log.debug("Kubevirt network created {}", event.newValue());
+                    eventExecutor.execute(() ->
+                            notifyDelegate(new KubevirtNetworkEvent(
+                            KUBEVIRT_NETWORK_CREATED, event.newValue().value())));
+                    break;
+                case UPDATE:
+                    log.debug("Kubevirt network updated {}", event.newValue());
+                    eventExecutor.execute(() ->
+                            notifyDelegate(new KubevirtNetworkEvent(
+                            KUBEVIRT_NETWORK_UPDATED, event.newValue().value())));
+                    break;
+                case REMOVE:
+                    log.debug("Kubevirt network removed {}", event.oldValue());
+                    eventExecutor.execute(() ->
+                            notifyDelegate(new KubevirtNetworkEvent(
+                            KUBEVIRT_NETWORK_REMOVED, event.oldValue().value())));
+                    break;
+                default:
+                    // do nothing
+                    break;
+            }
+        }
+    }
+}
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtNetworkManager.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtNetworkManager.java
new file mode 100644
index 0000000..581fd29
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtNetworkManager.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.impl;
+
+
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.event.ListenerRegistry;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetwork;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkAdminService;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkListener;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkService;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkStore;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkStoreDelegate;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.slf4j.Logger;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.kubevirtnetworking.api.Constants.KUBEVIRT_NETWORKING_APP_ID;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Provides implementation of administering and interfacing kubevirt network.
+ */
+@Component(
+        immediate = true,
+        service = {KubevirtNetworkAdminService.class, KubevirtNetworkService.class}
+)
+public class KubevirtNetworkManager
+        extends ListenerRegistry<KubevirtNetworkEvent, KubevirtNetworkListener>
+        implements KubevirtNetworkAdminService, KubevirtNetworkService {
+
+    protected final Logger log = getLogger(getClass());
+
+    private static final String MSG_NETWORK  = "Kubernetes network %s %s";
+
+    private static final String MSG_CREATED = "created";
+    private static final String MSG_UPDATED = "updated";
+    private static final String MSG_REMOVED = "removed";
+
+    private static final String ERR_NULL_NETWORK  = "Kubernetes network cannot be null";
+    private static final String ERR_NULL_NETWORK_ID  = "Kubernetes network ID cannot be null";
+
+    private static final String ERR_IN_USE = " still in use";
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    protected CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    protected KubevirtNetworkStore networkStore;
+
+    private final KubevirtNetworkStoreDelegate delegate = new InternalNetworkStorageDelegate();
+
+    private ApplicationId appId;
+
+    @Activate
+    protected void activate() {
+        appId = coreService.registerApplication(KUBEVIRT_NETWORKING_APP_ID);
+
+        networkStore.setDelegate(delegate);
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        networkStore.unsetDelegate(delegate);
+        log.info("Stopped");
+    }
+
+    @Override
+    public void createNetwork(KubevirtNetwork network) {
+        checkNotNull(network, ERR_NULL_NETWORK);
+        checkArgument(!Strings.isNullOrEmpty(network.networkId()), ERR_NULL_NETWORK_ID);
+
+        networkStore.createNetwork(network);
+
+        log.info(String.format(MSG_NETWORK, network.name(), MSG_CREATED));
+    }
+
+    @Override
+    public void updateNetwork(KubevirtNetwork network) {
+        checkNotNull(network, ERR_NULL_NETWORK);
+        checkArgument(!Strings.isNullOrEmpty(network.networkId()), ERR_NULL_NETWORK_ID);
+
+        networkStore.updateNetwork(network);
+
+        log.info(String.format(MSG_NETWORK, network.networkId(), MSG_UPDATED));
+    }
+
+    @Override
+    public void removeNetwork(String networkId) {
+        checkArgument(!Strings.isNullOrEmpty(networkId), ERR_NULL_NETWORK_ID);
+
+        synchronized (this) {
+//            if (isNetworkInUse(networkId)) {
+//                final String error = String.format(MSG_NETWORK, networkId, ERR_IN_USE);
+//                throw new IllegalStateException(error);
+//            }
+            KubevirtNetwork network = networkStore.removeNetwork(networkId);
+
+            if (network != null) {
+                log.info(String.format(MSG_NETWORK, network.name(), MSG_REMOVED));
+            }
+        }
+    }
+
+    @Override
+    public void clear() {
+        networkStore.clear();
+    }
+
+    @Override
+    public KubevirtNetwork network(String networkId) {
+        checkArgument(!Strings.isNullOrEmpty(networkId), ERR_NULL_NETWORK_ID);
+        return networkStore.network(networkId);
+    }
+
+    @Override
+    public Set<KubevirtNetwork> networks() {
+        return ImmutableSet.copyOf(networkStore.networks());
+    }
+
+    @Override
+    public Set<KubevirtNetwork> networks(KubevirtNetwork.Type type) {
+        return ImmutableSet.copyOf(networkStore.networks().stream()
+                .filter(n -> n.type() == type).collect(Collectors.toSet()));
+    }
+
+    private class InternalNetworkStorageDelegate implements KubevirtNetworkStoreDelegate {
+
+        @Override
+        public void notify(KubevirtNetworkEvent event) {
+            if (event != null) {
+                log.trace("send kubevirt networking event {}", event);
+                process(event);
+            }
+        }
+    }
+}
diff --git a/apps/kubevirt-networking/app/src/test/java/org/onosproject/kubevirtnetworking/impl/KubevirtNetworkManagerTest.java b/apps/kubevirt-networking/app/src/test/java/org/onosproject/kubevirtnetworking/impl/KubevirtNetworkManagerTest.java
new file mode 100644
index 0000000..1d0c676
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/test/java/org/onosproject/kubevirtnetworking/impl/KubevirtNetworkManagerTest.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * 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.kubevirtnetworking.impl;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.junit.TestUtils;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreServiceAdapter;
+import org.onosproject.core.DefaultApplicationId;
+import org.onosproject.event.Event;
+import org.onosproject.kubevirtnetworking.api.DefaultKubevirtNetwork;
+import org.onosproject.kubevirtnetworking.api.KubevirtIpPool;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetwork;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent;
+import org.onosproject.kubevirtnetworking.api.KubevirtNetworkListener;
+import org.onosproject.store.service.TestStorageService;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetwork.Type.VXLAN;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent.Type.KUBEVIRT_NETWORK_CREATED;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent.Type.KUBEVIRT_NETWORK_REMOVED;
+import static org.onosproject.kubevirtnetworking.api.KubevirtNetworkEvent.Type.KUBEVIRT_NETWORK_UPDATED;
+
+/**
+ * Unit tests for kubevirt network manager.
+ */
+public class KubevirtNetworkManagerTest {
+
+    private static final ApplicationId TEST_APP_ID = new DefaultApplicationId(1, "test");
+
+    private static final String UNKNOWN_ID = "unknown_id";
+    private static final String UPDATED_NAME = "updated_name";
+
+    private static final String NETWORK_ID = "network_id";
+    private static final String NETWORK_NAME = "network_name";
+
+    private static final KubevirtNetwork.Type TYPE = VXLAN;
+    private static final Integer MTU = 1500;
+    private static final String SEGMENT_ID = "1";
+    private static final IpAddress GATEWAY_IP = IpAddress.valueOf("10.10.10.1");
+    private static final String CIDR = "10.10.10.0/24";
+    private static final IpAddress IP_POOL_START = IpAddress.valueOf("10.10.10.100");
+    private static final IpAddress IP_POOL_END = IpAddress.valueOf("10.10.10.200");
+
+    private static final KubevirtNetwork NETWORK = DefaultKubevirtNetwork.builder()
+            .networkId(NETWORK_ID)
+            .name(NETWORK_NAME)
+            .type(TYPE)
+            .mtu(MTU)
+            .segmentId(SEGMENT_ID)
+            .gatewayIp(GATEWAY_IP)
+            .cidr(CIDR)
+            .ipPool(new KubevirtIpPool(IP_POOL_START, IP_POOL_END))
+            .hostRoutes(ImmutableSet.of())
+            .build();
+
+    private static final KubevirtNetwork NETWORK_UPDATED = DefaultKubevirtNetwork.builder()
+            .networkId(NETWORK_ID)
+            .name(UPDATED_NAME)
+            .type(TYPE)
+            .mtu(MTU)
+            .segmentId(SEGMENT_ID)
+            .gatewayIp(GATEWAY_IP)
+            .cidr(CIDR)
+            .ipPool(new KubevirtIpPool(IP_POOL_START, IP_POOL_END))
+            .hostRoutes(ImmutableSet.of())
+            .build();
+
+    private final TestKubevirtnetworkListener testListener = new TestKubevirtnetworkListener();
+
+    private KubevirtNetworkManager target;
+    private DistributedKubevirtNetworkStore networkStore;
+
+    @Before
+    public void setUp() throws Exception {
+        networkStore = new DistributedKubevirtNetworkStore();
+        TestUtils.setField(networkStore, "coreService", new TestCoreService());
+        TestUtils.setField(networkStore, "storageService", new TestStorageService());
+        TestUtils.setField(networkStore, "eventExecutor", MoreExecutors.newDirectExecutorService());
+        networkStore.activate();
+
+        target = new KubevirtNetworkManager();
+        TestUtils.setField(target, "coreService", new TestCoreService());
+        target.networkStore = networkStore;
+        target.addListener(testListener);
+        target.activate();
+    }
+
+    @After
+    public void tearDown() {
+        target.removeListener(testListener);
+        networkStore.deactivate();
+        target.deactivate();
+        networkStore = null;
+        target = null;
+    }
+
+    /**
+     * Tests if getting all networks returns the correct set of networks.
+     */
+    @Test
+    public void testGetNetworks() {
+        createBasicNetworks();
+        assertEquals("Number of network did not match", 1, target.networks().size());
+    }
+
+    /**
+     * Tests if getting a network with ID returns the correct network.
+     */
+    @Test
+    public void testGetNetworkById() {
+        createBasicNetworks();
+        assertNotNull("Network did not match", target.network(NETWORK_ID));
+        assertNull("Network did not match", target.network(UNKNOWN_ID));
+    }
+
+    /**
+     * Tests creating and removing a network, and checks if it triggers proper events.
+     */
+    @Test
+    public void testCreateAndRemoveNetwork() {
+        target.createNetwork(NETWORK);
+        assertEquals("Number of networks did not match", 1, target.networks().size());
+        assertNotNull("Network was not created", target.network(NETWORK_ID));
+
+        target.removeNetwork(NETWORK_ID);
+        assertEquals("Number of networks did not match", 0, target.networks().size());
+        assertNull("Network was not removed", target.network(NETWORK_ID));
+
+        validateEvents(KUBEVIRT_NETWORK_CREATED, KUBEVIRT_NETWORK_REMOVED);
+    }
+
+    /**
+     * Tests updating a network, and checks if it triggers proper events.
+     */
+    @Test
+    public void testCreateAndUpdateNetwork() {
+        target.createNetwork(NETWORK);
+        assertEquals("Number of networks did not match", 1, target.networks().size());
+        assertEquals("Network did not match", NETWORK_NAME, target.network(NETWORK_ID).name());
+
+        target.updateNetwork(NETWORK_UPDATED);
+
+        assertEquals("Number of networks did not match", 1, target.networks().size());
+        assertEquals("Network did not match", UPDATED_NAME, target.network(NETWORK_ID).name());
+        validateEvents(KUBEVIRT_NETWORK_CREATED, KUBEVIRT_NETWORK_UPDATED);
+    }
+
+    /**
+     * Tests if creating a null network fails with an exception.
+     */
+    @Test(expected = NullPointerException.class)
+    public void testCreateNullNetwork() {
+        target.createNetwork(null);
+    }
+
+    /**
+     * Tests if creating a duplicate network fails with an exception.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testCreateDuplicateNetwork() {
+        target.createNetwork(NETWORK);
+        target.createNetwork(NETWORK);
+    }
+
+    /**
+     * Tests if removing network with null ID fails with an exception.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testRemoveNetworkWithNull() {
+        target.removeNetwork(null);
+    }
+
+    /**
+     * Tests if updating an unregistered network fails with an exception.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testUpdateUnregisteredNetwork() {
+        target.updateNetwork(NETWORK);
+    }
+
+    private void createBasicNetworks() {
+        target.createNetwork(NETWORK);
+    }
+
+    private static class TestCoreService extends CoreServiceAdapter {
+
+        @Override
+        public ApplicationId registerApplication(String name) {
+            return TEST_APP_ID;
+        }
+    }
+
+    private static class TestKubevirtnetworkListener implements KubevirtNetworkListener {
+        private List<KubevirtNetworkEvent> events = Lists.newArrayList();
+
+        @Override
+        public void event(KubevirtNetworkEvent event) {
+            events.add(event);
+        }
+    }
+
+    private void validateEvents(Enum... types) {
+        int i = 0;
+        assertEquals("Number of events did not match", types.length, testListener.events.size());
+        for (Event event : testListener.events) {
+            assertEquals("Incorrect event received", types[i], event.type());
+            i++;
+        }
+        testListener.events.clear();
+    }
+}