Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This subsystem continues to use the OSGi mechanism to persistently track configurable parameters in the local instance context and to notify components when the parameters change. In this way the application components can continue to use the standard and well-understood OSGi configuration via ComponentContext. Furthermore, if components use the Apache Felix compile-time @Parameter @Property annotation, the ONOS build process generates a configuration catalog as a jar/bundle resource, which the component can register, allowing the ONOS administrator to see what parameters can be configured. The component configuration subsystem will then make sure that when a change is made on one ONOS instance, the same change will be propagated across the entire ONOS cluster and reflected on all ONOS instances in that cluster.

...

To allow parameters to be configurable, components must first designate their fields using the @ParameterProperty annotation as follows:

Code Block
private static final int DEFAULT_MAX_EVENTS = 1000;

@Property(name = "maxEvents", intValue = DEFAULT_MAX_EVENTS,
        label = "Maximum number of events to accumulate")
private int maxEvents = DEFAULT_MAX_EVENTS;

private static final int DEFAULT_EMAIL = "onos-dev@onosproject.org";

@Property(name = "notificationEmail", value = DEFAULT_EMAIL,
          label = "Notification email address")
private String notificationEmail = DEFAULT_EMAIL;

In order to allow these parameters to be changed dynamically, a component should define a modified method, annotated using @Modify@Modified compile-time annotation as in this example:

Code Block
@Modified
public booleanvoid modified(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();

    String s = Tools.get(properties, "newMaxEvents");
    maxEvents = Strings.isNullOrEmpty(s) ? DEFAULT_MAX_EVENTS : Integer.parseInt(s.trim())

    s = Tools.get(properties, "notificationEmail");
    notificationEmail = Strings.isNullOrEmpty(s) ? DEFAULT_EMAIL : s;
    ...
}

...

Modules that contain configurable components should contain the following configuration of onos-maven-plugin:

Code Block
<build>
    <plugins>
        ...
        <plugin>
            <groupId>org.onosproject</groupId>
            <artifactId>onos-maven-plugin</artifactId>
            <version>1.1.0<9</version>
        <executions>
        <executions>
    <execution>
            <execution>
    <id>app</id>
                <phase>generate-resources</phase>
                    <goals>
                        <goal>cfg</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        ...
    </plugins>
</build>

This Maven plugin will generate the jar/bundle resource containing the dictionary of configurable properties using the annotations. This is then used by the CLI, and in the future GUI, to present the ONOS administrator with a list of configurable parameters, description of their purpose, their current and default values. This configuration is already contained in the root ONOS pom.xml and consequently any child subproject will inherit this capability. Therefore, only applications outside of the ONOS source-code will need to include the above in their Maven pom.xml file(s).

...

  • cfg - lists class names of all configurable components that have registered with the subsystem
  • cfg get - lists all class names and their properties as a full dump
  • cfg get componentClass - lists all properties of the specified class
  • cfg get componentClass name - lists the value of the specified component property (not implemented yet)
  • cfg set componentClass name value - sets the value of the specified component property
  • cfg set componentClass name - clears the value of the specified component property restoring it to its default value

...