<controller.mdsal.version>1.5.0-SNAPSHOT</controller.mdsal.version>
<mdsal.model.version>0.10.0-SNAPSHOT</mdsal.model.version>
<restconf.version>1.5.0-SNAPSHOT</restconf.version>
+ <ovsdb.version>1.4.0-SNAPSHOT</ovsdb.version>
</properties>
<dependencyManagement>
<dependencies>
<artifactId>neutron-logger</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>southbound-features</artifactId>
+ <version>${ovsdb.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.mdsal-utils</artifactId>
+ <version>${ovsdb.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>neutron-hostconfig-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>neutron-hostconfig-ovs</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/neutron.git</connection>
<repository>mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features</repository>
+ <repository>mvn:org.opendaylight.ovsdb/southbound-features/{{VERSION}}/xml/features</repository>
<repository>mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features</repository>
<feature name='odl-neutron-service' version='${project.version}' description="OpenDaylight :: Neutron :: API">
<feature version='${project.version}'>odl-neutron-spi</feature>
<bundle>mvn:org.opendaylight.neutron/neutron-logger/{{VERSION}}</bundle>
<bundle>mvn:org.osgi/org.osgi.core/{{VERSION}}</bundle>
</feature>
+ <feature name='odl-neutron-hostconfig-ovs' version='${project.version}' description="OpenDaylight :: Neutron :: HostconfigOvs">
+ <feature version='${controller.mdsal.version}'>odl-mdsal-broker</feature>
+ <feature version="${ovsdb.version}">odl-ovsdb-southbound-api</feature>
+ <bundle>mvn:org.opendaylight.neutron/model/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.southbound-utils/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.neutron/neutron-hostconfig-utils/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.neutron/neutron-hostconfig-ovs/{{VERSION}}</bundle>
+ <bundle>mvn:org.osgi/org.osgi.core/{{VERSION}}</bundle>
+ </feature>
</features>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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.opendaylight.controller</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>neutron-hostconfig-ovs</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <properties>
+ <checkstyle.location>${project.parent.basedir}/src/main/resources</checkstyle.location>
+ </properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>mdsal-model-artifacts</artifactId>
+ <version>0.10.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>neutron-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.mdsal-utils</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.southbound-utils</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>neutron-hostconfig-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-api</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <compilerArgs>
+ <arg>-Xlint:unchecked</arg>
+ <arg>-Xlint:deprecation</arg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/neutron.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/neutron.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/NeutronNorthBound:Main</url>
+ </scm>
+ <distributionManagement>
+ <!-- Site deployment -->
+ <site>
+ <id>opendaylight-site</id>
+ <url>${nexus.site.url}/${project.artifactId}/</url>
+ </site>
+ </distributionManagement>
+
+ <!--
+ Maven Site Configuration
+
+ The following configuration is necessary for maven-site-plugin to
+ correctly identify the correct deployment path for OpenDaylight Maven
+ sites.
+ -->
+ <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2017 Intel Corporation. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.hostconfig.ovs;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+
+import java.util.Collection;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.neutron.hostconfig.utils.NeutronHostconfigUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronHostconfigOvsListener implements ClusteredDataTreeChangeListener<Node>, AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronHostconfigOvsListener.class);
+ private final DataBroker dataBroker;
+ private final SouthboundUtils southboundUtils;
+ private final NeutronHostconfigUtils neutronHostconfig;
+ private ListenerRegistration<DataTreeChangeListener<Node>> listenerRegistration;
+ private static final String OS_HOST_CONFIG_HOST_ID_KEY = "odl_os_hostconfig_hostid";
+ private static final String OS_HOST_CONFIG_CONFIG_KEY_PREFIX = "odl_os_hostconfig_config_odl_";
+ private static int HOST_TYPE_STR_LEN = 8;
+
+ public NeutronHostconfigOvsListener(final DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
+ this.southboundUtils = new SouthboundUtils(mdsalUtils);
+ this.neutronHostconfig = new NeutronHostconfigUtils(dataBroker);
+ }
+
+ private void processChanges(Collection<DataTreeModification<Node>> changes) {
+ LOG.info("onDataTreeChanged: Received Data Tree Changed ...", changes);
+ for (DataTreeModification<Node> change : changes) {
+ final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
+ final DataObjectModification<Node> mod = change.getRootNode();
+ LOG.info("onDataTreeChanged: Received Data Tree Changed Update of Type={} for Key={}",
+ mod.getModificationType(), key);
+ switch (mod.getModificationType()) {
+ case DELETE:
+ updateHostConfig(mod.getDataAfter(), NeutronHostconfigUtils.Action.DELETE);
+ break;
+ case SUBTREE_MODIFIED:
+ updateHostConfig(mod.getDataAfter(), NeutronHostconfigUtils.Action.UPDATE);
+ break;
+ case WRITE:
+ updateHostConfig(mod.getDataAfter(), NeutronHostconfigUtils.Action.ADD);
+ break;
+ default:
+ LOG.error("onDataTreeChanged: Invalid modification type={}",
+ mod.getModificationType());
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes) {
+ Preconditions.checkNotNull(changes, "Changes may not be null!");
+ processChanges(changes);
+ }
+
+ private InstanceIdentifier<Node> createNodeIdentifier() {
+ return InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID))
+ .child(Node.class);
+ }
+
+ public void init() {
+ LOG.info("{} start", getClass().getSimpleName());
+ DataTreeIdentifier<Node> dataTreeIdentifier =
+ new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, createNodeIdentifier());
+ LOG.info("Neutron Hostconfig DataChange listener registration {}", dataTreeIdentifier);
+ listenerRegistration = dataBroker.registerDataTreeChangeListener(dataTreeIdentifier, this);
+ }
+
+ public void close() throws Exception {
+ if (listenerRegistration != null) {
+ listenerRegistration.close();
+ LOG.trace("HostConfig listener Closed");
+ }
+ }
+
+ private void updateHostConfig(Node node, NeutronHostconfigUtils.Action action) {
+ String hostId = getExternalId(node, OS_HOST_CONFIG_HOST_ID_KEY);
+ if (hostId == null) {
+ return;
+ }
+ for (Map.Entry<String, String> entry : extractHostConfig(node).entrySet()) {
+ neutronHostconfig.updateMdsal(neutronHostconfig.buildHostConfigInfo(hostId, entry.getKey(),
+ entry.getValue()), action);
+ }
+ }
+
+ private Map<String, String> extractHostConfig(Node node) {
+ Map<String, String> config = Maps.newHashMap();
+ OvsdbNodeAugmentation ovsdbNode = getOvsdbNodeAugmentation(node);
+ if (ovsdbNode != null && ovsdbNode.getOpenvswitchExternalIds() != null) {
+ for (OpenvswitchExternalIds openvswitchExternalIds : ovsdbNode.getOpenvswitchExternalIds()) {
+ if (openvswitchExternalIds.getExternalIdKey().startsWith(OS_HOST_CONFIG_CONFIG_KEY_PREFIX)) {
+ // Extract the host type. Max 8 characters after
+ // suffix OS_HOST_CONFIG_CONFIG_KEY_PREFIX.length()
+ String hostType = openvswitchExternalIds.getExternalIdKey().substring(
+ OS_HOST_CONFIG_CONFIG_KEY_PREFIX.length());
+ if (null != hostType && hostType.length() > 0) {
+ if (hostType.length() > HOST_TYPE_STR_LEN) {
+ hostType = hostType.substring(0, HOST_TYPE_STR_LEN);
+ }
+ hostType = "ODL " + hostType.toUpperCase();
+ if (null != openvswitchExternalIds.getExternalIdValue()) {
+ config.put(hostType, openvswitchExternalIds.getExternalIdValue());
+ }
+ }
+ }
+ }
+ }
+ return config;
+ }
+
+ private String getExternalId(Node node, String key) {
+ OvsdbNodeAugmentation ovsdbNode = getOvsdbNodeAugmentation(node);
+ if (ovsdbNode != null && ovsdbNode.getOpenvswitchExternalIds() != null) {
+ for (OpenvswitchExternalIds openvswitchExternalIds : ovsdbNode.getOpenvswitchExternalIds()) {
+ if (openvswitchExternalIds.getExternalIdKey().equals(key)) {
+ return openvswitchExternalIds.getExternalIdValue();
+ }
+ }
+ }
+ return null;
+ }
+
+ private OvsdbNodeAugmentation getOvsdbNodeAugmentation(Node node) {
+ OvsdbNodeAugmentation ovsdbNode = southboundUtils.extractOvsdbNode(node);
+ if (ovsdbNode == null) {
+ Node nodeFromReadOvsdbNode = southboundUtils.readOvsdbNode(node);
+ if (nodeFromReadOvsdbNode != null) {
+ ovsdbNode = southboundUtils.extractOvsdbNode(nodeFromReadOvsdbNode);
+ }
+ }
+ return ovsdbNode;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default" />
+
+ <bean id="neutronHostconfigOvs"
+ class="org.opendaylight.neutron.hostconfig.ovs.NeutronHostconfigOvsListener"
+ init-method="init"
+ destroy-method="close">
+ <argument ref="dataBroker"/>
+ </bean>
+
+</blueprint>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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.opendaylight.controller</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>neutron-hostconfig</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>utils</module>
+ <module>ovs</module>
+ </modules>
+ <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!--
+ Maven Site Configuration
+ The following configuration is necessary for maven-site-plugin to
+ correctly identify the correct deployment path for OpenDaylight Maven
+ sites.
+ -->
+ <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+
+ <distributionManagement>
+ <site>
+ <id>opendaylight-site</id>
+ <url>${nexus.site.url}/${project.artifactId}/</url>
+ </site>
+ </distributionManagement>
+</project>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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.opendaylight.controller</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>neutron-hostconfig-utils</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <properties>
+ <checkstyle.location>${project.parent.basedir}/src/main/resources</checkstyle.location>
+ </properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>mdsal-model-artifacts</artifactId>
+ <version>0.10.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.neutron</groupId>
+ <artifactId>model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-api</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <compilerArgs>
+ <arg>-Xlint:unchecked</arg>
+ <arg>-Xlint:deprecation</arg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/neutron.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/neutron.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/NeutronNorthBound:Main</url>
+ </scm>
+ <distributionManagement>
+ <!-- Site deployment -->
+ <site>
+ <id>opendaylight-site</id>
+ <url>${nexus.site.url}/${project.artifactId}/</url>
+ </site>
+ </distributionManagement>
+
+ <!--
+ Maven Site Configuration
+
+ The following configuration is necessary for maven-site-plugin to
+ correctly identify the correct deployment path for OpenDaylight Maven
+ sites.
+ -->
+ <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+</project>
+
--- /dev/null
+/*
+ * Copyright (c) 2017 Intel Corporation and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.hostconfig.utils;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.Hostconfigs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.HostconfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronHostconfigUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(NeutronHostconfigUtils.class);
+ private final DataBroker dataBroker;
+
+ public enum Action {
+ ADD,
+ UPDATE,
+ DELETE
+ }
+
+ public NeutronHostconfigUtils(final DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
+
+ public void updateMdsal(Hostconfig hostConfig, Action action) {
+ InstanceIdentifier<Hostconfig> hostConfigId;
+ if (hostConfig == null) {
+ return;
+ }
+ try {
+ switch (action) {
+ case ADD:
+ case UPDATE:
+ final WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ hostConfigId = createInstanceIdentifier(hostConfig);
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, hostConfigId, hostConfig, true);
+ writeTx.submit().get();
+ break;
+ case DELETE:
+ final WriteTransaction delTx = dataBroker.newWriteOnlyTransaction();
+ hostConfigId = createInstanceIdentifier(hostConfig);
+ delTx.delete(LogicalDatastoreType.OPERATIONAL, hostConfigId);
+ delTx.submit().get();
+ break;
+ default:
+ break;
+ }
+ } catch (Exception e) {
+ LOG.warn("Hostconfig transaction commit failed to DS.", e);
+ }
+ }
+
+ public Hostconfig buildHostConfigInfo(String hostId, String hostType, String hostConfig) {
+ HostconfigBuilder hostconfigBuilder = new HostconfigBuilder();
+ hostconfigBuilder.setHostId(hostId);
+ hostconfigBuilder.setHostType(hostType);
+ hostconfigBuilder.setConfig(hostConfig);
+ return hostconfigBuilder.build();
+ }
+
+ private InstanceIdentifier<Hostconfig> createInstanceIdentifier(Hostconfig hostconfig) {
+ return InstanceIdentifier.create(Neutron.class).child(Hostconfigs.class)
+ .child(Hostconfig.class, hostconfig.getKey());
+ }
+}
<module>karaf</module>
<module>integration/test</module>
<module>model</module>
+ <module>neutron-hostconfig</module>
</modules>
<build>
<plugins>