[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/BUCK b/apps/openstacknode/BUCK
index e3a14bd..704f016 100644
--- a/apps/openstacknode/BUCK
+++ b/apps/openstacknode/BUCK
@@ -1,27 +1,13 @@
-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',
+BUNDLES = [
+ '//apps/openstacknode/api:onos-apps-openstacknode-api',
+ '//apps/openstacknode/app:onos-apps-openstacknode-app',
]
-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,
-)
-
onos_app (
title = 'OpenStack Node Bootstrap App',
category = 'Utility',
url = 'http://onosproject.org',
+ included_bundles = BUNDLES,
description = 'SONA Openstack Node Bootstrap Application.',
required_apps = [ 'org.onosproject.ovsdb-base', 'org.onosproject.drivers.ovsdb' ]
)
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/src/main/java/org/onosproject/openstacknode/api/Constants.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/Constants.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/NodeState.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/NodeState.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeAdminService.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeEvent.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeListener.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeService.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStore.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeStoreDelegate.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/package-info.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/package-info.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/package-info.java
rename to apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/package-info.java
diff --git a/apps/openstacknode/app/BUCK b/apps/openstacknode/app/BUCK
new file mode 100644
index 0000000..821cb71
--- /dev/null
+++ b/apps/openstacknode/app/BUCK
@@ -0,0 +1,28 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:org.apache.karaf.shell.console',
+ '//cli:onos-cli',
+ '//lib:javax.ws.rs-api',
+ '//utils/rest:onlab-rest',
+ '//protocols/ovsdb/api:onos-protocols-ovsdb-api',
+ '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
+ '//core/store/serializers:onos-core-serializers',
+ '//apps/openstacknode/api:onos-apps-openstacknode-api',
+]
+
+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,
+ web_context = '/onos/openstacknode',
+ api_title = 'OpenStack Node App API',
+ api_version = '1.0',
+ api_description = 'REST API for OpenStack Node App',
+ api_package = 'org.onosproject.openstacknode.web',
+)
+
diff --git a/apps/openstacknode/app/pom.xml b/apps/openstacknode/app/pom.xml
new file mode 100644
index 0000000..33bbfee
--- /dev/null
+++ b/apps/openstacknode/app/pom.xml
@@ -0,0 +1,128 @@
+<?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-app</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-apps-openstacknode-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0.1</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/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeInitCommand.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/cli/package-info.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/package-info.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/cli/package-info.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/package-info.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
similarity index 70%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
index 65d565a..ddd583e 100644
--- a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
@@ -30,12 +30,6 @@
import org.onosproject.core.CoreService;
import org.onosproject.event.ListenerRegistry;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.openstacknode.api.OpenstackNodeConfig;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackNodeAdminService;
import org.onosproject.openstacknode.api.OpenstackNodeEvent;
@@ -87,22 +81,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LeadershipService leadershipService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected NetworkConfigRegistry configRegistry;
-
private final ExecutorService eventExecutor = newSingleThreadExecutor(
groupedThreads(this.getClass().getSimpleName(), "event-handler", log));
- private final ConfigFactory configFactory =
- new ConfigFactory<ApplicationId, OpenstackNodeConfig>(
- SubjectFactories.APP_SUBJECT_FACTORY, OpenstackNodeConfig.class, "openstacknode") {
- @Override
- public OpenstackNodeConfig createConfig() {
- return new OpenstackNodeConfig();
- }
- };
-
- private final NetworkConfigListener configListener = new InternalConfigListener();
private final OpenstackNodeStoreDelegate delegate = new InternalNodeStoreDelegate();
private ApplicationId appId;
@@ -116,18 +97,12 @@
localNode = clusterService.getLocalNode().id();
leadershipService.runForLeadership(appId.name());
- configRegistry.registerConfigFactory(configFactory);
- configRegistry.addListener(configListener);
-
- readConfiguration();
log.info("Started");
}
@Deactivate
protected void deactivate() {
osNodeStore.unsetDelegate(delegate);
- configRegistry.removeListener(configListener);
- configRegistry.unregisterConfigFactory(configFactory);
leadershipService.withdraw(appId.name());
eventExecutor.shutdown();
@@ -212,53 +187,4 @@
}
}
}
-
- private void readConfiguration() {
- OpenstackNodeConfig config = configRegistry.getConfig(appId, OpenstackNodeConfig.class);
- if (config == null) {
- log.debug("No configuration found");
- return;
- }
-
- log.info("Read openstack node configurations...");
- Set<String> hostnames = config.openstackNodes().stream()
- .map(OpenstackNode::hostname)
- .collect(Collectors.toSet());
- nodes().stream().filter(osNode -> !hostnames.contains(osNode.hostname()))
- .forEach(osNode -> removeNode(osNode.hostname()));
-
- config.openstackNodes().forEach(osNode -> {
- OpenstackNode existing = node(osNode.hostname());
- if (existing == null) {
- createNode(osNode);
- } else if (!existing.equals(osNode)) {
- updateNode(osNode);
- }
- });
- }
-
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- NodeId leaderNodeId = leadershipService.getLeader(appId.name());
- if (!Objects.equals(localNode, leaderNodeId)) {
- // do not allow to proceed without leadership
- return;
- }
-
- if (!event.configClass().equals(OpenstackNodeConfig.class)) {
- return;
- }
-
- switch (event.type()) {
- case CONFIG_ADDED:
- case CONFIG_UPDATED:
- eventExecutor.execute(OpenstackNodeManager.this::readConfiguration);
- break;
- default:
- break;
- }
- }
- }
}
diff --git a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/package-info.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/package-info.java
similarity index 100%
rename from apps/openstacknode/src/main/java/org/onosproject/openstacknode/impl/package-info.java
rename to apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/package-info.java
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
new file mode 100644
index 0000000..cce5134
--- /dev/null
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
@@ -0,0 +1,164 @@
+/*
+ * 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.web;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.google.common.collect.Sets;
+import org.onlab.osgi.DefaultServiceDirectory;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.openstacknode.api.NodeState;
+import org.onosproject.openstacknode.api.OpenstackNode;
+import org.onosproject.openstacknode.api.OpenstackNodeAdminService;
+import org.onosproject.openstacknode.api.OpenstackNodeService;
+import org.onosproject.openstacknode.impl.DefaultOpenstackNode;
+import org.onosproject.rest.AbstractWebResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+import java.io.InputStream;
+import java.util.Set;
+
+import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
+import static javax.ws.rs.core.Response.created;
+
+@Path("configure")
+public class OpenstackNodeWebResource extends AbstractWebResource {
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private static final String MESSAGE_NODE = "Received node %s request";
+ private static final String NODES = "nodes";
+
+ private final OpenstackNodeAdminService osNodeAdminService =
+ DefaultServiceDirectory.getService(OpenstackNodeAdminService.class);
+ private final OpenstackNodeService osNodeService =
+ DefaultServiceDirectory.getService(OpenstackNodeService.class);
+
+ @Context
+ private UriInfo uriInfo;
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response createNodes(InputStream input) {
+ log.trace(String.format(MESSAGE_NODE, "CREATE"));
+
+ readNodeConfiguration(input).forEach(osNode -> {
+ OpenstackNode existing = osNodeService.node(osNode.hostname());
+ if (existing == null) {
+ osNodeAdminService.createNode(osNode);
+ }
+ });
+
+ UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
+ .path(NODES)
+ .path("NODE_ID");
+
+ return created(locationBuilder.build()).build();
+ }
+
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response updateNodes(InputStream input) {
+ log.trace(String.format(MESSAGE_NODE, "UPDATE"));
+
+ Set<OpenstackNode> nodes = readNodeConfiguration(input);
+ for (OpenstackNode osNode: nodes) {
+ OpenstackNode existing = osNodeService.node(osNode.hostname());
+ if (existing == null) {
+ log.warn("There is no node configuration to update : {}", osNode.hostname());
+ return Response.notModified().build();
+ } else if (!existing.equals(osNode)) {
+ osNodeAdminService.updateNode(osNode);
+ }
+ }
+
+ return Response.ok().build();
+ }
+
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response deleteNodes(InputStream input) {
+ log.trace(String.format(MESSAGE_NODE, "DELETE"));
+
+ Set<OpenstackNode> nodes = readNodeConfiguration(input);
+ for (OpenstackNode osNode: nodes) {
+ OpenstackNode existing = osNodeService.node(osNode.hostname());
+ if (existing == null) {
+ log.warn("There is no node configuration to delete : {}", osNode.hostname());
+ return Response.notModified().build();
+ } else {
+ osNodeAdminService.removeNode(osNode.hostname());
+ }
+ }
+
+ return Response.ok().build();
+ }
+
+ private Set<OpenstackNode> readNodeConfiguration(InputStream input) {
+ Set<OpenstackNode> nodeSet = Sets.newHashSet();
+ try {
+ JsonNode jsonTree = mapper().enable(INDENT_OUTPUT).readTree(input);
+ ArrayNode nodes = (ArrayNode) jsonTree.path("nodes");
+ nodes.forEach(node -> {
+ try {
+ String hostname = node.get("hostname").asText();
+ String type = node.get("type").asText();
+ String mIp = node.get("managementIp").asText();
+ String dIp = node.get("dataIp").asText();
+ String iBridge = node.get("integrationBridge").asText();
+ String rBridge = null;
+ if (node.get("routerBridge") != null) {
+ rBridge = node.get("routerBridge").asText();
+ }
+ DefaultOpenstackNode.Builder nodeBuilder = DefaultOpenstackNode.builder()
+ .hostname(hostname)
+ .type(OpenstackNode.NodeType.valueOf(type))
+ .managementIp(IpAddress.valueOf(mIp))
+ .dataIp(IpAddress.valueOf(dIp))
+ .intgBridge(DeviceId.deviceId(iBridge))
+ .state(NodeState.INIT);
+ if (rBridge != null) {
+ nodeBuilder.routerBridge(DeviceId.deviceId(rBridge));
+ }
+ log.trace("node is {}", nodeBuilder.build().toString());
+ nodeSet.add(nodeBuilder.build());
+ } catch (Exception e) {
+ log.error(e.toString());
+ throw new IllegalArgumentException();
+ }
+ });
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ return nodeSet;
+ }
+}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/package-info.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/package-info.java
new file mode 100644
index 0000000..85d6a61
--- /dev/null
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/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.web;
\ No newline at end of file
diff --git a/apps/openstacknode/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/openstacknode/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
similarity index 100%
rename from apps/openstacknode/src/main/resources/OSGI-INF/blueprint/shell-config.xml
rename to apps/openstacknode/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
diff --git a/apps/openstacknode/app/src/main/webapp/WEB-INF/web.xml b/apps/openstacknode/app/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..583cd55
--- /dev/null
+++ b/apps/openstacknode/app/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="ONOS" version="2.5">
+ <display-name>Openstack Node REST API v1.0</display-name>
+
+ <servlet>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>jersey.config.server.provider.classnames</param-name>
+ <param-value>
+ org.onosproject.openstacknode.web.OpenstackNodeWebResource
+ </param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
similarity index 100%
rename from apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
rename to apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
diff --git a/apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java
similarity index 100%
rename from apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java
rename to apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java
diff --git a/apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
similarity index 95%
rename from apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
rename to apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
index 6dd481d..69a0f9d 100644
--- a/apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
@@ -29,7 +29,6 @@
import org.onosproject.core.DefaultApplicationId;
import org.onosproject.event.Event;
import org.onosproject.net.Device;
-import org.onosproject.net.config.NetworkConfigRegistryAdapter;
import org.onosproject.openstacknode.api.NodeState;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackNodeEvent;
@@ -43,7 +42,11 @@
import static org.junit.Assert.assertTrue;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
-import static org.onosproject.openstacknode.api.OpenstackNodeEvent.Type.*;
+import static org.onosproject.openstacknode.api.OpenstackNodeEvent.Type.OPENSTACK_NODE_COMPLETE;
+import static org.onosproject.openstacknode.api.OpenstackNodeEvent.Type.OPENSTACK_NODE_CREATED;
+import static org.onosproject.openstacknode.api.OpenstackNodeEvent.Type.OPENSTACK_NODE_INCOMPLETE;
+import static org.onosproject.openstacknode.api.OpenstackNodeEvent.Type.OPENSTACK_NODE_REMOVED;
+import static org.onosproject.openstacknode.api.OpenstackNodeEvent.Type.OPENSTACK_NODE_UPDATED;
/**
* Unit tests for OpenStack node manager.
@@ -114,11 +117,10 @@
osNodeStore.createNode(COMPUTE_3);
osNodeStore.createNode(GATEWAY_1);
- target = new OpenstackNodeManager();
+ target = new org.onosproject.openstacknode.impl.OpenstackNodeManager();
target.coreService = new TestCoreService();
target.clusterService = new TestClusterService();
target.leadershipService = new TestLeadershipService();
- target.configRegistry = new TestConfigService();
target.osNodeStore = osNodeStore;
target.addListener(testListener);
target.activate();
@@ -317,10 +319,6 @@
}
}
- private class TestConfigService extends NetworkConfigRegistryAdapter {
-
- }
-
private class TestClusterService extends ClusterServiceAdapter {
}
diff --git a/apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
similarity index 94%
rename from apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
rename to apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
index d551efb..3cb336a 100644
--- a/apps/openstacknode/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
@@ -46,7 +46,7 @@
protected static OpenstackNode createNode(String hostname, NodeType type,
Device intgBridge, IpAddress ipAddr,
NodeState state) {
- return DefaultOpenstackNode.builder()
+ return org.onosproject.openstacknode.impl.DefaultOpenstackNode.builder()
.hostname(hostname)
.type(type)
.intgBridge(intgBridge.id())
@@ -59,7 +59,7 @@
protected static OpenstackNode createNode(String hostname, NodeType type,
Device intgBridge, Device routerBridge,
IpAddress ipAddr, NodeState state) {
- return DefaultOpenstackNode.builder()
+ return org.onosproject.openstacknode.impl.DefaultOpenstackNode.builder()
.hostname(hostname)
.type(type)
.intgBridge(intgBridge.id())
diff --git a/apps/openstacknode/pom.xml b/apps/openstacknode/pom.xml
index cfb5e07..c2ab487 100644
--- a/apps/openstacknode/pom.xml
+++ b/apps/openstacknode/pom.xml
@@ -26,83 +26,14 @@
</parent>
<artifactId>onos-apps-openstacknode</artifactId>
- <packaging>bundle</packaging>
+ <packaging>pom</packaging>
<description>SONA Openstack Node Bootstrap Application</description>
+ <modules>
+ <module>api</module>
+ <module>app</module>
+ </modules>
- <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-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-ovsdb-api</artifactId>
- </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/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeConfig.java b/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeConfig.java
deleted file mode 100644
index 774342a..0000000
--- a/apps/openstacknode/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeConfig.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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();
- }
-}