Andrew kennedy; Cloudsoft; November 2016
This is a Brooklyn DSL enhancement to allow specifying entities in a blueprint using a query language similar to XPath 1 or JSONPath 2 that would give much greater flexibility than the current system.
The basic EQL syntax is described in the following sections.
The identity of an entity can be specified by the 'entity.id' sensor, the 'catalog.id' sensor or its display name. The current entity is the context in which the query is executing. If the query is executed as part of a policy or enricher, the context is the owning entity.
./one
- All entities named one that are siblings of the current entity
one
- All entities named one that are siblings of the current entity
//one
- All entities named one
.//one
- All entities named one that are descendants of the current entity
/one
- All top level entities named one
/*/one
- All second level entities named one
//*
- All entities
*
- All siblings of the current entity
.
- The current entity
..
- The current entities parent
one/two
- All entities named two that are children of entities named one that are siblings of the current entity
one//two
- All entities named two that are descendants of entities named one that are siblings of the current entity
one/*/two
- All entities named two that are grand-children of entities named one that are siblings of the current entity
one/*
- All entities that are children of entities named one that are siblings of the current entity
one[0]
- The first entity named one that is a sibling of the current entity
one[1]
- The second entity named one that is a sibling of the current entity
one[*]
- The last entity named one that is a sibling of the current entity
*[0]
- The first entity that is a sibling of the current entity
/[0]
- The first top-level entity
one(sensor)
- All entities named one that are a sibling of the current entity and have sensor sensor set to a truth-like value
one(sensor=value)
- All entities named one that are a sibling of the current entity and have sensor sensor set to value
one(@config)
- All entities named one that are a sibling of the current entity and have config key config set to a truth-like value
one(@config=value)
- All entities named one that are a sibling of the current entity and have config key config set to value
*(sensor=value)
- All entities that are siblings of the current entity and have sensor sensor set to value
//*(sensor=value)
- All entities that have sensor sensor set to value
//*(sensor=value)[0]
- The first entity that has sensor sensor set to value
$brooklyn:query("/*/node-name(@config.key=value)/*[3]").attributeWhenReady("sensor.name")
- The third child of any child of the root entity that is a named node-name with config config.key set to value.
$brooklyn:query("//cluster-name//service-name(service.isUp)")
- The service-name entities that have the service.isUp sensor set and are descendants of cluster-name entites.
This will be implemented as a new $brooklyn
DSL command named query
which will return the selected entity (or the first of the set of selected entities) as a DslComponent
. Further implementation details are yet to be determined.