You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

POMBA Validation Rules

The POMBA Validation Service comes with a set of rules that verify the data provided from the supported context builders. The rules delivered are not exhaustive (refer to the POMBA Rules) but the architecture allows for operators to add their own rules or customize existing rules in order to fulfill their specific needs.

The rule sets are simply arbitrary files (of Groovy code) contained within project-specific directories that are read by the Validation Service on startup.

In ONAP, POMBA rules are delivered via the OOM project in default-rules.groovy.

Update Rules

The structure and logic of the validation rules can be found here: https://wiki.onap.org/display/DW/Validation+Service.

The purpose of this page is to show how to add rules to a POMBA deployment.

Create Rule Code

The first step to adding a rule is figuring out what to validate.

Given the following event that's been assembled and published by context-aggregator:

{
  "event-header": {
    "entity-type": "poa-entity",
    "event-type": "POA-EVENT",
    ...
  },
  "entity": {
    "poa-event": { ... },
    "context-list": {
      "aai": {
        "service": {
          "name": "my-service-name",
          "type": "abc123-1"
        }
      }
      "sdc": {
        "service": {
          "name": "other-service-name",
          "type": "abc123-#?"
        }
      }
    }
  }
}


Let's create a rule to validate the service type.  We can assume that the rule will be executed with a single type, so we'll create a short groovy script to test the rule logic.

boolean validateServiceNameRule(String type) {
   // accept only lowercase letters, digits and dashes
   return type != null && type.matches("[a-z,0-9,-]*")
}

Define the Rule

After verifying that the groovy method works, the rule definition can be created.  On the target system, locate the rules directory for the POMBA event type (POA-EVENT).

$ cd ~/oom/kubernetes/pomba/charts/pomba-validation-service/resources/bundleconfig/etc/rules/poa-event
$ ls
default-rules.groovy
$


Add the new rule definition to any rule file (currently only default-rules.groovy exists).  There can be more than 1 rule file, however a rule can only be defined once, then can subsequently be used multiple times.

Rule definitions look like the following code block.  Notice that only the content of the groovy method is in the validate section.  (For more examples, see Validation+Service#ValidationService-Examples)

rule {
  name        'validate-service-type'
  category    'INVALID_TYPE'
  description 'Invalid service type'
  errorText   'Invalid type - value contains invalid characters, only [a-z,0-9,-] accepted'
  severity    'MINOR'
  attributes  'type'
  validate    'type != null && type.matches("[a-z,0-9,-]*")'
}

Add useRule

Now add the useRule clause(s) in the validation section of all targeted entities.  Currently POMBA only has 1 entity defined for default rules.

useRule contains 2 fields:

  • name: contains the name of the newly created rule.
  • attributes: specifies the location of the attributes to be passed to the rule; it's a full JSON path, starting from the incoming event's entity section, see example event above.

Two useRules clauses are being added here to validate the service types from A&AI and SDNC.

entity {
  name 'POA-EVENT'
  indexing {
	indices 'default-rules'
  }
  validation {
    // AAI service type
	useRule {
	  name 'validate-service-type'
	  attributes 'context-list.aai.service.type'
	}
	// SDC service type
	useRule {
	  name 'validate-service-type'
	  attributes 'context-list.sdc.service.type'
	}
  }
}

Restart Validation

Lastly, restart onap-validation; the container will restart and load the new rules that were added.

$ docker ps
CONTAINER ID        IMAGE                                                                             ...
73dad4fc56b7        dockercentral.it.att.com:5100/com.att.ecomp.aai.dev/onap-validation:1902.0.5      ...
...
$ docker container restart 73dad4fc56b7


Deploy Updated Rules

  • No labels