<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-netconf</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-config</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-xml-adapter</artifactId>
+ <artifactId>config-manager-facade-xml</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-impl</artifactId>
+ <artifactId>config-util</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-feature-adapter</artifactId>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>netconf-util</artifactId>
+ <artifactId>config-persister-impl</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>netconf-mapping-api</artifactId>
+ <artifactId>config-persister-feature-adapter</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.controller/features-netconf/${netconf.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-config/${config.version}/xml/features</repository>
<feature name='odl-config-persister-all' version='${project.version}' description="OpenDaylight :: Config Persister:: All">
<feature version='${project.version}'>odl-config-persister</feature>
<feature version='${project.version}'>odl-config-startup</feature>
</feature>
<feature name='odl-config-persister' version='${project.version}' description="OpenDaylight :: Config Persister ">
- <feature version='${netconf.version}'>odl-netconf-api</feature>
<feature version='${project.version}'>odl-config-api</feature>
+ <feature version='${project.version}'>odl-config-core</feature>
+ <feature version='${project.version}'>odl-config-manager</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding-generator</feature>
+ <bundle>mvn:org.opendaylight.controller/yang-jmx-generator/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/config-persister-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/config-util/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/config-manager-facade-xml/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/config-persister-file-xml-adapter/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/config-persister-impl/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/config-persister-feature-adapter/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netconf-util/${netconf.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netconf-mapping-api/${netconf.version}</bundle>
<bundle>mvn:com.google.guava/guava/${guava.version}</bundle>
<bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
<bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version}</bundle>
</feature>
<feature name='odl-config-startup' version='${project.version}' description="OpenDaylight :: Config Persister:: Config Startup">
- <feature version='${project.version}'>odl-config-netconf-connector</feature>
<feature version='${project.version}'>odl-config-persister</feature>
- <feature version='${project.version}'>odl-netconf-impl</feature>
+ </feature>
+ <feature name='odl-config-manager-facade-xml' version='${project.version}' description="Opendaylight :: Config Persister:: Mapping for Config Subsystem">
+ <feature version='${project.version}'>odl-config-core</feature>
+ <bundle>mvn:org.opendaylight.controller/config-manager-facade-xml/${project.version}</bundle>
</feature>
</features>
<bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-common/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
+ <bundle>mvn:io.netty/netty-codec/${netty.version}</bundle>
+ <bundle>mvn:io.netty/netty-handler/${netty.version}</bundle>
</feature>
<feature name='odl-config-core' version='${project.version}' description="OpenDaylight :: Config :: Core">
<feature version='${yangtools.version}'>odl-yangtools-binding</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding-generator</feature>
<feature version='${project.version}'>odl-config-api</feature>
+ <bundle>mvn:org.opendaylight.yangtools/yang-model-api/${yangtools.version}</bundle>
<bundle>mvn:org.opendaylight.controller/config-util/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/yang-jmx-generator/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/shutdown-api/${project.version}</bundle>
<classifier>features</classifier>
<type>xml</type>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-netconf</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-config-persister</artifactId>
<artifactId>sal-distributed-datastore</artifactId>
</dependency>
+ <!-- message-bus -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
+ <artifactId>messagebus-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>messagebus-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>messagebus-config</artifactId>
+ <version>${mdsal.version}</version>
+ <type>xml</type>
+ <classifier>config</classifier>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-netconf-connector</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-netconf-monitoring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>netconf-mdsal-config</artifactId>
- <version>${netconf.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-netconf-connector</artifactId>
+ <artifactId>sal-inmemory-datastore</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-rest-docgen</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>netconf-config-dispatcher</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>netconf-connector-config</artifactId>
- <version>${netconf.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>netconf-ssh</artifactId>
- </dependency>
-
<dependency>
<groupId>org.opendaylight.controller.model</groupId>
<artifactId>model-inventory</artifactId>
<repository>mvn:org.opendaylight.controller/features-config/${config.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-config-persister/${config.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-config-netty/${config.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.controller/features-netconf/${netconf.version}/xml/features</repository>
<repository>mvn:org.opendaylight.controller/features-akka/${commons.opendaylight.version}/xml/features</repository>
<feature name='odl-mdsal-all' version='${project.version}' description="OpenDaylight :: MDSAL :: All">
<feature version='${project.version}'>odl-mdsal-broker</feature>
<bundle>mvn:org.opendaylight.controller/sal-common-util/${mdsal.version}</bundle>
</feature>
- <!-- TODO move to netconf features, however there are some weird dependencies on features-config-persister all over that cause cyclic dependencies-->
- <feature name='odl-netconf-mdsal' version='${project.version}' description="OpenDaylight :: Netconf :: Mdsal">
- <feature version='${config.version}'>odl-config-all</feature>
- <feature version='${netconf.version}'>odl-netconf-all</feature>
- <feature version='${config.version}'>odl-config-netty</feature>
- <bundle>mvn:org.opendaylight.controller/netconf-tcp/${netconf.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netconf-ssh/${netconf.version}</bundle>
- <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
- <bundle>mvn:org.opendaylight.controller/mdsal-netconf-connector/${netconf.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/mdsal-netconf-monitoring/${netconf.version}</bundle>
- <!-- TODO 01-netconf.xml file requires netconf-config-dispatcher to be present and its part of netconf-connector features. Clean Up-->
- <bundle>mvn:org.opendaylight.controller/netconf-config-dispatcher/${config.version}</bundle>
- <configfile finalname='${config.configfile.directory}/${config.netconf.client.configfile}'>mvn:org.opendaylight.controller/netconf-config/${netconf.version}/xml/config</configfile>
- <configfile finalname='${config.configfile.directory}/${config.netconf.mdsal.configfile}'>mvn:org.opendaylight.controller/netconf-mdsal-config/${netconf.version}/xml/config</configfile>
- </feature>
-
<feature name='odl-mdsal-broker-local' version='${project.version}' description="OpenDaylight :: MDSAL :: Broker">
<feature version='${yangtools.version}'>odl-yangtools-common</feature>
<feature version='${yangtools.version}'>odl-yangtools-binding</feature>
<bundle>mvn:org.opendaylight.controller.samples/clustering-it-provider/${project.version}</bundle>
<configfile finalname="${config.configfile.directory}/20-clustering-test-app.xml">mvn:org.opendaylight.controller.samples/clustering-it-config/${project.version}/xml/config</configfile>
</feature>
+
+ <!-- FIXME decouple messagebus code into messagebus and messagebus netconf -->
+ <feature name='odl-message-bus' version='${project.version}'>
+ <!--<feature version='${project.version}'>odl-netconf-connector</feature>-->
+ <bundle>mvn:org.opendaylight.controller.model/model-inventory/${mdsal.version}</bundle>
+ <feature version='${project.version}'>odl-mdsal-broker</feature>
+ <bundle>mvn:org.opendaylight.controller/messagebus-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/messagebus-spi/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/messagebus-impl/${project.version}</bundle>
+ <configfile finalname="${config.configfile.directory}/05-message-bus.xml">mvn:org.opendaylight.controller/messagebus-config/${project.version}/xml/config</configfile>
+ </feature>
</features>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2014 Cisco Systems, Inc. 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
--->
-<features name="odl-controller-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
- <!--
- Necessary TODO: Please read the features guidelines:
- https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Feature_Best_Practices
- -->
- <!--
- Necessary TODO: Add repo entries for the repositories of features you refer to
- in this feature file but do not define here.
- Examples:
- <repository>mvn:org.opendaylight.yangtools/features-yangtools/0.8.0-SNAPSHOT/xml/features</repository>
- <repository>mvn:org.opendaylight.controller/features-mdsal/1.3.0-SNAPSHOT/xml/features</repository>
- <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.2.0-SNAPSHOT/xml/features</repository>
- -->
- <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.controller/features-netconf/${netconf.version}/xml/features</repository>
- <!-- FIXME: This introduces cycle between projects, which makes version updates
- harder. Should be moved to different.
- -->
- <repository>mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features</repository>
- <feature name='odl-netconf-connector-all' version='${project.version}' description='OpenDaylight :: Netconf Connector :: All'>
- <!--
- Necessary TODO:
- List all of the user consumable features you define in this feature file here.
- Generally you would *not* list individual bundles here, but only features defined in *this* file.
- It is useful to list them in the same order they occur in the file.
-
- Examples:
- <feature version='${project.version}'>odl-controller-provider</feature>
- <feature version='${project.version}'>odl-controller-model</feature>
- -->
- <feature version='${project.version}'>odl-netconf-connector</feature>
- <feature version='${project.version}'>odl-netconf-connector-ssh</feature>
-
-
- </feature>
- <!--
- Necessary TODO: Define your features. It is useful to list then in order of dependency. So if A depends on B, list A first.
- When naming your features please be mindful of the guidelines:
- https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines
- Particularly:
- a) Prefixing names with 'odl-': https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Feature_Naming
- b) Descriptions: https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Description
- c) Avoid start-levels: https://wiki.opendaylight.org/view/Runtime:Karaf_Features_Guidelines#Avoid_start-levels
-
- It's also nice to list inside a feature, first the features it needs, then the bundles it needs, then the configfiles.
- Examples:
-
- * Basic MD-SAL Provider
- <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider '>
- <feature version='1.3.0-SNAPSHOT'>odl-mdsal-broker</feature>
- <feature version='${project.version}'>odl-controller-model</feature>
- <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
- ... whatever other bundles you need
- </feature>
-
- * Basic MD-SAL Model feature
- <feature name='odl-controller-model' version='${project.version}' description='OpenDaylight :: controller :: Model'>
- <feature version='0.8.0-SNAPSHOT'>odl-yangtools-binding</feature>
- <feature version='0.8.0-SNAPSHOT'>odl-yangtools-models</feature>
- <bundle>mvn:org.opendaylight.controller/controller-model/${project.version}</bundle>
- ... whatever other bundles you need
- </feature>
-
- * Config Subsystem example - the config file is your config subsystem configuration
- <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
- <feature version='1.3.0-SNAPSHOT'>odl-mdsal-broker</feature>
- <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
- <configfile finalname="etc/opendaylight/karaf/80-controller.xml">mvn:org.opendaylight.controller/controller-config/${project.version}/xml/config</configfile>
- ... whatever other bundles you need
- </feature>
-
- * Basic MD-SAL Provider that uses openflowplugin-flow-services (which brings along odl-mdsal-broker)
- <feature name='odl-controller-provider' version='${project.version}' description='OpenDaylight :: controller :: Provider'>
- <feature version='0.2.0-SNAPSHOT'>odl-openflowplugin-flow-services</feature>
- <bundle>mvn:org.opendaylight.controller/controller-provider/${project.version}</bundle>
- ... whatever other bundles you need
- </feature>
-
- -->
- <feature name='odl-netconf-connector' version='${project.version}' description="OpenDaylight :: Netconf Connector :: Netconf Connector">
- <feature version='${project.version}'>odl-mdsal-broker</feature>
- <feature version='${netconf.version}'>odl-netconf-client</feature>
- <feature version='${yangtools.version}'>odl-yangtools-models</feature>
- <bundle>mvn:org.opendaylight.controller/sal-netconf-connector/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller.model/model-inventory/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netconf-config-dispatcher/${config.version}</bundle>
- <configfile finalname='${config.configfile.directory}/${config.netconf.client.configfile}'>mvn:org.opendaylight.controller/netconf-config/${netconf.version}/xml/config</configfile>
- </feature>
- <feature name='odl-netconf-connector-ssh' version='${project.version}' description="OpenDaylight :: Netconf Connector :: Netconf Connector + Netconf SSH Server + loopback connection configuration">
- <feature version='${netconf.version}'>odl-netconf-ssh</feature>
- <feature version='${project.version}'>odl-netconf-connector</feature>
- <configfile finalname="${config.configfile.directory}/${config.netconf.connector.configfile}">mvn:org.opendaylight.controller/netconf-connector-config/${netconf.version}/xml/config</configfile>
- </feature>
- <feature name='odl-netconf-ssh' version='${netconf.version}' description="OpenDaylight :: Netconf Connector :: SSH">
- <feature version='${netconf.version}'>odl-netconf-tcp</feature>
- <feature version='${config.version}'>odl-config-netty</feature>
- <!-- FIXME: This introduces cycle between projects, which makes version updates
- harder. Should be moved to different.
- -->
- <feature version='${aaa.version}'>odl-aaa-netconf-plugin</feature>
- <bundle>mvn:org.opendaylight.controller/netconf-ssh/${netconf.version}</bundle>
- </feature>
- <feature name='odl-netconf-tcp' version='${netconf.version}' description="OpenDaylight :: Netconf Connector :: TCP">
- <feature version='${netconf.version}'>odl-netconf-impl</feature>
- <feature version='${config.version}'>odl-config-netty</feature>
- <bundle>mvn:org.opendaylight.controller/netconf-tcp/${netconf.version}</bundle>
- </feature>
-
- <feature name='odl-message-bus' version='${project.version}'>
- <feature version='${project.version}'>odl-netconf-connector</feature>
- <feature version='${project.version}'>odl-mdsal-broker</feature>
- <bundle>mvn:org.opendaylight.controller/messagebus-api/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/messagebus-spi/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/messagebus-impl/${project.version}</bundle>
- <configfile finalname="${config.configfile.directory}/05-message-bus.xml">mvn:org.opendaylight.controller/messagebus-config/${project.version}/xml/config</configfile>
- </feature>
- <!-- Optional TODO: Remove TODO Comments -->
-
-</features>
<module>config-persister</module>
<module>config-netty</module>
<module>mdsal</module>
- <module>netconf</module>
<module>protocol-framework</module>
<module>akka</module>
- <module>netconf-connector</module>
<module>restconf</module>
<module>extras</module>
</modules>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>org.opendaylight.controller.config.api,
- org.opendaylight.controller.config.api.annotations,
- org.opendaylight.controller.config.spi,
- org.opendaylight.controller.config.api.jmx,
- org.opendaylight.controller.config.api.jmx.constants,
- org.opendaylight.controller.config.api.runtime,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.rpc.context.rev130617.*,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.*,</Export-Package>
- </instructions>
- </configuration>
</plugin>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
* ConfigRegisry is registered.
*/
public static final ObjectName OBJECT_NAME = ConfigRegistryConstants.OBJECT_NAME;
+ public static final ObjectName OBJECT_NAME_NO_NOTIFICATIONS = ConfigRegistryConstants.OBJECT_NAME_NO_NOTIFICATIONS;
/**
* Opens new configuration transaction.
*/
Set<String> getAvailableModuleNames();
-
}
public static final String TYPE_CONFIG_REGISTRY = "ConfigRegistry";
+ public static final String TYPE_CONFIG_REGISTRY_NO_NOTIFICATIONS = "ConfigRegistryNoNotifications";
+
public static final String ON_DOMAIN = "org.opendaylight.controller";
public static final String TYPE_KEY = "type";
public static final ObjectName OBJECT_NAME = createONWithDomainAndType(TYPE_CONFIG_REGISTRY);
+ public static final ObjectName OBJECT_NAME_NO_NOTIFICATIONS = createONWithDomainAndType(TYPE_CONFIG_REGISTRY_NO_NOTIFICATIONS);
+
public static final String GET_AVAILABLE_MODULE_NAMES_ATTRIBUT_NAME = "AvailableModuleNames";
public static ObjectName createONWithDomainAndType(String type) {
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. 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.controller.config.api.jmx.notifications;
+
+import javax.management.NotificationBroadcasterSupport;
+
+public class CommitJMXNotification extends ConfigJMXNotification {
+
+ private static final String AFTER_COMMIT_MESSAGE_TEMPLATE = "Commit successful: %s";
+
+ CommitJMXNotification(NotificationBroadcasterSupport source, String message) {
+ super(ConfigJMXNotification.NotificationType.COMMIT, source, String.format(AFTER_COMMIT_MESSAGE_TEMPLATE, message));
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer("CommitJMXNotification{");
+ sb.append('}');
+ return sb.toString();
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8587623362011695514L;
+
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.api.jmx;
+package org.opendaylight.controller.config.api.jmx.notifications;
-import java.util.Set;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
-import org.w3c.dom.Element;
+import javax.management.ObjectName;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-public abstract class NetconfJMXNotification extends Notification {
+public abstract class ConfigJMXNotification extends Notification {
/**
*
private static long sequenceNumber = 1;
- private final TransactionProviderJMXNotificationType type;
+ public static String TYPE_NAME = "configfNotificationProvider";
+ public static ObjectName OBJECT_NAME = ObjectNameUtil.createONWithDomainAndType(TYPE_NAME);
- protected NetconfJMXNotification(TransactionProviderJMXNotificationType type,
- NotificationBroadcasterSupport source, String message) {
+ private final NotificationType type;
+
+ protected ConfigJMXNotification(NotificationType type,
+ NotificationBroadcasterSupport source, String message) {
super(type.toString(), source, sequenceNumber++, System.nanoTime(), message);
this.type = type;
}
* @param transactionName
* @param cfgSnapshot
*/
- public static CommitJMXNotification afterCommit(NotificationBroadcasterSupport source, String message,
- Element cfgSnapshot, Set<String> capabilities) {
- return new CommitJMXNotification(source, message, cfgSnapshot, capabilities);
+ public static CommitJMXNotification afterCommit(NotificationBroadcasterSupport source, String messages) {
+ return new CommitJMXNotification(source, messages);
}
- static enum TransactionProviderJMXNotificationType {
- commit;
+ enum NotificationType {
+ COMMIT;
}
}
<artifactId>config-plugin-parent</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>config-persister-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-manager-facade-xml</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>config-util</artifactId>
--- /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>
+ <artifactId>config-subsystem</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>config-manager-facade-xml</artifactId>
+ <name>${project.artifactId}</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-jmx-generator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>binding-generator-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Activator>org.opendaylight.controller.config.facade.xml.osgi.YangStoreActivator</Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig;
+package org.opendaylight.controller.config.facade.xml;
import java.util.Set;
import javax.management.ObjectName;
+import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
import org.opendaylight.controller.config.util.ConfigRegistryClient;
import org.opendaylight.controller.config.util.ConfigTransactionClient;
-import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider;
public class CandidateDatastoreQueryStrategy implements DatastoreQueryStrategy {
--- /dev/null
+
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.config.facade.xml;
+
+import com.google.common.collect.Multimap;
+import java.util.Map;
+import org.opendaylight.controller.config.api.ServiceReferenceReadableRegistry;
+import org.opendaylight.controller.config.facade.xml.mapping.config.Config;
+import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementDefinition;
+import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementResolved;
+import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
+import org.opendaylight.controller.config.facade.xml.mapping.config.Services;
+import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+
+public class ConfigExecution {
+
+ private final TestOption testOption;
+ private final EditStrategyType defaultEditStrategyType;
+ private final Services services;
+ private final Config configResolver;
+ private final XmlElement configElement;
+
+ public ConfigExecution(Config configResolver, XmlElement configElement, TestOption testOption, EditStrategyType defaultStrategy) throws DocumentedException {
+ Config.checkUnrecognisedChildren(configElement);
+ this.configResolver = configResolver;
+ this.configElement = configElement;
+ this.services = configResolver.fromXmlServices(configElement);
+ this.testOption = testOption;
+ this.defaultEditStrategyType = defaultStrategy;
+ }
+
+ public boolean shouldTest() {
+ return testOption == TestOption.testOnly || testOption == TestOption.testThenSet;
+ }
+
+ public boolean shouldSet() {
+ return testOption == TestOption.set || testOption == TestOption.testThenSet;
+ }
+
+ public Map<String, Multimap<String, ModuleElementResolved>> getResolvedXmlElements(ServiceReferenceReadableRegistry serviceRegistry) throws DocumentedException {
+ return configResolver.fromXmlModulesResolved(configElement, defaultEditStrategyType, getServiceRegistryWrapper(serviceRegistry));
+ }
+
+ public ServiceRegistryWrapper getServiceRegistryWrapper(ServiceReferenceReadableRegistry serviceRegistry) {
+ // TODO cache service registry
+ return new ServiceRegistryWrapper(serviceRegistry);
+ }
+
+ public Map<String, Multimap<String,ModuleElementDefinition>> getModulesDefinition(ServiceReferenceReadableRegistry serviceRegistry) throws DocumentedException {
+ return configResolver.fromXmlModulesMap(configElement, defaultEditStrategyType, getServiceRegistryWrapper(serviceRegistry));
+ }
+
+ public EditStrategyType getDefaultStrategy() {
+ return defaultEditStrategyType;
+ }
+
+ public Services getServices() {
+ return services;
+ }
+
+ public XmlElement getConfigElement() {
+ return configElement;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.config.facade.xml;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+import java.io.Closeable;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping;
+import org.opendaylight.controller.config.facade.xml.mapping.config.Config;
+import org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfig;
+import org.opendaylight.controller.config.facade.xml.mapping.config.InstanceConfigElementResolved;
+import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig;
+import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementDefinition;
+import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleElementResolved;
+import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
+import org.opendaylight.controller.config.facade.xml.mapping.config.Services;
+import org.opendaylight.controller.config.facade.xml.osgi.YangStoreContext;
+import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
+import org.opendaylight.controller.config.facade.xml.runtime.InstanceRuntime;
+import org.opendaylight.controller.config.facade.xml.runtime.ModuleRuntime;
+import org.opendaylight.controller.config.facade.xml.runtime.Runtime;
+import org.opendaylight.controller.config.facade.xml.strategy.EditConfigStrategy;
+import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
+import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
+import org.opendaylight.controller.config.util.BeanReader;
+import org.opendaylight.controller.config.util.ConfigRegistryClient;
+import org.opendaylight.controller.config.util.ConfigTransactionClient;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
+import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Config subsystem facade for xml format
+ * <p/>
+ * TODO extract generic interface for config subsystem facades
+ */
+public class ConfigSubsystemFacade implements Closeable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigSubsystemFacade.class);
+ private final YangStoreService yangStoreService;
+ private final TransactionProvider transactionProvider;
+ private final ConfigRegistryClient configRegistryClient;
+ private final ConfigRegistryClient configRegistryClientNoNotifications;
+ private final RpcFacade rpcFacade;
+
+ public ConfigSubsystemFacade(ConfigRegistryClient configRegistryClient, ConfigRegistryClient configRegistryClientNoNotifications, YangStoreService yangStoreService, String id) {
+ this.configRegistryClient = configRegistryClient;
+ this.configRegistryClientNoNotifications = configRegistryClientNoNotifications;
+ this.yangStoreService = yangStoreService;
+ this.transactionProvider = new TransactionProvider(configRegistryClient, id);
+ rpcFacade = new RpcFacade(yangStoreService, configRegistryClient);
+ }
+
+ public ConfigSubsystemFacade(ConfigRegistryClient configRegistryClient, ConfigRegistryClient configRegistryClientNoNotifications, YangStoreService yangStoreService, TransactionProvider txProvider) {
+ this.configRegistryClient = configRegistryClient;
+ this.configRegistryClientNoNotifications = configRegistryClientNoNotifications;
+ this.yangStoreService = yangStoreService;
+ this.transactionProvider = txProvider;
+ rpcFacade = new RpcFacade(yangStoreService, configRegistryClient);
+ }
+
+ public Element getConfiguration(final Document document, final Datastore source, final Optional<String> maybeNamespace) {
+
+ final ConfigTransactionClient registryClient;
+ // Read current state from a transaction, if running is source, then start new transaction just for reading
+ // in case of candidate, get current transaction representing candidate
+ if (source == Datastore.running) {
+ final ObjectName readTx = transactionProvider.getOrCreateReadTransaction();
+ registryClient = configRegistryClient.getConfigTransactionClient(readTx);
+ } else {
+ registryClient = configRegistryClient.getConfigTransactionClient(transactionProvider.getOrCreateTransaction());
+ }
+
+ try {
+ Element dataElement = XmlUtil.createElement(document, XmlMappingConstants.DATA_KEY, Optional.<String>absent());
+ final Set<ObjectName> instances = Datastore.getInstanceQueryStrategy(source, this.transactionProvider)
+ .queryInstances(configRegistryClient);
+
+ final Config configMapping =
+ new Config(transformMbeToModuleConfigs(yangStoreService.getModuleMXBeanEntryMap()), yangStoreService.getEnumResolver());
+
+ ServiceRegistryWrapper serviceTracker = new ServiceRegistryWrapper(registryClient);
+ dataElement = configMapping.toXml(instances, maybeNamespace, document, dataElement, serviceTracker);
+
+ return dataElement;
+ } finally {
+ if (source == Datastore.running) {
+ transactionProvider.closeReadTransaction();
+ }
+ }
+ }
+
+ public void executeConfigExecution(ConfigExecution configExecution) throws DocumentedException, ValidationException {
+ if (configExecution.shouldTest()) {
+ executeTests(configExecution);
+ }
+
+ if (configExecution.shouldSet()) {
+ executeSet(configExecution);
+ }
+ }
+
+ public CommitStatus commitTransaction() throws DocumentedException, ValidationException, ConflictingVersionException {
+ final CommitStatus status = this.transactionProvider.commitTransaction();
+ LOG.trace("Transaction committed successfully: {}", status);
+ return status;
+ }
+
+ public CommitStatus commitSilentTransaction() throws DocumentedException, ValidationException, ConflictingVersionException {
+ final CommitStatus status = this.transactionProvider.commitTransaction(configRegistryClientNoNotifications);
+ LOG.trace("Transaction committed successfully: {}", status);
+ return status;
+ }
+
+ private void executeSet(ConfigExecution configExecution) throws DocumentedException {
+ set(configExecution);
+ LOG.debug("Set phase for {} operation successful, element: ", configExecution.getDefaultStrategy(), configExecution.getConfigElement());
+ }
+
+ private void executeTests(ConfigExecution configExecution) throws DocumentedException, ValidationException {
+ test(configExecution, configExecution.getDefaultStrategy());
+ LOG.debug("Test phase for {} operation successful, element: ", configExecution.getDefaultStrategy(), configExecution.getConfigElement());
+ }
+
+ private void test(ConfigExecution execution, EditStrategyType editStrategyType) throws ValidationException, DocumentedException {
+ ObjectName taON = transactionProvider.getTestTransaction();
+ try {
+ // default strategy = replace wipes config
+ if (editStrategyType == EditStrategyType.replace) {
+ transactionProvider.wipeTestTransaction(taON);
+ }
+
+ ConfigTransactionClient ta = configRegistryClient.getConfigTransactionClient(taON);
+
+ handleMisssingInstancesOnTransaction(ta, execution);
+ setServicesOnTransaction(ta, execution);
+ setOnTransaction(ta, execution);
+ transactionProvider.validateTestTransaction(taON);
+ } finally {
+ transactionProvider.abortTestTransaction(taON);
+ }
+ }
+
+ private void set(ConfigExecution ConfigExecution) throws DocumentedException {
+ ObjectName taON = transactionProvider.getOrCreateTransaction();
+
+ // default strategy = replace wipes config
+ if (ConfigExecution.getDefaultStrategy() == EditStrategyType.replace) {
+ transactionProvider.wipeTransaction();
+ }
+
+ ConfigTransactionClient ta = configRegistryClient.getConfigTransactionClient(taON);
+
+ handleMisssingInstancesOnTransaction(ta, ConfigExecution);
+ setServicesOnTransaction(ta, ConfigExecution);
+ setOnTransaction(ta, ConfigExecution);
+ }
+
+ private void setServicesOnTransaction(ConfigTransactionClient ta, ConfigExecution execution) throws DocumentedException {
+
+ Services services = execution.getServices();
+
+ Map<String, Map<String, Map<String, Services.ServiceInstance>>> namespaceToServiceNameToRefNameToInstance = services
+ .getNamespaceToServiceNameToRefNameToInstance();
+
+ for (Map.Entry<String, Map<String, Map<String, Services.ServiceInstance>>> namespaceToServiceToRefEntry : namespaceToServiceNameToRefNameToInstance.entrySet()) {
+ for (Map.Entry<String, Map<String, Services.ServiceInstance>> serviceToRefEntry : namespaceToServiceToRefEntry.getValue().entrySet()) {
+
+ String qnameOfService = getQname(ta, namespaceToServiceToRefEntry.getKey(), serviceToRefEntry.getKey());
+ Map<String, Services.ServiceInstance> refNameToInstance = serviceToRefEntry.getValue();
+
+ for (Map.Entry<String, Services.ServiceInstance> refNameToServiceEntry : refNameToInstance.entrySet()) {
+ ObjectName on = refNameToServiceEntry.getValue().getObjectName(ta.getTransactionName());
+ try {
+ if (Services.ServiceInstance.EMPTY_SERVICE_INSTANCE == refNameToServiceEntry.getValue()) {
+ ta.removeServiceReference(qnameOfService, refNameToServiceEntry.getKey());
+ LOG.debug("Removing service {} with name {}", qnameOfService, refNameToServiceEntry.getKey());
+ } else {
+ ObjectName saved = ta.saveServiceReference(qnameOfService, refNameToServiceEntry.getKey(), on);
+ LOG.debug("Saving service {} with on {} under name {} with service on {}", qnameOfService,
+ on, refNameToServiceEntry.getKey(), saved);
+ }
+ } catch (InstanceNotFoundException e) {
+ throw new DocumentedException(String.format("Unable to edit ref name " + refNameToServiceEntry.getKey() + " for instance " + on, e),
+ ErrorType.application,
+ ErrorTag.operation_failed,
+ ErrorSeverity.error);
+ }
+ }
+ }
+ }
+ }
+
+ private String getQname(ConfigTransactionClient ta, String namespace, String serviceName) {
+ return ta.getServiceInterfaceName(namespace, serviceName);
+ }
+
+ private void setOnTransaction(ConfigTransactionClient ta, ConfigExecution execution) throws DocumentedException {
+
+ for (Multimap<String, ModuleElementResolved> modulesToResolved : execution.getResolvedXmlElements(ta).values()) {
+
+ for (Map.Entry<String, ModuleElementResolved> moduleToResolved : modulesToResolved.entries()) {
+ String moduleName = moduleToResolved.getKey();
+
+ ModuleElementResolved moduleElementResolved = moduleToResolved.getValue();
+ String instanceName = moduleElementResolved.getInstanceName();
+
+ InstanceConfigElementResolved ice = moduleElementResolved.getInstanceConfigElementResolved();
+ EditConfigStrategy strategy = ice.getEditStrategy();
+ strategy.executeConfiguration(moduleName, instanceName, ice.getConfiguration(), ta, execution.getServiceRegistryWrapper(ta));
+ }
+ }
+ }
+
+ private void handleMisssingInstancesOnTransaction(ConfigTransactionClient ta,
+ ConfigExecution execution) throws DocumentedException {
+
+ for (Multimap<String, ModuleElementDefinition> modulesToResolved : execution.getModulesDefinition(ta).values()) {
+ for (Map.Entry<String, ModuleElementDefinition> moduleToResolved : modulesToResolved.entries()) {
+ String moduleName = moduleToResolved.getKey();
+
+ ModuleElementDefinition moduleElementDefinition = moduleToResolved.getValue();
+
+ EditConfigStrategy strategy = moduleElementDefinition.getEditStrategy();
+ strategy.executeConfiguration(moduleName, moduleElementDefinition.getInstanceName(), null, ta, execution.getServiceRegistryWrapper(ta));
+ }
+ }
+ }
+
+ public Config getConfigMapping() {
+ final YangStoreContext snapshot = yangStoreService.getCurrentSnapshot();
+ Map<String, Map<String, ModuleConfig>> factories = transformMbeToModuleConfigs(snapshot.getModuleMXBeanEntryMap());
+ Map<String, Map<Date, IdentityMapping>> identitiesMap = transformIdentities(snapshot.getModules());
+ return new Config(factories, identitiesMap, snapshot.getEnumResolver());
+ }
+
+ private static Map<String, Map<Date, IdentityMapping>> transformIdentities(Set<Module> modules) {
+ Map<String, Map<Date, IdentityMapping>> mappedIds = Maps.newHashMap();
+ for (Module module : modules) {
+ String namespace = module.getNamespace().toString();
+ Map<Date, IdentityMapping> revisionsByNamespace = mappedIds.get(namespace);
+ if (revisionsByNamespace == null) {
+ revisionsByNamespace = Maps.newHashMap();
+ mappedIds.put(namespace, revisionsByNamespace);
+ }
+
+ Date revision = module.getRevision();
+
+ IdentityMapping identityMapping = revisionsByNamespace.get(revision);
+ if (identityMapping == null) {
+ identityMapping = new IdentityMapping();
+ revisionsByNamespace.put(revision, identityMapping);
+ }
+
+ for (IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
+ identityMapping.addIdSchemaNode(identitySchemaNode);
+ }
+
+ }
+
+ return mappedIds;
+ }
+
+ public Map<String/* Namespace from yang file */,
+ Map<String /* Name of module entry from yang file */, ModuleConfig>> transformMbeToModuleConfigs(
+ Map<String/* Namespace from yang file */,
+ Map<String /* Name of module entry from yang file */, ModuleMXBeanEntry>> mBeanEntries) {
+ return transformMbeToModuleConfigs(configRegistryClient, mBeanEntries);
+ }
+
+ public Map<String/* Namespace from yang file */,
+ Map<String /* Name of module entry from yang file */, ModuleConfig>> transformMbeToModuleConfigs(BeanReader reader,
+ Map<String/* Namespace from yang file */,
+ Map<String /* Name of module entry from yang file */, ModuleMXBeanEntry>> mBeanEntries) {
+
+ Map<String, Map<String, ModuleConfig>> namespaceToModuleNameToModuleConfig = Maps.newHashMap();
+
+ for (Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleToMbe : mBeanEntries.entrySet()) {
+ for (Map.Entry<String, ModuleMXBeanEntry> moduleNameToMbe : namespaceToModuleToMbe.getValue().entrySet()) {
+ String moduleName = moduleNameToMbe.getKey();
+ ModuleMXBeanEntry moduleMXBeanEntry = moduleNameToMbe.getValue();
+
+ ModuleConfig moduleConfig = new ModuleConfig(moduleName,
+ new InstanceConfig(reader, moduleMXBeanEntry.getAttributes(), moduleMXBeanEntry.getNullableDummyContainerName()));
+
+ Map<String, ModuleConfig> moduleNameToModuleConfig = namespaceToModuleNameToModuleConfig.get(namespaceToModuleToMbe.getKey());
+ if (moduleNameToModuleConfig == null) {
+ moduleNameToModuleConfig = Maps.newHashMap();
+ namespaceToModuleNameToModuleConfig.put(namespaceToModuleToMbe.getKey(), moduleNameToModuleConfig);
+ }
+
+ moduleNameToModuleConfig.put(moduleName, moduleConfig);
+ }
+ }
+
+ return namespaceToModuleNameToModuleConfig;
+ }
+
+ public ConfigExecution getConfigExecution(final Config configMapping, final Element xmlToBePersisted) throws DocumentedException {
+ return new ConfigExecution(configMapping, XmlElement.fromDomElement(xmlToBePersisted), TestOption.testThenSet, EditStrategyType.getDefaultStrategy());
+ }
+
+ private Map<String, Map<String, ModuleRuntime>> createModuleRuntimes(ConfigRegistryClient configRegistryClient,
+ Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries) {
+ Map<String, Map<String, ModuleRuntime>> retVal = Maps.newHashMap();
+
+ for (Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleEntry : mBeanEntries.entrySet()) {
+
+ Map<String, ModuleRuntime> innerMap = Maps.newHashMap();
+ Map<String, ModuleMXBeanEntry> entriesFromNamespace = namespaceToModuleEntry.getValue();
+ for (Map.Entry<String, ModuleMXBeanEntry> moduleToMXEntry : entriesFromNamespace.entrySet()) {
+
+ ModuleMXBeanEntry mbe = moduleToMXEntry.getValue();
+
+ Map<RuntimeBeanEntry, InstanceConfig> cache = Maps.newHashMap();
+ RuntimeBeanEntry root = null;
+ for (RuntimeBeanEntry rbe : mbe.getRuntimeBeans()) {
+ cache.put(rbe, new InstanceConfig(configRegistryClient, rbe.getYangPropertiesToTypesMap(), mbe.getNullableDummyContainerName()));
+ if (rbe.isRoot()) {
+ root = rbe;
+ }
+ }
+
+ if (root == null) {
+ continue;
+ }
+
+ InstanceRuntime rootInstanceRuntime = createInstanceRuntime(root, cache);
+ ModuleRuntime moduleRuntime = new ModuleRuntime(rootInstanceRuntime);
+ innerMap.put(moduleToMXEntry.getKey(), moduleRuntime);
+ }
+
+ retVal.put(namespaceToModuleEntry.getKey(), innerMap);
+ }
+ return retVal;
+ }
+
+ private InstanceRuntime createInstanceRuntime(RuntimeBeanEntry root, Map<RuntimeBeanEntry, InstanceConfig> cache) {
+ Map<String, InstanceRuntime> children = Maps.newHashMap();
+ for (RuntimeBeanEntry child : root.getChildren()) {
+ children.put(child.getJavaNamePrefix(), createInstanceRuntime(child, cache));
+ }
+
+ return new InstanceRuntime(cache.get(root), children, createJmxToYangMap(root.getChildren()));
+ }
+
+ private Map<String, String> createJmxToYangMap(List<RuntimeBeanEntry> children) {
+ Map<String, String> jmxToYangNamesForChildRbe = Maps.newHashMap();
+ for (RuntimeBeanEntry rbe : children) {
+ jmxToYangNamesForChildRbe.put(rbe.getJavaNamePrefix(), rbe.getYangName());
+ }
+ return jmxToYangNamesForChildRbe;
+ }
+
+ public Element get(Document document) throws DocumentedException {
+ final ObjectName testTransaction = transactionProvider.getOrCreateReadTransaction();
+ final ConfigTransactionClient txClient = configRegistryClient.getConfigTransactionClient(testTransaction);
+
+ try {
+ // Runtime beans are not parts of transactions and have to be queried against the central registry
+ final Set<ObjectName> runtimeBeans = configRegistryClient.lookupRuntimeBeans();
+
+ final Set<ObjectName> configBeans = Datastore.getInstanceQueryStrategy(Datastore.running, transactionProvider)
+ .queryInstances(configRegistryClient);
+
+ final Map<String, Map<String, ModuleRuntime>> moduleRuntimes = createModuleRuntimes(configRegistryClient,
+ yangStoreService.getModuleMXBeanEntryMap());
+
+ final YangStoreContext yangStoreSnapshot = yangStoreService.getCurrentSnapshot();
+ final Map<String, Map<String, ModuleConfig>> moduleConfigs = transformMbeToModuleConfigs(txClient,
+ yangStoreSnapshot.getModuleMXBeanEntryMap());
+
+ final org.opendaylight.controller.config.facade.xml.runtime.Runtime runtime = new Runtime(moduleRuntimes, moduleConfigs);
+
+ return runtime.toXml(runtimeBeans, configBeans, document, yangStoreSnapshot.getEnumResolver());
+ } finally {
+ transactionProvider.closeReadTransaction();
+ }
+ }
+
+ public void abortConfiguration() {
+ if (transactionProvider.getTransaction().isPresent()) {
+ this.transactionProvider.abortTransaction();
+ }
+ }
+
+ public void validateConfiguration() throws ValidationException {
+ transactionProvider.validateTransaction();
+ }
+
+ @Override
+ public void close() {
+ transactionProvider.close();
+ }
+
+ public RpcFacade getRpcFacade() {
+ return rpcFacade;
+ }
+
+}
+
--- /dev/null
+package org.opendaylight.controller.config.facade.xml;
+
+import com.google.common.collect.Sets;
+import java.util.Set;
+import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
+import org.opendaylight.controller.config.util.ConfigRegistryClient;
+import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
+import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.controller.config.util.capability.YangModuleCapability;
+import org.opendaylight.yangtools.yang.model.api.Module;
+
+public class ConfigSubsystemFacadeFactory {
+
+ private ConfigRegistryClient cfgRegClient;
+ private ConfigRegistryJMXClient cfgRegClientNoNotifications;
+ private YangStoreService yangStoreService;
+
+ public ConfigSubsystemFacadeFactory(final ConfigRegistryClient cfgRegClient, final ConfigRegistryJMXClient jmxClientNoNotifications, final YangStoreService yangStoreService) {
+ this.cfgRegClient = cfgRegClient;
+ this.cfgRegClientNoNotifications = jmxClientNoNotifications;
+ this.yangStoreService = yangStoreService;
+ }
+
+ /**
+ * Create new instance of ConfigSubsystemFacade. Each instance works with a dedicated transaction provider, making
+ * the instances suitable for facade-per-client use.
+ */
+ public ConfigSubsystemFacade createFacade(final String id) {
+ return new ConfigSubsystemFacade(cfgRegClient, cfgRegClientNoNotifications, yangStoreService, id);
+ }
+
+ public YangStoreService getYangStoreService() {
+ return yangStoreService;
+ }
+
+ public Set<Capability> getCurrentCapabilities() {
+ Set<Module> modules = yangStoreService.getModules();
+ final Set<Capability> capabilities = Sets.newHashSet();
+ for (Module module : modules) {
+ capabilities.add(new YangModuleCapability(module, yangStoreService.getModuleSource(module)));
+ }
+
+ return capabilities;
+ }
+
+
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.confignetconfconnector.operations;
+package org.opendaylight.controller.config.facade.xml;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig.CandidateDatastoreQueryStrategy;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig.DatastoreQueryStrategy;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig.RunningDatastoreQueryStrategy;
-import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider;
+import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
public enum Datastore {
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig;
+package org.opendaylight.controller.config.facade.xml;
import java.util.Set;
import javax.management.ObjectName;
--- /dev/null
+package org.opendaylight.controller.config.facade.xml;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import java.util.Map;
+import javax.management.ObjectName;
+import javax.management.openmbean.OpenType;
+import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
+import org.opendaylight.controller.config.facade.xml.mapping.attributes.mapping.AttributeMappingStrategy;
+import org.opendaylight.controller.config.facade.xml.mapping.attributes.mapping.ObjectMapper;
+import org.opendaylight.controller.config.facade.xml.mapping.attributes.toxml.ObjectXmlWriter;
+import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
+import org.opendaylight.controller.config.facade.xml.rpc.InstanceRuntimeRpc;
+import org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs;
+import org.opendaylight.controller.config.facade.xml.rpc.Rpcs;
+import org.opendaylight.controller.config.facade.xml.rpc.RuntimeRpcElementResolved;
+import org.opendaylight.controller.config.util.ConfigRegistryClient;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
+import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.VoidAttribute;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class RpcFacade {
+
+ public static final String CONTEXT_INSTANCE = "context-instance";
+ private YangStoreService yangStoreService;
+ private ConfigRegistryClient configRegistryClient;
+
+ public RpcFacade(final YangStoreService yangStoreService, final ConfigRegistryClient configRegistryClient) {
+ this.yangStoreService = yangStoreService;
+ this.configRegistryClient = configRegistryClient;
+ }
+
+ public Rpcs mapRpcs() {
+
+ final Map<String, Map<String, ModuleRpcs>> map = Maps.newHashMap();
+
+ for (final Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleEntry : yangStoreService.getModuleMXBeanEntryMap().entrySet()) {
+
+ Map<String, ModuleRpcs> namespaceToModules = map.get(namespaceToModuleEntry.getKey());
+ if (namespaceToModules == null) {
+ namespaceToModules = Maps.newHashMap();
+ map.put(namespaceToModuleEntry.getKey(), namespaceToModules);
+ }
+
+ for (final Map.Entry<String, ModuleMXBeanEntry> moduleEntry : namespaceToModuleEntry.getValue().entrySet()) {
+
+ ModuleRpcs rpcMapping = namespaceToModules.get(moduleEntry.getKey());
+ if (rpcMapping == null) {
+ rpcMapping = new ModuleRpcs(yangStoreService.getEnumResolver());
+ namespaceToModules.put(moduleEntry.getKey(), rpcMapping);
+ }
+
+ final ModuleMXBeanEntry entry = moduleEntry.getValue();
+
+ for (final RuntimeBeanEntry runtimeEntry : entry.getRuntimeBeans()) {
+ rpcMapping.addNameMapping(runtimeEntry);
+ for (final RuntimeBeanEntry.Rpc rpc : runtimeEntry.getRpcs()) {
+ rpcMapping.addRpc(runtimeEntry, rpc);
+ }
+ }
+ }
+ }
+
+ return new Rpcs(map);
+ }
+
+
+ public OperationExecution fromXml(final XmlElement xml) throws DocumentedException {
+ final String namespace;
+ namespace = xml.getNamespace();
+
+ final XmlElement contextInstanceElement = xml.getOnlyChildElement(CONTEXT_INSTANCE);
+ final String operationName = xml.getName();
+
+ final RuntimeRpcElementResolved id = RuntimeRpcElementResolved.fromXpath(
+ contextInstanceElement.getTextContent(), operationName, namespace);
+
+ final Rpcs rpcs = mapRpcs();
+
+ final ModuleRpcs rpcMapping = rpcs.getRpcMapping(id);
+ final InstanceRuntimeRpc instanceRuntimeRpc = rpcMapping.getRpc(id.getRuntimeBeanName(), operationName);
+
+ // TODO move to Rpcs after xpath attribute is redesigned
+
+ final ObjectName on = id.getObjectName(rpcMapping);
+ Map<String, AttributeConfigElement> attributes = instanceRuntimeRpc.fromXml(xml);
+ attributes = sortAttributes(attributes, xml);
+
+ return new OperationExecution(on, instanceRuntimeRpc.getName(), attributes,
+ instanceRuntimeRpc.getReturnType(), namespace);
+ }
+
+ private Map<String, AttributeConfigElement> sortAttributes(
+ final Map<String, AttributeConfigElement> attributes, final XmlElement xml) {
+ final Map<String, AttributeConfigElement> sorted = Maps.newLinkedHashMap();
+
+ for (XmlElement xmlElement : xml.getChildElements()) {
+ final String name = xmlElement.getName();
+ if (!CONTEXT_INSTANCE.equals(name)) { // skip context
+ // instance child node
+ // because it
+ // specifies
+ // ObjectName
+ final AttributeConfigElement value = attributes.get(name);
+ if (value == null) {
+ throw new IllegalArgumentException("Cannot find yang mapping for node " + xmlElement);
+ }
+ sorted.put(name, value);
+ }
+ }
+
+ return sorted;
+ }
+
+ public Object executeOperation(final OperationExecution execution) {
+ final Object[] params = new Object[execution.attributes.size()];
+ final String[] signature = new String[execution.attributes.size()];
+
+ int i = 0;
+ for (final AttributeConfigElement attribute : execution.attributes.values()) {
+ final Optional<?> resolvedValueOpt = attribute.getResolvedValue();
+
+ params[i] = resolvedValueOpt.isPresent() ? resolvedValueOpt.get() : attribute.getResolvedDefaultValue();
+ signature[i] = resolvedValueOpt.isPresent() ? resolvedValueOpt.get().getClass().getName() : attribute
+ .getResolvedDefaultValue().getClass().getName();
+ i++;
+ }
+
+ return configRegistryClient.invokeMethod(execution.on, execution.operationName, params, signature);
+ }
+
+ public Element toXml(Document doc, Object result, OperationExecution execution) throws DocumentedException {
+ AttributeMappingStrategy<?, ? extends OpenType<?>> mappingStrategy = new ObjectMapper().prepareStrategy(execution.getReturnType());
+ Optional<?> mappedAttributeOpt = mappingStrategy.mapAttribute(result);
+ Preconditions.checkState(mappedAttributeOpt.isPresent(), "Unable to map return value %s as %s", result, execution.getReturnType().getOpenType());
+
+ // FIXME: multiple return values defined as leaf-list and list in yang should not be wrapped in output xml element,
+ // they need to be appended directly under rpc-reply element
+ //
+ // Either allow List of Elements to be returned from NetconfOperation or
+ // pass reference to parent output xml element for netconf operations to
+ // append result(s) on their own
+ Element tempParent = XmlUtil.createElement(doc, "output", Optional.of(XmlMappingConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
+ new ObjectXmlWriter().prepareWritingStrategy(execution.getReturnType().getAttributeYangName(),
+ execution.getReturnType(), doc).writeElement(tempParent, execution.getNamespace(), mappedAttributeOpt.get());
+
+ XmlElement xmlElement = XmlElement.fromDomElement(tempParent);
+ return xmlElement.getChildElements().size() > 1 ? tempParent : xmlElement.getOnlyChildElement().getDomElement();
+ }
+
+ public class OperationExecution {
+
+ private final ObjectName on;
+ private final String operationName;
+ private final Map<String, AttributeConfigElement> attributes;
+ private final AttributeIfc returnType;
+ private final String namespace;
+
+ public OperationExecution(final ObjectName on, final String name,
+ final Map<String, AttributeConfigElement> attributes, final AttributeIfc returnType, final String namespace) {
+ this.on = on;
+ this.operationName = name;
+ this.attributes = attributes;
+ this.returnType = returnType;
+ this.namespace = namespace;
+ }
+
+ public boolean isVoid() {
+ return returnType == VoidAttribute.getInstance();
+ }
+
+ public ObjectName getOn() {
+ return on;
+ }
+
+ public String getOperationName() {
+ return operationName;
+ }
+
+ public Map<String, AttributeConfigElement> getAttributes() {
+ return attributes;
+ }
+
+ public AttributeIfc getReturnType() {
+ return returnType;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+ }
+
+}
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig;
+package org.opendaylight.controller.config.facade.xml;
import java.util.Set;
import javax.management.ObjectName;
+import org.opendaylight.controller.config.facade.xml.transactions.TransactionProvider;
import org.opendaylight.controller.config.util.ConfigRegistryClient;
import org.opendaylight.controller.config.util.ConfigTransactionClient;
-import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider;
public class RunningDatastoreQueryStrategy implements DatastoreQueryStrategy {
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.config.facade.xml;
+
+import java.util.Arrays;
+
+public enum TestOption {
+ testOnly, set, testThenSet;
+
+ public static TestOption getFromXmlName(String testOptionXmlName) {
+ switch (testOptionXmlName) {
+ case "test-only":
+ return testOnly;
+ case "test-then-set":
+ return testThenSet;
+ case "set":
+ return set;
+ default:
+ throw new IllegalArgumentException("Unsupported test option " + testOptionXmlName + " supported: "
+ + Arrays.toString(TestOption.values()));
+ }
+ }
+
+ public static TestOption getDefault() {
+ return testThenSet;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.config.facade.xml.exception;
+
+import java.util.Collections;
+import java.util.Map;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+
+public class ConfigHandlingException extends DocumentedException {
+ private static final long serialVersionUID = 1L;
+
+ public ConfigHandlingException(final String message, final ErrorType errorType, final ErrorTag errorTag,
+ final ErrorSeverity errorSeverity) {
+ this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+ }
+
+ public ConfigHandlingException(final String message, final ErrorType errorType, final ErrorTag errorTag,
+ final ErrorSeverity errorSeverity, final Map<String, String> errorInfo){
+ super(message,errorType,errorTag,errorSeverity,errorInfo);
+ }
+}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.exception;
+package org.opendaylight.controller.config.facade.xml.exception;
import java.util.Collections;
import java.util.Map;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
-public class NoTransactionFoundException extends NetconfDocumentedException {
+public class NoTransactionFoundException extends DocumentedException {
private static final long serialVersionUID = 1L;
public NoTransactionFoundException(final String message, final ErrorType errorType, final ErrorTag errorTag,
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.exception;
+package org.opendaylight.controller.config.facade.xml.exception;
import java.util.Collections;
import java.util.Map;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
-public class OperationNotPermittedException extends NetconfDocumentedException {
+public class OperationNotPermittedException extends DocumentedException {
private static final long serialVersionUID = 1L;
public OperationNotPermittedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.config.facade.xml.mapping;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+
+public class IdentityMapping {
+ private final Map<String, IdentitySchemaNode> identityNameToSchemaNode;
+
+ public IdentityMapping() {
+ this.identityNameToSchemaNode = Maps.newHashMap();
+ }
+
+ public void addIdSchemaNode(IdentitySchemaNode node) {
+ String name = node.getQName().getLocalName();
+ Preconditions.checkState(!identityNameToSchemaNode.containsKey(name));
+ identityNameToSchemaNode.put(name, node);
+ }
+
+ public boolean containsIdName(String idName) {
+ return identityNameToSchemaNode.containsKey(idName);
+ }
+
+}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes;
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeType;
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import java.util.List;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
public abstract class AbstractAttributeReadingStrategy implements AttributeReadingStrategy {
}
@Override
- public AttributeConfigElement readElement(List<XmlElement> configNodes) throws NetconfDocumentedException {
+ public AttributeConfigElement readElement(List<XmlElement> configNodes) throws DocumentedException {
if (configNodes.size() == 0){
return AttributeConfigElement.createNullValue(postprocessNullableDefault(nullableDefault));
}
return readElementHook(configNodes);
}
- abstract AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException;
+ abstract AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws DocumentedException;
protected Object postprocessNullableDefault(String nullableDefault) {
return nullableDefault;
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import com.google.common.collect.Lists;
import java.util.List;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditStrategyType;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
}
@Override
- AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException {
+ AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws DocumentedException {
List<Object> innerList = Lists.newArrayList();
EditStrategyType innerEditStrategy= null;
for (XmlElement configNode : configNodes) {
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import com.google.common.base.Optional;
import javax.management.openmbean.OpenType;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving.AttributeResolvingStrategy;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditStrategyType;
+import org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.AttributeResolvingStrategy;
+import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
/**
* Parsed xml element containing configuration for one attribute of an instance
}
public void resolveValue(AttributeResolvingStrategy<?, ? extends OpenType<?>> attributeResolvingStrategy,
- String attrName) throws NetconfDocumentedException {
+ String attrName) throws DocumentedException {
resolvedValue = attributeResolvingStrategy.parseAttribute(attrName, value);
Optional<?> resolvedDefault = attributeResolvingStrategy.parseAttribute(attrName, defaultValue);
resolvedDefaultValue = resolvedDefault.isPresent() ? resolvedDefault.get() : null;
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import java.util.List;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
public interface AttributeReadingStrategy {
- public abstract AttributeConfigElement readElement(List<XmlElement> element) throws NetconfDocumentedException;
+ public abstract AttributeConfigElement readElement(List<XmlElement> element) throws DocumentedException;
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditStrategyType;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
public class CompositeAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
}
@Override
- AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException {
+ AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws DocumentedException {
Preconditions.checkState(configNodes.size() == 1, "This element should be present only once %s", configNodes);
complexElement.checkUnrecognisedElements(recognisedChildren);
- String perInstanceEditStrategy = complexElement.getAttribute(XmlNetconfConstants.OPERATION_ATTR_KEY,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ String perInstanceEditStrategy = complexElement.getAttribute(XmlMappingConstants.OPERATION_ATTR_KEY,
+ XmlMappingConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
return Strings.isNullOrEmpty(perInstanceEditStrategy) ? AttributeConfigElement.create(getNullableDefault(), innerMap) :
AttributeConfigElement.create(getNullableDefault(), innerMap, EditStrategyType.valueOf(perInstanceEditStrategy));
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import com.google.common.base.Preconditions;
import java.util.List;
import java.util.Map;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.config.facade.xml.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlMappingConstants;
public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
}
@Override
- AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException {
+ AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws DocumentedException {
XmlElement firstChild = configNodes.get(0);
Preconditions.checkState(configNodes.size() == 1, "This element should be present only once " + firstChild
return AttributeConfigElement.create(getNullableDefault(), resolve(firstChild));
}
- private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) throws NetconfDocumentedException{
- XmlElement typeElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY);
+ private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) throws DocumentedException{
+ XmlElement typeElement = firstChild.getOnlyChildElementWithSameNamespace(XmlMappingConstants.TYPE_KEY);
Map.Entry<String, String> prefixNamespace = typeElement.findNamespaceOfTextContent();
String serviceName = checkPrefixAndExtractServiceName(typeElement, prefixNamespace);
- XmlElement nameElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.NAME_KEY);
+ XmlElement nameElement = firstChild.getOnlyChildElementWithSameNamespace(XmlMappingConstants.NAME_KEY);
String dependencyName = nameElement.getTextContent();
return new ObjectNameAttributeMappingStrategy.MappedDependency(prefixNamespace.getValue(), serviceName,
dependencyName);
}
- public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry<String, String> prefixNamespace) throws NetconfDocumentedException {
+ public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry<String, String> prefixNamespace) throws DocumentedException {
String serviceName = typeElement.getTextContent();
Preconditions.checkNotNull(prefixNamespace.getKey(), "Service %s value cannot be linked to namespace",
- XmlNetconfConstants.TYPE_KEY);
+ XmlMappingConstants.TYPE_KEY);
if(prefixNamespace.getKey().isEmpty()) {
return serviceName;
} else {
String prefix = prefixNamespace.getKey() + PREFIX_SEPARATOR;
Preconditions.checkState(serviceName.startsWith(prefix),
- "Service %s not correctly prefixed, expected %s, but was %s", XmlNetconfConstants.TYPE_KEY, prefix,
+ "Service %s not correctly prefixed, expected %s, but was %s", XmlMappingConstants.TYPE_KEY, prefix,
serviceName);
serviceName = serviceName.substring(prefix.length());
return serviceName;
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
+import org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping;
+import org.opendaylight.controller.config.facade.xml.mapping.attributes.AttributeIfcSwitchStatement;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributeIfcSwitchStatement;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditConfig;
public class ObjectXmlReader extends AttributeIfcSwitchStatement<AttributeReadingStrategy> {
private String key;
- private Map<String, Map<Date, EditConfig.IdentityMapping>> identityMap;
+ private Map<String, Map<Date, IdentityMapping>> identityMap;
- public Map<String, AttributeReadingStrategy> prepareReading(Map<String, AttributeIfc> yangToAttrConfig, Map<String, Map<Date,EditConfig.IdentityMapping>> identityMap) {
+ public Map<String, AttributeReadingStrategy> prepareReading(Map<String, AttributeIfc> yangToAttrConfig, Map<String, Map<Date, IdentityMapping>> identityMap) {
Map<String, AttributeReadingStrategy> strategies = Maps.newHashMap();
this.identityMap = identityMap;
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
import com.google.common.base.Preconditions;
import java.util.List;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
public class SimpleAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
public SimpleAttributeReadingStrategy(String nullableDefault) {
}
@Override
- AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException {
+ AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws DocumentedException {
XmlElement xmlElement = configNodes.get(0);
Preconditions.checkState(configNodes.size() == 1, "This element should be present only once " + xmlElement