Add Kubevirt Port and Instance classes with CURD interfaces

Change-Id: I1afbba8a04bc1872cc1c086f2e3a15620533d517
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtInstance.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtInstance.java
new file mode 100644
index 0000000..13b94ce
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtInstance.java
@@ -0,0 +1,133 @@
+/*
+ * 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 java.util.Objects;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+public final class DefaultKubevirtInstance implements KubevirtInstance {
+
+    private static final String NOT_NULL_MSG = "Instance % cannot be null";
+
+    private final String uid;
+    private final String name;
+    private final Set<KubevirtPort> ports;
+
+    /**
+     * Default constructor.
+     *
+     * @param uid       UID
+     * @param name      name of instance
+     * @param ports     set of ports associated with the instance
+     */
+    public DefaultKubevirtInstance(String uid, String name, Set<KubevirtPort> ports) {
+        this.uid = uid;
+        this.name = name;
+        this.ports = ports;
+    }
+
+    @Override
+    public String uid() {
+        return uid;
+    }
+
+    @Override
+    public String name() {
+        return name;
+    }
+
+    @Override
+    public Set<KubevirtPort> ports() {
+        return ImmutableSet.copyOf(ports);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        DefaultKubevirtInstance that = (DefaultKubevirtInstance) o;
+        return uid.equals(that.uid) && name.equals(that.name) && ports.equals(that.ports);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(uid, name, ports);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("uid", uid)
+                .add("name", name)
+                .add("ports", ports)
+                .toString();
+    }
+
+    /**
+     * Returns new builder instance.
+     *
+     * @return kubevirt port builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /**
+     * Default builder implementation.
+     */
+    public static final class Builder implements KubevirtInstance.Builder {
+
+        private String uid;
+        private String name;
+        private Set<KubevirtPort> ports;
+
+        @Override
+        public KubevirtInstance build() {
+            checkArgument(uid != null, NOT_NULL_MSG, "UID");
+            checkArgument(name != null, NOT_NULL_MSG, "name");
+            checkArgument(ports != null, NOT_NULL_MSG, "ports");
+
+            return new DefaultKubevirtInstance(uid, name, ports);
+        }
+
+        @Override
+        public Builder uid(String uid) {
+            this.uid = uid;
+            return this;
+        }
+
+        @Override
+        public Builder name(String name) {
+            this.name = name;
+            return this;
+        }
+
+        @Override
+        public Builder ports(Set<KubevirtPort> ports) {
+            this.ports = ports;
+            return this;
+        }
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtPort.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtPort.java
new file mode 100644
index 0000000..049a336
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtPort.java
@@ -0,0 +1,169 @@
+/*
+ * 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.MacAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Default implementation of kubernetes port.
+ */
+public final class DefaultKubevirtPort implements KubevirtPort {
+
+    private static final String NOT_NULL_MSG = "Port % cannot be null";
+
+    private final MacAddress macAddress;
+    private final IpAddress ipAddress;
+    private final DeviceId deviceId;
+    private final PortNumber portNumber;
+
+    /**
+     * Default constructor.
+     *
+     * @param macAddress        MAC address
+     * @param ipAddress         IP address
+     * @param deviceId          device identifier
+     * @param portNumber        port number
+     */
+    public DefaultKubevirtPort(MacAddress macAddress, IpAddress ipAddress,
+                               DeviceId deviceId, PortNumber portNumber) {
+        this.macAddress = macAddress;
+        this.ipAddress = ipAddress;
+        this.deviceId = deviceId;
+        this.portNumber = portNumber;
+    }
+
+    @Override
+    public MacAddress macAddress() {
+        return macAddress;
+    }
+
+    @Override
+    public IpAddress ipAddress() {
+        return ipAddress;
+    }
+
+    @Override
+    public DeviceId deviceId() {
+        return deviceId;
+    }
+
+    @Override
+    public PortNumber portNumber() {
+        return portNumber;
+    }
+
+    @Override
+    public KubevirtPort updatePortNumber(PortNumber portNumber) {
+        return null;
+    }
+
+    @Override
+    public KubevirtPort updateDeviceId(DeviceId deviceId) {
+        return null;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        DefaultKubevirtPort that = (DefaultKubevirtPort) o;
+        return macAddress.equals(that.macAddress) && ipAddress.equals(that.ipAddress) &&
+                deviceId.equals(that.deviceId) && portNumber.equals(that.portNumber);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(macAddress, ipAddress, deviceId, portNumber);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("macAddress", macAddress)
+                .add("ipAddress", ipAddress)
+                .add("deviceId", deviceId)
+                .add("portNumber", portNumber)
+                .toString();
+    }
+
+    /**
+     * Returns new builder instance.
+     *
+     * @return kubevirt port builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /**
+     * Default builder implementation.
+     */
+    public static final class Builder implements KubevirtPort.Builder {
+
+        private MacAddress macAddress;
+        private IpAddress ipAddress;
+        private DeviceId deviceId;
+        private PortNumber portNumber;
+
+        // private constructor not intended to use from external
+        private Builder() {
+        }
+
+        @Override
+        public KubevirtPort build() {
+            checkArgument(macAddress != null, NOT_NULL_MSG, "macAddress");
+            checkArgument(ipAddress != null, NOT_NULL_MSG, "ipAddress");
+
+            return new DefaultKubevirtPort(macAddress, ipAddress, deviceId, portNumber);
+        }
+
+        @Override
+        public Builder macAddress(MacAddress macAddress) {
+            this.macAddress = macAddress;
+            return this;
+        }
+
+        @Override
+        public Builder ipAddress(IpAddress ipAddress) {
+            this.ipAddress = ipAddress;
+            return this;
+        }
+
+        @Override
+        public Builder deviceId(DeviceId deviceId) {
+            this.deviceId = deviceId;
+            return this;
+        }
+
+        @Override
+        public Builder portNumber(PortNumber portNumber) {
+            this.portNumber = portNumber;
+            return this;
+        }
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstance.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstance.java
new file mode 100644
index 0000000..83f7a1f
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstance.java
@@ -0,0 +1,79 @@
+/*
+ * 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 java.util.Set;
+
+/**
+ * Interface of kubevirt instance.
+ */
+public interface KubevirtInstance {
+
+    /**
+     * Returns the kubevirt instance UID.
+     *
+     * @return kubevirt instance UID
+     */
+    String uid();
+
+    /**
+     * Returns the kubevirt instance name.
+     *
+     * @return kubevirt instance name
+     */
+    String name();
+
+    /**
+     * Returns the kubevirt ports associated with the instance.
+     *
+     * @return kubevirt ports
+     */
+    Set<KubevirtPort> ports();
+
+    interface Builder {
+
+        /**
+         * Builds on immutable instance.
+         *
+         * @return kubevirt instance
+         */
+        KubevirtInstance build();
+
+        /**
+         * Returns instance builder with supplied UID.
+         *
+         * @param uid UID of instance
+         * @return instance builder
+         */
+        Builder uid(String uid);
+
+        /**
+         * Returns instance builder with supplied name.
+         *
+         * @param name name of instance
+         * @return instance builder
+         */
+        Builder name(String name);
+
+        /**
+         * Returns instance builder with supplied ports.
+         *
+         * @param ports set of ports
+         * @return instance builder
+         */
+        Builder ports(Set<KubevirtPort> ports);
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceAdminService.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceAdminService.java
new file mode 100644
index 0000000..0262ea6
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceAdminService.java
@@ -0,0 +1,45 @@
+/*
+ * 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 KubevirtInstanceAdminService extends KubevirtInstanceService {
+
+    /**
+     * Creates a new kubevirt instance with the given information.
+     *
+     * @param instance a new kubevirt instance
+     */
+    void createInstance(KubevirtInstance instance);
+
+    /**
+     * Updates the kubevirt instance with the given information.
+     *
+     * @param instance the updated kubevirt instance
+     */
+    void updateInstance(KubevirtInstance instance);
+
+    /**
+     * Removes the kubevirt instance.
+     *
+     * @param uid kubevirt instance UID
+     */
+    void removeInstance(String uid);
+
+    /**
+     * Clears the existing instances.
+     */
+    void clear();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceEvent.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceEvent.java
new file mode 100644
index 0000000..a9ecdb6
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceEvent.java
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+/**
+ * Kubevirt Instance event class.
+ */
+public class KubevirtInstanceEvent extends AbstractEvent<KubevirtInstanceEvent.Type, KubevirtInstance> {
+
+    /**
+     * Creates an event of a given type for the specified kubevirt instance.
+     *
+     * @param type          kubevirt instance event type
+     * @param subject       kubevirt instance
+     */
+    protected KubevirtInstanceEvent(Type type, KubevirtInstance subject) {
+        super(type, subject);
+    }
+
+    /**
+     * Kubevirt instance events.
+     */
+    public enum Type {
+        /**
+         * Signifies that a new kubevirt instance is created.
+         */
+        KUBEVIRT_INSTANCE_CREATED,
+
+        /**
+         * Signifies that the kubevirt instance is updated.
+         */
+        KUBEVIRT_INSTANCE_UPDATED,
+
+        /**
+         * Signifies that the kubevirt instance is removed.
+         */
+        KUBEVIRT_INSTANCE_REMOVED,
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceListener.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceListener.java
new file mode 100644
index 0000000..2acfa0f
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceListener.java
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+public interface KubevirtInstanceListener extends EventListener<KubevirtInstanceEvent> {
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceService.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceService.java
new file mode 100644
index 0000000..1230e34
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceService.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;
+
+import org.onosproject.event.ListenerService;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the inventory of kubevirt instance.
+ */
+public interface KubevirtInstanceService
+        extends ListenerService<KubevirtInstanceEvent, KubevirtInstanceListener> {
+
+    /**
+     * Returns the kubevirt instance with the supplied instance UID.
+     *
+     * @param uid instance UID
+     * @return kubevirt instance
+     */
+    KubevirtInstance instance(String uid);
+
+    /**
+     * Returns all kubevirt instances registered.
+     *
+     * @return set of kubevirt instances
+     */
+    Set<KubevirtInstance> instances();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceStore.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceStore.java
new file mode 100644
index 0000000..fadbf7e
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceStore.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 instance; not intended for direct use.
+ */
+public interface KubevirtInstanceStore
+        extends Store<KubevirtInstanceEvent, KubevirtInstanceStoreDelegate> {
+
+    /**
+     * Creates a new kubevirt instance.
+     *
+     * @param instance kubevirt instance
+     */
+    void createInstance(KubevirtInstance instance);
+
+    /**
+     * Updates the kubevirt instance.
+     *
+     * @param instance kubevirt instance
+     */
+    void updateInstance(KubevirtInstance instance);
+
+    /**
+     * Removes the kubevirt instance with the given instance UID.
+     *
+     * @param uid kubevirt instance UID
+     * @return remove kubevirt instance; null if failed
+     */
+    KubevirtInstance removeInstance(String uid);
+
+    /**
+     * Returns the kubevirt instance with the given instance UID.
+     *
+     * @param uid kubevirt instance UID
+     * @return kubevirt instance; null if not found
+     */
+    KubevirtInstance instance(String uid);
+
+    /**
+     * Returns all kubevirt instances.
+     *
+     * @return set of kubevirt instance
+     */
+    Set<KubevirtInstance> instances();
+
+    /**
+     * Removes all kubevirt instances.
+     */
+    void clear();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceStoreDelegate.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceStoreDelegate.java
new file mode 100644
index 0000000..4a100d6
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtInstanceStoreDelegate.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 instance store delegate abstraction.
+ */
+public interface KubevirtInstanceStoreDelegate extends StoreDelegate<KubevirtInstanceEvent> {
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPort.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPort.java
new file mode 100644
index 0000000..d7c1ff2
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPort.java
@@ -0,0 +1,116 @@
+/*
+ * 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 org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+/**
+ * Representation of virtual port.
+ */
+public interface KubevirtPort {
+
+    /**
+     * Returns the MAC address of the port.
+     *
+     * @return MAC address
+     */
+    MacAddress macAddress();
+
+    /**
+     * Returns the IP address of the port.
+     *
+     * @return IP address
+     */
+    IpAddress ipAddress();
+
+    /**
+     * Returns the device ID of the port.
+     *
+     * @return device ID
+     */
+    DeviceId deviceId();
+
+    /**
+     * Returns the port number of the port.
+     *
+     * @return port number
+     */
+    PortNumber portNumber();
+
+    /**
+     * Returns new port instance with the given port number.
+     *
+     * @param portNumber updated port number
+     * @return updated port
+     */
+    KubevirtPort updatePortNumber(PortNumber portNumber);
+
+    /**
+     * Returns new port instance with the given device ID.
+     *
+     * @param deviceId device identifier
+     * @return updated port
+     */
+    KubevirtPort updateDeviceId(DeviceId deviceId);
+
+    /**
+     * Builder of new port.
+     */
+    interface Builder {
+
+        /**
+         * Builds an immutable port instance.
+         *
+         * @return kubernetes port
+         */
+        KubevirtPort build();
+
+        /**
+         * Returns port builder with supplied MAC address.
+         *
+         * @param macAddress MAC address
+         * @return port builder
+         */
+        Builder macAddress(MacAddress macAddress);
+
+        /**
+         * Returns port builder with supplied IP address.
+         *
+         * @param ipAddress IP address
+         * @return port builder
+         */
+        Builder ipAddress(IpAddress ipAddress);
+
+        /**
+         * Returns port builder with supplied device ID.
+         *
+         * @param deviceId device ID
+         * @return port builder
+         */
+        Builder deviceId(DeviceId deviceId);
+
+        /**
+         * Returns port builder with supplied port number.
+         *
+         * @param portNumber port number
+         * @return port builder
+         */
+        Builder portNumber(PortNumber portNumber);
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortAdminService.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortAdminService.java
new file mode 100644
index 0000000..6e384d7
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortAdminService.java
@@ -0,0 +1,47 @@
+/*
+ * 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.MacAddress;
+
+public interface KubevirtPortAdminService extends KubevirtPortService {
+
+    /**
+     * Creates a kubevirt port with the given information.
+     *
+     * @param port a new kubevirt port
+     */
+    void createPort(KubevirtPort port);
+
+    /**
+     * Updates the kubevirt port with the given information.
+     *
+     * @param port the updated kubevirt port
+     */
+    void updatePort(KubevirtPort port);
+
+    /**
+     * Removes the kubevirt port.
+     *
+     * @param mac MAC address bound with the port
+     */
+    void removePort(MacAddress mac);
+
+    /**
+     * Clears the existing ports.
+     */
+    void clear();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortEvent.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortEvent.java
new file mode 100644
index 0000000..efc67d5
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortEvent.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+/**
+ * Kubevirt port event class.
+ */
+public class KubevirtPortEvent extends AbstractEvent<KubevirtPortEvent.Type, KubevirtPort> {
+
+    /**
+     * Creates an event of a given type for the specified port.
+     *
+     * @param type      kubevirt port event type
+     * @param subject   kubevirt port subject
+     */
+    public KubevirtPortEvent(Type type, KubevirtPort subject) {
+        super(type, subject);
+    }
+
+    /**
+     * Kubevirt port events.
+     */
+    public enum Type {
+
+        /**
+         * Signifies that a new kubevirt port is created.
+         */
+        KUBEVIRT_PORT_CREATED,
+
+        /**
+         * Signifies that the kubevirt port is updated.
+         */
+        KUBEVIRT_PORT_UPDATED,
+
+        /**
+         * Signifies that the kubevirt port is removed.
+         */
+        KUBEVIRT_PORT_REMOVED,
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortListener.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortListener.java
new file mode 100644
index 0000000..49aabf6
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortListener.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 port event.
+ */
+public interface KubevirtPortListener extends EventListener<KubevirtPortEvent> {
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortService.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortService.java
new file mode 100644
index 0000000..7861bb3
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortService.java
@@ -0,0 +1,43 @@
+/*
+ * 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.MacAddress;
+import org.onosproject.event.ListenerService;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the inventory of kubevirt port.
+ */
+public interface KubevirtPortService
+        extends ListenerService<KubevirtPortEvent, KubevirtPortListener> {
+
+    /**
+     * Returns the kubevirt port with the supplied MAC address.
+     *
+     * @param mac MAC address
+     * @return kubevirt port
+     */
+    KubevirtPort port(MacAddress mac);
+
+    /**
+     * Returns all kubevirt ports registered.
+     *
+     * @return set of kubevirt ports
+     */
+    Set<KubevirtPort> ports();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortStore.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortStore.java
new file mode 100644
index 0000000..0daf301
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortStore.java
@@ -0,0 +1,70 @@
+/*
+ * 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.MacAddress;
+import org.onosproject.store.Store;
+
+import java.util.Set;
+
+/**
+ * Manages inventory of kubevirt port; not intended for direct use.
+ */
+public interface KubevirtPortStore
+        extends Store<KubevirtPortEvent, KubevirtPortStoreDelegate> {
+
+    /**
+     * Creates a new kubevirt port.
+     *
+     * @param port kubevirt port
+     */
+    void createPort(KubevirtPort port);
+
+    /**
+     * Updates the kubevirt port.
+     *
+     * @param port kubevirt port
+     */
+    void updatedPort(KubevirtPort port);
+
+    /**
+     * Removes the kubevirt port with the given MAC address.
+     *
+     * @param mac port MAC address
+     * @return removed kubevirt port; null if failed
+     */
+    KubevirtPort removePort(MacAddress mac);
+
+    /**
+     * Returns the kubevirt port with the given port MAC.
+     *
+     * @param mac port MAC address
+     * @return kubevirt port; null if not found
+     */
+    KubevirtPort port(MacAddress mac);
+
+    /**
+     * Returns all kubevirt ports.
+     *
+     * @return set of kubevirt ports
+     */
+    Set<KubevirtPort> ports();
+
+    /**
+     * Removes all kubevirt ports.
+     */
+    void clear();
+}
diff --git a/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortStoreDelegate.java b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortStoreDelegate.java
new file mode 100644
index 0000000..1ce09b8
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/main/java/org/onosproject/kubevirtnetworking/api/KubevirtPortStoreDelegate.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 port store delegate abstraction.
+ */
+public interface KubevirtPortStoreDelegate extends StoreDelegate<KubevirtPortEvent> {
+}
diff --git a/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtInstanceTest.java b/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtInstanceTest.java
new file mode 100644
index 0000000..c1e59b6
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtInstanceTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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 org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Unit tests for the default kubevirt instance class.
+ */
+public class DefaultKubevirtInstanceTest {
+
+    private static final String UID_1 = "1";
+    private static final String UID_2 = "2";
+    private static final String NAME_1 = "instance-1";
+    private static final String NAME_2 = "instance-2";
+    private static final MacAddress MAC_1 = MacAddress.valueOf("11:22:33:44:55:66");
+    private static final MacAddress MAC_2 = MacAddress.valueOf("66:55:44:33:22:11");
+    private static final IpAddress IP_1 = IpAddress.valueOf("10.10.10.10");
+    private static final IpAddress IP_2 = IpAddress.valueOf("20.20.20.20");
+    private static final DeviceId DID_1 = DeviceId.deviceId("did1");
+    private static final DeviceId DID_2 = DeviceId.deviceId("did2");
+    private static final PortNumber PN_1 = PortNumber.portNumber(1);
+    private static final PortNumber PN_2 = PortNumber.portNumber(2);
+    private static final KubevirtPort PORT_1 = createPort(MAC_1, IP_1, DID_1, PN_1);
+    private static final KubevirtPort PORT_2 = createPort(MAC_2, IP_2, DID_2, PN_2);
+
+    private KubevirtInstance instance1;
+    private KubevirtInstance sameAsInstance1;
+    private KubevirtInstance instance2;
+
+    /**
+     * Tests class immutability.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(DefaultKubevirtInstance.class);
+    }
+
+    /**
+     * Initial setup for this unit test.
+     */
+    @Before
+    public void setUp() {
+        instance1 = DefaultKubevirtInstance.builder()
+                .uid(UID_1)
+                .name(NAME_1)
+                .ports(ImmutableSet.of(PORT_1))
+                .build();
+
+        sameAsInstance1 = DefaultKubevirtInstance.builder()
+                .uid(UID_1)
+                .name(NAME_1)
+                .ports(ImmutableSet.of(PORT_1))
+                .build();
+
+        instance2 = DefaultKubevirtInstance.builder()
+                .uid(UID_2)
+                .name(NAME_2)
+                .ports(ImmutableSet.of(PORT_2))
+                .build();
+    }
+
+    /**
+     * Tests object equality.
+     */
+    @Test
+    public void testEquality() {
+        new EqualsTester().addEqualityGroup(instance1, sameAsInstance1)
+                .addEqualityGroup(instance2)
+                .testEquals();
+    }
+
+    /**
+     * Test object construction.
+     */
+    @Test
+    public void testConstruction() {
+        KubevirtInstance instance = instance1;
+
+        assertEquals(UID_1, instance1.uid());
+        assertEquals(NAME_1, instance1.name());
+        assertEquals(ImmutableSet.of(PORT_1), instance1.ports());
+    }
+
+    static KubevirtPort createPort(MacAddress mac, IpAddress ip, DeviceId did, PortNumber pn) {
+        return DefaultKubevirtPort.builder()
+                .macAddress(mac)
+                .ipAddress(ip)
+                .deviceId(did)
+                .portNumber(pn)
+                .build();
+    }
+}
diff --git a/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtPortTest.java b/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtPortTest.java
new file mode 100644
index 0000000..00f3cd4
--- /dev/null
+++ b/apps/kubevirt-networking/api/src/test/java/org/onosproject/kubevirtnetworking/api/DefaultKubevirtPortTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Unit tests for the default kubevirt port class.
+ */
+public class DefaultKubevirtPortTest {
+    private static final MacAddress MAC_ADDRESS_1 = MacAddress.valueOf("00:11:22:33:44:55");
+    private static final MacAddress MAC_ADDRESS_2 = MacAddress.valueOf("11:22:33:44:55:66");
+    private static final IpAddress IP_ADDRESS_1 = IpAddress.valueOf("10.10.10.10");
+    private static final IpAddress IP_ADDRESS_2 = IpAddress.valueOf("20.20.20.20");
+    private static final DeviceId DEVICE_ID_1 = DeviceId.deviceId("of:000000000000001");
+    private static final DeviceId DEVICE_ID_2 = DeviceId.deviceId("of:000000000000002");
+    private static final PortNumber PORT_NUMBER_1 = PortNumber.portNumber(1);
+    private static final PortNumber PORT_NUMBER_2 = PortNumber.portNumber(2);
+
+    private KubevirtPort port1;
+    private KubevirtPort sameAsPort1;
+    private KubevirtPort port2;
+
+    /**
+     * Tests class immutability.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(DefaultKubevirtPort.class);
+    }
+
+    /**
+     * Initial setup for this unit test.
+     */
+    @Before
+    public void setUp() {
+        port1 = DefaultKubevirtPort.builder()
+                .macAddress(MAC_ADDRESS_1)
+                .ipAddress(IP_ADDRESS_1)
+                .deviceId(DEVICE_ID_1)
+                .portNumber(PORT_NUMBER_1)
+                .build();
+
+        sameAsPort1 = DefaultKubevirtPort.builder()
+                .macAddress(MAC_ADDRESS_1)
+                .ipAddress(IP_ADDRESS_1)
+                .deviceId(DEVICE_ID_1)
+                .portNumber(PORT_NUMBER_1)
+                .build();
+
+        port2 = DefaultKubevirtPort.builder()
+                .macAddress(MAC_ADDRESS_2)
+                .ipAddress(IP_ADDRESS_2)
+                .deviceId(DEVICE_ID_2)
+                .portNumber(PORT_NUMBER_2)
+                .build();
+    }
+
+    /**
+     * Tests object equality.
+     */
+    @Test
+    public void testEquality() {
+        new EqualsTester().addEqualityGroup(port1, sameAsPort1)
+                .addEqualityGroup(port2)
+                .testEquals();
+    }
+
+    /**
+     * Test object construction.
+     */
+    @Test
+    public void testConstruction() {
+        KubevirtPort port = port1;
+
+        assertEquals(MAC_ADDRESS_1, port.macAddress());
+        assertEquals(IP_ADDRESS_1, port.ipAddress());
+        assertEquals(DEVICE_ID_1, port.deviceId());
+        assertEquals(PORT_NUMBER_1, port.portNumber());
+    }
+}