[ONOS-6410] flexible configuration datastore specifier.
- added completer to netconf-config-get
Change-Id: I7cc88637bd51d9f4bea7d906346ffacfbd8706a6
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
index 4fffde6..6638e32 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
@@ -93,31 +93,75 @@
String requestSync(String request) throws NetconfException;
/**
- * Retrives the specified configuration.
+ * Retrieves the specified configuration.
*
* @param netconfTargetConfig the type of configuration to retrieve.
* @return specified configuration.
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- String getConfig(TargetConfig netconfTargetConfig) throws NetconfException;
+ default String getConfig(DatastoreId netconfTargetConfig) throws NetconfException {
+ // default implementation provided for backward compatibility
+ // this API is the one, which should be implemented
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return getConfig(netconfTargetConfig.id());
+ }
/**
- * Retrives the specified configuration.
+ * Retrieves the specified configuration.
*
* @param netconfTargetConfig the type of configuration to retrieve.
* @return specified configuration.
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
* @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfig enum parameter instead
+ * org.onosproject.netconf.TargetConfiguration parameter instead
*/
@Deprecated
- String getConfig(String netconfTargetConfig) throws NetconfException;
+ default String getConfig(TargetConfig netconfTargetConfig) throws NetconfException {
+ return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
+ }
+
+ /**
+ * Retrieves the specified configuration.
+ *
+ * @param netconfTargetConfig the type of configuration to retrieve.
+ * @return specified configuration.
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ * @deprecated - 1.10.0 Kingfisher use method overload that accepts
+ * org.onosproject.netconf.TargetConfiguration parameter instead
+ */
+ @Deprecated
+ default String getConfig(String netconfTargetConfig) throws NetconfException {
+ return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
+ }
/**
- * Retrives part of the specivied configuration based on the filterSchema.
+ * Retrieves part of the specified configuration based on the filterSchema.
+ *
+ * @param netconfTargetConfig the type of configuration to retrieve.
+ * @param configurationFilterSchema XML schema to filter the configuration
+ * elements we are interested in
+ * @return device running configuration.
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ */
+ default String getConfig(DatastoreId netconfTargetConfig,
+ String configurationFilterSchema)
+ throws NetconfException {
+ // default implementation provided for backward compatibility
+ // this API is the one, which should be implemented
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return getConfig(netconfTargetConfig.id(), configurationFilterSchema);
+ }
+
+
+ /**
+ * Retrieves part of the specified configuration based on the filterSchema.
*
* @param netconfTargetConfig the type of configuration to retrieve.
* @param configurationFilterSchema XML schema to filter the configuration
@@ -129,11 +173,14 @@
* org.onosproject.netconf.TargetConfig enum parameter instead
*/
@Deprecated
- String getConfig(String netconfTargetConfig, String configurationFilterSchema)
- throws NetconfException;
+ default String getConfig(String netconfTargetConfig, String configurationFilterSchema)
+ throws NetconfException {
+ return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
+ configurationFilterSchema);
+ }
/**
- * Retrives part of the specivied configuration based on the filterSchema.
+ * Retrieves part of the specified configuration based on the filterSchema.
*
* @param netconfTargetConfig the type of configuration to retrieve.
* @param configurationFilterSchema XML schema to filter the configuration
@@ -141,13 +188,19 @@
* @return device running configuration.
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
+ * @deprecated - 1.10.0 Kingfisher use method overload that accepts
+ * org.onosproject.netconf.TargetConfig enum parameter instead
*/
- String getConfig(TargetConfig netconfTargetConfig, String configurationFilterSchema)
- throws NetconfException;
+ @Deprecated
+ default String getConfig(TargetConfig netconfTargetConfig, String configurationFilterSchema)
+ throws NetconfException {
+ return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
+ configurationFilterSchema);
+ }
/**
- * Retrives part of the specified configuration based on the filterSchema.
+ * Retrieves part of the specified configuration based on the filterSchema.
*
* @param newConfiguration configuration to set
* @return true if the configuration was edited correctly
@@ -158,7 +211,26 @@
boolean editConfig(String newConfiguration) throws NetconfException;
/**
- * Retrives part of the specified configuration based on the filterSchema.
+ * Retrieves part of the specified configuration based on the filterSchema.
+ *
+ * @param netconfTargetConfig the targetConfiguration to change
+ * @param mode selected mode to change the configuration
+ * @param newConfiguration configuration to set
+ * @return true if the configuration was edited correctly
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ */
+ default boolean editConfig(DatastoreId netconfTargetConfig, String mode, String newConfiguration)
+ throws NetconfException {
+ // default implementation provided for backward compatibility
+ // this API is the one, which should be implemented
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return editConfig(netconfTargetConfig.id(), mode, newConfiguration);
+ }
+
+ /**
+ * Retrieves part of the specified configuration based on the filterSchema.
*
* @param netconfTargetConfig the targetConfiguration to change
* @param mode selected mode to change the configuration
@@ -167,14 +239,18 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
* @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfig enum parameter instead
+ * org.onosproject.netconf.TargetConfiguration enum parameter instead
*/
@Deprecated
- boolean editConfig(String netconfTargetConfig, String mode, String newConfiguration)
- throws NetconfException;
+ default boolean editConfig(String netconfTargetConfig, String mode, String newConfiguration)
+ throws NetconfException {
+ return editConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
+ mode,
+ newConfiguration);
+ }
/**
- * Retrives part of the specified configuration based on the filterSchema.
+ * Retrieves part of the specified configuration based on the filterSchema.
*
* @param netconfTargetConfig the targetConfiguration to change
* @param mode selected mode to change the configuration
@@ -182,9 +258,56 @@
* @return true if the configuration was edited correctly
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
+ * @deprecated - 1.10.0 Kingfisher use method overload that accepts
+ * org.onosproject.netconf.TargetConfiguration enum parameter instead
*/
- boolean editConfig(TargetConfig netconfTargetConfig, String mode, String newConfiguration)
- throws NetconfException;
+ @Deprecated
+ default boolean editConfig(TargetConfig netconfTargetConfig, String mode, String newConfiguration)
+ throws NetconfException {
+ return editConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
+ mode,
+ newConfiguration);
+ }
+
+ /**
+ * Copies the configuration between configuration datastores.
+ * <p>
+ * The target configuration can't be the running one
+ *
+ * @param destination configuration datastore
+ * @param source configuration datastore
+ * @return true if the configuration was copied correctly
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ */
+ default boolean copyConfig(DatastoreId destination, DatastoreId source)
+ throws NetconfException {
+ // default implementation provided for backward compatibility
+ // but this API should be implemented overriding the default
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return copyConfig(destination.id(), source.id());
+ }
+
+ /**
+ * Copies the new configuration, an Url or a complete configuration xml tree
+ * to the target configuration.
+ * The target configuration can't be the running one
+ *
+ * @param netconfTargetConfig the type of configuration to retrieve.
+ * @param newConfiguration configuration XML to set or URL tag to the configuration
+ * @return true if the configuration was copied correctly
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ */
+ default boolean copyConfig(DatastoreId netconfTargetConfig, String newConfiguration)
+ throws NetconfException {
+ // default implementation provided for backward compatibility
+ // but this API should be implemented overriding the default
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return copyConfig(netconfTargetConfig.id(), newConfiguration);
+ }
/**
* Copies the new configuration, an Url or a complete configuration xml tree
@@ -196,10 +319,7 @@
* @return true if the configuration was copied correctly
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfig enum parameter instead
*/
- @Deprecated
boolean copyConfig(String netconfTargetConfig, String newConfiguration)
throws NetconfException;
@@ -213,9 +333,45 @@
* @return true if the configuration was copied correctly
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
+ * @deprecated - 1.10.0 Kingfisher use method overload that accepts
+ * org.onosproject.netconf.TargetConfiguration enum parameter instead
*/
- boolean copyConfig(TargetConfig netconfTargetConfig, String newConfiguration)
- throws NetconfException;
+ @Deprecated
+ default boolean copyConfig(TargetConfig netconfTargetConfig, String newConfiguration)
+ throws NetconfException {
+ return copyConfig(TargetConfig.toDatastoreId(netconfTargetConfig), newConfiguration);
+ }
+
+ /**
+ * Deletes part of the specified configuration based on the filterSchema.
+ *
+ * @param netconfTargetConfig the name of the configuration to delete
+ * @return true if the configuration was copied correctly
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ */
+ default boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException {
+ // default implementation provided for backward compatibility
+ // this API is the one, which should be implemented
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return deleteConfig(netconfTargetConfig.id());
+ }
+
+ /**
+ * Deletes part of the specified configuration based on the filterSchema.
+ *
+ * @param netconfTargetConfig the name of the configuration to delete
+ * @return true if the configuration was deleted correctly
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ * @deprecated - 1.10.0 Kingfisher use method overload that accepts
+ * org.onosproject.netconf.TargetConfiguration enum parameter instead
+ */
+ @Deprecated
+ default boolean deleteConfig(String netconfTargetConfig) throws NetconfException {
+ return deleteConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
+ }
/**
* Deletes part of the specified configuration based on the filterSchema.
@@ -225,20 +381,12 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
* @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfig enum parameter instead
+ * org.onosproject.netconf.TargetConfiguration enum parameter instead
*/
@Deprecated
- boolean deleteConfig(String netconfTargetConfig) throws NetconfException;
-
- /**
- * Deletes part of the specified configuration based on the filterSchema.
- *
- * @param netconfTargetConfig the name of the configuration to delete
- * @return true if the configuration was copied correctly
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- */
- boolean deleteConfig(TargetConfig netconfTargetConfig) throws NetconfException;
+ default boolean deleteConfig(TargetConfig netconfTargetConfig) throws NetconfException {
+ return deleteConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
+ }
/**
* Starts subscription to the device's notifications.
@@ -266,12 +414,49 @@
/**
* Locks the specified configuration.
*
- * @param configType type of configuration to be locked
+ * @param datastore configuration datastore to be locked
* @return true if successful.
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- boolean lock(String configType) throws NetconfException;
+ default boolean lock(DatastoreId datastore) throws NetconfException {
+ // default implementation provided for backward compatibility
+ // this API is the one, which should be implemented
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return lock(datastore.id());
+ }
+
+ /**
+ * Locks the specified configuration.
+ *
+ * @param configType type of configuration to be locked
+ * @return true if successful.
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ * @deprecated - 1.10.0 Kingfisher use method overload that accepts
+ * org.onosproject.netconf.TargetConfiguration parameter instead
+ */
+ @Deprecated
+ default boolean lock(String configType) throws NetconfException {
+ return lock(TargetConfig.toDatastoreId(configType));
+ }
+
+ /**
+ * Unlocks the specified configuration.
+ *
+ * @param datastore configuration datastore to be unlocked
+ * @return true if successful.
+ * @throws NetconfException when there is a problem in the communication process on
+ * the underlying connection
+ */
+ default boolean unlock(DatastoreId datastore) throws NetconfException {
+ // default implementation provided for backward compatibility
+ // this API is the one, which should be implemented
+ // TODO default implementation here should be removed after
+ // deprecation of the other 2 variants.
+ return unlock(datastore.id());
+ }
/**
* Unlocks the specified configuration.
@@ -280,8 +465,13 @@
* @return true if successful.
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
+ * @deprecated - 1.10.0 Kingfisher use method overload that accepts
+ * org.onosproject.netconf.TargetConfiguration parameter instead
*/
- boolean unlock(String configType) throws NetconfException;
+ @Deprecated
+ default boolean unlock(String configType) throws NetconfException {
+ return unlock(TargetConfig.toDatastoreId(configType));
+ }
/**
* Locks the running configuration.
@@ -290,7 +480,9 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- boolean lock() throws NetconfException;
+ default boolean lock() throws NetconfException {
+ return lock(DatastoreId.RUNNING);
+ }
/**
* Unlocks the running configuration.
@@ -299,7 +491,9 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- boolean unlock() throws NetconfException;
+ default boolean unlock() throws NetconfException {
+ return unlock(DatastoreId.RUNNING);
+ }
/**
* Closes the Netconf session with the device.
@@ -372,6 +566,7 @@
Logger log = LoggerFactory.getLogger(NetconfSession.class);
log.error("Not implemented/exposed by the underlying session implementation");
}
+
/**
* Sets the ONOS side capabilities.
*