ONOS-6742 Refactored OpenstackNode
- Removed gateway node uplink interface configuration steps
- Added checking group states
- Refactored interface, store, manager and handler
Change-Id: I9149edbec6481b15377848c8f24bdc5c6c73adc4
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/Constants.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/Constants.java
new file mode 100644
index 0000000..9f812db
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/NodeState.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/NodeState.java
new file mode 100644
index 0000000..6d3a825
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
new file mode 100644
index 0000000..d380ec5
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java
new file mode 100644
index 0000000..cfef1aa
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeConfig.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeConfig.java
new file mode 100644
index 0000000..774342a
--- /dev/null
+++ b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeConfig.java
@@ -0,0 +1,128 @@
+/*
+ * 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 com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Sets;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.config.Config;
+import org.onosproject.openstacknode.impl.DefaultOpenstackNode;
+
+import java.util.Set;
+
+import static org.onosproject.net.config.Config.FieldPresence.MANDATORY;
+import static org.onosproject.net.config.Config.FieldPresence.OPTIONAL;
+import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
+
+/**
+ * Configuration object for OpensatckNode service.
+ */
+public final class OpenstackNodeConfig extends Config<ApplicationId> {
+
+ private static final String NODES = "nodes";
+ private static final String HOST_NAME = "hostname";
+ private static final String TYPE = "type";
+ private static final String MANAGEMENT_IP = "managementIp";
+ private static final String DATA_IP = "dataIp";
+ private static final String INTEGRATION_BRIDGE = "integrationBridge";
+
+ // GATEWAY node specific fields
+ private static final String ROUTER_BRIDGE = "routerBridge";
+ private static final String VLAN_INTF_NAME = "vlanPort";
+
+ @Override
+ public boolean isValid() {
+ boolean result = hasOnlyFields(NODES);
+ if (object.get(NODES) == null || object.get(NODES).size() < 1) {
+ return true;
+ }
+
+ for (JsonNode node : object.get(NODES)) {
+ if (get(node, DATA_IP) == null && get(node, VLAN_INTF_NAME) == null) {
+ final String msg = "There is neither tunnel interface nor vlan port";
+ throw new IllegalArgumentException(msg);
+ }
+ ObjectNode osNode = (ObjectNode) node;
+ result &= hasOnlyFields(osNode,
+ HOST_NAME,
+ TYPE,
+ MANAGEMENT_IP,
+ DATA_IP,
+ INTEGRATION_BRIDGE,
+ ROUTER_BRIDGE,
+ VLAN_INTF_NAME
+ );
+
+ result &= isString(osNode, HOST_NAME, MANDATORY);
+ result &= isString(osNode, TYPE, MANDATORY);
+ result &= isIpAddress(osNode, MANAGEMENT_IP, MANDATORY);
+ result &= isString(osNode, INTEGRATION_BRIDGE, MANDATORY);
+ result &= isString(osNode, VLAN_INTF_NAME, OPTIONAL);
+ result &= isIpAddress(osNode, DATA_IP, OPTIONAL);
+
+ DeviceId.deviceId(osNode.get(INTEGRATION_BRIDGE).asText());
+ OpenstackNode.NodeType.valueOf(osNode.get(TYPE).asText());
+
+ if (osNode.get(TYPE).asText().equals(GATEWAY.name())) {
+ result &= isString(osNode, ROUTER_BRIDGE, MANDATORY);
+ DeviceId.deviceId(osNode.get(ROUTER_BRIDGE).asText());
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns the set of nodes read from network config.
+ *
+ * @return set of openstack nodes
+ */
+ public Set<OpenstackNode> openstackNodes() {
+ Set<OpenstackNode> nodes = Sets.newHashSet();
+ for (JsonNode node : object.get(NODES)) {
+ OpenstackNode.NodeType type = OpenstackNode.NodeType.valueOf(get(node, TYPE));
+ OpenstackNode.Builder nodeBuilder = DefaultOpenstackNode.builder()
+ .intgBridge(DeviceId.deviceId(get(node, INTEGRATION_BRIDGE)))
+ .managementIp(IpAddress.valueOf(get(node, MANAGEMENT_IP)))
+ .type(type)
+ .hostname(get(node, HOST_NAME))
+ .state(NodeState.INIT);
+
+ if (get(node, DATA_IP) != null) {
+ nodeBuilder.dataIp(IpAddress.valueOf(get(node, DATA_IP)));
+ }
+ if (get(node, VLAN_INTF_NAME) != null) {
+ nodeBuilder.vlanIntf(get(node, VLAN_INTF_NAME));
+ }
+ if (type.equals(GATEWAY)) {
+ nodeBuilder.routerBridge(DeviceId.deviceId(get(node, ROUTER_BRIDGE)));
+ }
+ nodes.add(nodeBuilder.build());
+ }
+ return nodes;
+ }
+
+ private String get(JsonNode jsonNode, String path) {
+ JsonNode jNode = jsonNode.get(path);
+ if (jNode == null || jNode.isMissingNode()) {
+ return null;
+ }
+ return jNode.asText();
+ }
+}
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java
new file mode 100644
index 0000000..68ac50e
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
new file mode 100644
index 0000000..fa0bb33
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java
new file mode 100644
index 0000000..b462624
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java
new file mode 100644
index 0000000..592593a
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java
new file mode 100644
index 0000000..3a0a1ca
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java
new file mode 100644
index 0000000..34de865
--- /dev/null
+++ b/apps/openstacknode/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/src/main/java/org/onosproject/openstacknode/api/package-info.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/package-info.java
new file mode 100644
index 0000000..3bf6709
--- /dev/null
+++ b/apps/openstacknode/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