[ONOS-6632] Add REST APIs for configuring compute and gateway nodes.

 - network configuration is not working any more.

Change-Id: I24e4d8b7b8cc33d839328887b9c6190d714baeba
diff --git a/apps/openstacknode/api/BUCK b/apps/openstacknode/api/BUCK
new file mode 100644
index 0000000..1099c27
--- /dev/null
+++ b/apps/openstacknode/api/BUCK
@@ -0,0 +1,19 @@
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//lib:org.apache.karaf.shell.console',
+    '//cli:onos-cli',
+    '//protocols/ovsdb/api:onos-protocols-ovsdb-api',
+    '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
+    '//core/store/serializers:onos-core-serializers',
+]
+
+TEST_DEPS = [
+    '//lib:TEST_ADAPTERS',
+    '//core/api:onos-api-tests',
+    '//core/common:onos-core-common-tests',
+]
+
+osgi_jar_with_tests (
+    deps = COMPILE_DEPS,
+    test_deps = TEST_DEPS
+)
diff --git a/apps/openstacknode/api/pom.xml b/apps/openstacknode/api/pom.xml
new file mode 100644
index 0000000..a48e296
--- /dev/null
+++ b/apps/openstacknode/api/pom.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-apps-openstacknode</artifactId>
+        <version>1.11.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-apps-openstacknode-api</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>SONA Openstack Node Bootstrap Application</description>
+
+
+    <properties>
+        <onos.app.name>org.onosproject.openstacknode</onos.app.name>
+        <onos.app.title>OpenStack Node Bootstrap App</onos.app.title>
+        <onos.app.category>Utility</onos.app.category>
+        <onos.app.url>http://onosproject.org</onos.app.url>
+        <onos.app.readme>SONA Openstack Node Bootstrap Application</onos.app.readme>
+        <onos.app.requires>
+            org.onosproject.ovsdb-base,
+            org.onosproject.drivers.ovsdb
+        </onos.app.requires>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-rest</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-core-serializers</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-cli</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-protocols-ovsdb-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava-testlib</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+</project>
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
new file mode 100644
index 0000000..9f812db
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+/**
+ * Provides constants used in OpenStack node services.
+ */
+public final class Constants {
+
+    private Constants() {
+    }
+
+    public static final String INTEGRATION_BRIDGE = "br-int";
+    public static final String ROUTER_BRIDGE = "br-router";
+    public static final String DEFAULT_TUNNEL = "vxlan";
+    public static final String PATCH_INTG_BRIDGE = "patch-intg";
+    public static final String PATCH_ROUT_BRIDGE = "patch-rout";
+}
\ No newline at end of file
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java
new file mode 100644
index 0000000..6d3a825
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+/**
+ * Defines the initialization states of OpenStack node.
+ */
+public enum NodeState {
+
+    /**
+     * Indicates the node is newly added.
+     */
+    INIT {
+        @Override
+        public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
+            handler.processInitState(osNode);
+        }
+
+        @Override
+        public NodeState nextState() {
+            return DEVICE_CREATED;
+        }
+    },
+    /**
+     * Indicates bridge devices are added according to the node state.
+     */
+    DEVICE_CREATED {
+        @Override
+        public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
+            handler.processDeviceCreatedState(osNode);
+        }
+
+        @Override
+        public NodeState nextState() {
+            return PORT_CREATED;
+        }
+    },
+    /**
+     * Indicates required ports are added.
+     */
+    PORT_CREATED {
+        @Override
+        public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
+            handler.processPortCreatedState(osNode);
+        }
+
+        @Override
+        public NodeState nextState() {
+            return COMPLETE;
+        }
+    },
+    /**
+     * Indicates node initialization is done.
+     */
+    COMPLETE {
+        @Override
+        public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
+            handler.processCompleteState(osNode);
+        }
+
+        @Override
+        public NodeState nextState() {
+            return COMPLETE;
+        }
+
+    },
+    /**
+     * Indicates node is broken.
+     */
+    INCOMPLETE {
+        @Override
+        public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
+            handler.processIncompleteState(osNode);
+        }
+
+        @Override
+        public NodeState nextState() {
+            return INIT;
+        }
+    };
+
+    public abstract void process(OpenstackNodeHandler handler, OpenstackNode osNode);
+    public abstract NodeState nextState();
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
new file mode 100644
index 0000000..d380ec5
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onosproject.core.GroupId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.group.GroupKey;
+
+/**
+ * Representation of a node used in OpenstackNetworking service.
+ */
+public interface OpenstackNode {
+
+    /**
+     * List of valid virtual network modes.
+     */
+    enum NetworkMode {
+        VXLAN,
+        VLAN
+    }
+
+    /**
+     * List of valid node types.
+     */
+    enum NodeType {
+        COMPUTE,
+        GATEWAY
+    }
+
+    /**
+     * Returns hostname of the node.
+     *
+     * @return hostname
+     */
+    String hostname();
+
+    /**
+     * Returns the type of the node.
+     *
+     * @return node type
+     */
+    NodeType type();
+
+    /**
+     * Returns the OVSDB device ID of the node.
+     *
+     * @return ovsdb device id
+     */
+    DeviceId ovsdb();
+
+    /**
+     * Returns the device ID of the integration bridge at the node.
+     *
+     * @return device id
+     */
+    DeviceId intgBridge();
+
+    /**
+     * Returns the router bridge device ID.
+     *
+     * @return device id; null if the node type is compute
+     */
+    DeviceId routerBridge();
+
+    /**
+     * Returns the management network IP address of the node.
+     *
+     * @return ip address
+     */
+    IpAddress managementIp();
+
+    /**
+     * Returns the data network IP address used for tunneling.
+     *
+     * @return ip address; null if vxlan mode is not enabled
+     */
+    IpAddress dataIp();
+
+    /**
+     * Returns the name of the vlan interface.
+     *
+     * @return vlan interface name; null if vlan mode is not enabled
+     */
+    String vlanIntf();
+
+    /**
+     * Returns the initialization state of the node.
+     *
+     * @return node state
+     */
+    NodeState state();
+
+    /**
+     * Returns the gateway group ID of this node.
+     *
+     * @param mode network mode of the group
+     * @return gateway group identifier
+     */
+    GroupId gatewayGroupId(NetworkMode mode);
+
+    /**
+     * Returns the group key of this node.
+     *
+     * @param mode network mode of the group
+     * @return gateway group key
+     */
+    GroupKey gatewayGroupKey(NetworkMode mode);
+
+    /**
+     * Returns the tunnel port number.
+     *
+     * @return port number; null if tunnel port does not exist
+     */
+    PortNumber tunnelPortNum();
+
+    /**
+     * Returns the vlan port nubmer.
+     *
+     * @return port number; null if vlan port does not exist
+     */
+    PortNumber vlanPortNum();
+
+    /**
+     * Returns the patch port number of the integration bridge.
+     *
+     * @return port number; null if the node type is compute
+     */
+    PortNumber patchPortNum();
+
+    /**
+     * Returns the vlan port MAC address.
+     *
+     * @return mac address; null if vlan port does not exist
+     */
+    MacAddress vlanPortMac();
+
+    /**
+     * Returns new openstack node instance with given state.
+     *
+     * @param newState updated state
+     * @return updated openstack node
+     */
+    OpenstackNode updateState(NodeState newState);
+
+    /**
+     * Builder of new node entities.
+     */
+    interface Builder {
+
+        /**
+         * Builds an immutable openstack node instance.
+         *
+         * @return openstack node instance
+         */
+        OpenstackNode build();
+
+        /**
+         * Returns openstack node builder with supplied hostname.
+         *
+         * @param hostname hostname of the node
+         * @return opesntack node builder
+         */
+        Builder hostname(String hostname);
+
+        /**
+         * Returns openstack node builder with supplied type.
+         *
+         * @param type openstack node type
+         * @return openstack node builder
+         */
+        Builder type(NodeType type);
+
+        /**
+         * Returns openstack node builder with supplied integration bridge ID.
+         *
+         * @param intgBridge integration bridge device id
+         * @return openstack node builder
+         */
+        Builder intgBridge(DeviceId intgBridge);
+
+        /**
+         * Returns openstack node builder with supplied router bridge ID.
+         *
+         * @param routerBridge router bridge id
+         * @return openstack node builder
+         */
+        Builder routerBridge(DeviceId routerBridge);
+
+        /**
+         * Returns openstack node builder with supplied management IP address.
+         *
+         * @param managementIp management ip address
+         * @return openstack node builder
+         */
+        Builder managementIp(IpAddress managementIp);
+
+        /**
+         * Returns openstack node builder with supplied data network IP address.
+         *
+         * @param dataIp data network ip address
+         * @return openstack node builder
+         */
+        Builder dataIp(IpAddress dataIp);
+
+        /**
+         * Returns openstack node builder with supplied vlan interface.
+         *
+         * @param vlanIntf vlan interface name
+         * @return openstack node builder
+         */
+        Builder vlanIntf(String vlanIntf);
+
+        /**
+         * Returns openstack node builder with supplied node state.
+         *
+         * @param state node state
+         * @return openstack node builder
+         */
+        Builder state(NodeState state);
+    }
+}
+
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java
new file mode 100644
index 0000000..cfef1aa
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+/**
+ * Service for administering inventory of opestackNode.
+ */
+public interface OpenstackNodeAdminService {
+
+    /**
+     * Creates a new node.
+     *
+     * @param osNode openstack node
+     */
+    void createNode(OpenstackNode osNode);
+
+    /**
+     * Updates the node.
+     *
+     * @param osNode openstack node
+     */
+    void updateNode(OpenstackNode osNode);
+
+    /**
+     * Removes the node.
+     *
+     * @param hostname openstack node hostname
+     * @return removed node; null if the node does not exist
+     */
+    OpenstackNode removeNode(String hostname);
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java
new file mode 100644
index 0000000..68ac50e
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Describes OpenStack node init state event.
+ */
+public class OpenstackNodeEvent extends AbstractEvent<OpenstackNodeEvent.Type, OpenstackNode> {
+
+    public enum Type {
+
+        /**
+         * Signifies that new node is created.
+         */
+        OPENSTACK_NODE_CREATED,
+
+        /**
+         * Signifies that the node state is updated.
+         */
+        OPENSTACK_NODE_UPDATED,
+
+        /**
+         * Signifies that the node state is complete.
+         */
+        OPENSTACK_NODE_COMPLETE,
+
+        /**
+         * Signifies that the node state is removed.
+         */
+        OPENSTACK_NODE_REMOVED,
+
+        /**
+         * Signifies that the node state is changed to incomplete.
+         */
+        OPENSTACK_NODE_INCOMPLETE
+    }
+
+    /**
+     * Creates an event with the given type and node.
+     *
+     * @param type event type
+     * @param node openstack node
+     */
+    public OpenstackNodeEvent(Type type, OpenstackNode node) {
+        super(type, node);
+    }
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
new file mode 100644
index 0000000..fa0bb33
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+/**
+ * Service handling openstack node state.
+ */
+public interface OpenstackNodeHandler {
+
+    /**
+     * Processes the given node for init state.
+     * It creates required bridges on OVS based on the node type.
+     *
+     * @param osNode openstack node
+     */
+    void processInitState(OpenstackNode osNode);
+
+    /**
+     * Processes the given node for device created state.
+     * It creates required ports on the bridges based on the node type.
+     *
+     * @param osNode openstack node
+     */
+    void processDeviceCreatedState(OpenstackNode osNode);
+
+    /**
+     * Processes the given node for port created state.
+     * It creates gateway groups on compute node.
+     *
+     * @param osNode openstack node
+     */
+    void processPortCreatedState(OpenstackNode osNode);
+
+    /**
+     * Processes the given node for complete state.
+     * It performs post-init jobs for the complete node.
+     *
+     * @param osNode openstack node
+     */
+    void processCompleteState(OpenstackNode osNode);
+
+    /**
+     * Processes the given node for incomplete state.
+     *
+     * @param osNode openstack node
+     */
+    void processIncompleteState(OpenstackNode osNode);
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java
new file mode 100644
index 0000000..b462624
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Listener for OpenstackNode event.
+ */
+public interface OpenstackNodeListener extends EventListener<OpenstackNodeEvent> {
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java
new file mode 100644
index 0000000..592593a
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+import org.onosproject.event.ListenerService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.openstacknode.api.OpenstackNode.NodeType;
+
+import java.util.Set;
+
+/**
+ * Service for interfacing with the inventory of {@link OpenstackNode}.
+ */
+public interface OpenstackNodeService extends ListenerService<OpenstackNodeEvent, OpenstackNodeListener> {
+
+    String APP_ID = "org.onosproject.openstacknode";
+
+    /**
+     * Returns all registered nodes.
+     *
+     * @return set of openstack nodes
+     */
+    Set<OpenstackNode> nodes();
+
+    /**
+     * Returns all nodes with the specified type.
+     *
+     * @param type node type
+     * @return set of openstack nodes
+     */
+    Set<OpenstackNode> nodes(NodeType type);
+
+    /**
+     * Returns all nodes with complete state.
+     *
+     * @return set of openstack nodes
+     */
+    Set<OpenstackNode> completeNodes();
+
+    /**
+     * Returns all nodes with complete state and the specified type.
+     *
+     * @param type node type
+     * @return set of openstack nodes
+     */
+    Set<OpenstackNode> completeNodes(NodeType type);
+
+    /**
+     * Returns the node with the specified hostname.
+     *
+     * @param hostname hostname
+     * @return openstack node
+     */
+    OpenstackNode node(String hostname);
+
+    /**
+     * Returns the node with the specified device ID.
+     * The device ID can be any one of integration bridge, router bridge,
+     * or ovsdb device.
+     *
+     * @param deviceId device id
+     * @return openstack node
+     */
+    OpenstackNode node(DeviceId deviceId);
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java
new file mode 100644
index 0000000..3a0a1ca
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+import org.onosproject.store.Store;
+
+import java.util.Set;
+
+/**
+ * Manages inventory of OpenstackNode; not intended for direct use.
+ */
+public interface OpenstackNodeStore extends Store<OpenstackNodeEvent, OpenstackNodeStoreDelegate> {
+
+    /**
+     * Creates a new node.
+     *
+     * @param osNode openstack node
+     */
+    void createNode(OpenstackNode osNode);
+
+    /**
+     * Updates the node.
+     *
+     * @param osNode openstack node
+     */
+    void updateNode(OpenstackNode osNode);
+
+    /**
+     * Removes the node.
+     *
+     * @param hostname openstack node hostname
+     * @return removed openstack node; null if no node mapped for the hostname
+     */
+    OpenstackNode removeNode(String hostname);
+
+    /**
+     * Returns all registered nodes.
+     *
+     * @return set of openstack nodes
+     */
+    Set<OpenstackNode> nodes();
+
+    /**
+     * Returns the node with the specified hostname.
+     *
+     * @param hostname hostname
+     * @return openstack node
+     */
+    OpenstackNode node(String hostname);
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java
new file mode 100644
index 0000000..34de865
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknode.api;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * OpenstackNode store delegate.
+ */
+public interface OpenstackNodeStoreDelegate extends StoreDelegate<OpenstackNodeEvent> {
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/package-info.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/package-info.java
new file mode 100644
index 0000000..3bf6709
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Application for bootstrapping Compute/Gateway Node in OpenStack.
+ */
+package org.onosproject.openstacknode.api;
\ No newline at end of file