Copyright 2018 AT&T Intellectual Property. All rights reserved. Modifications Copyright (C) 2019 Nordix Foundation. This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE Full license text at https://creativecommons.org/licenses/by/4.0/legalcode

ONAP Control Loop Guard

A control loop guard is a YAML specification for creating policy guard for ControlLoop.

ONAP Control Loop Guard Features:

  • The Control Loop Guard can specify the frequency limiter and the blacklist of target entities but not both in the same Guard.
  • Two parts are incorporated. One is the common guard header including guard version while the other part is a set of guard policies.
  • The Control Loop Guard should contain at least one guard policies.
  • Each guard policy is bound to a specific Actor and Recipe.
  • Each guard policy should have at least one limit constraints which define how the guard policy should be enforced.
  • Supported Actors are APPC and SO.

This SDK helps build the YAML specification for ONAP Control Loop Guard.

Create Builder Object

To begin with, the ControlLoopGuardBuilder.Factory class has static methods that one should use to begin building a Control Loop Guard. It will return a ControlLoopGuardBuilder object that can then be used to continue to build and define the Control Loop Guard.

		ControlLoopGuardBuilder builder = ControlLoopGuardBuilder.Factory.buildControlLoopGuard(new Guard());

Add Guard Policy

After a guard builder has been created, the next step would be to add a guard policy to the newly created Control Loop Guard via the builder. To add a guard policy, use the addGuardPolicy() method.

		GuardPolicy policy = new GuardPolicy(
								"unique_guard_vUSP_1", 
								"APPC 5 Restart", 
								"We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am)",
								"APPC", 
								"Restart");	
		builder = builder.addGuardPolicy(policy);

Add Limit Constraint to a Guard Policy

The limit constraint defines the details of how to enforce the guard policy. Each limit constraint can contain two types of constraints - frequency limiter and black list. At least one type of constraints should be specified, otherwise the limit constraint will be counted as invalid. To add a limit constraint to an existing guard policy, use the addLimitConstraint() method.

		Map<String, String> time_in_range = new HashMap<String, String>();
		time_in_range.put("arg2", "PT5H");
		time_in_range.put("arg3", "PT24H");
		List<String> blacklist = new LinkedList<String>();
		blacklist.add("vm_name_1");
		blacklist.add("vm_name_2");
		Constraint cons = new Constraint(5, "PT15M", time_in_range, blacklist);
		builder = builder.addLimitConstraint(policy.id, cons);

Build the YAML Specification

When finished defining the Guard Policies, build the specification and analyze the Results.java

		Results results = builder.buildSpecification();
		if (results.isValid()) {
			System.out.println(results.getSpecification());
		} else {
			System.err.println("Builder failed");
			for (Message message : results.getMessages()) {
				System.err.println(message.getMessage());
			}
		}

Use the YAML Specification to Generate the XACML Guard Policies

Now that you have a valid YAML specification, call the method in PolicyGuardYamlToXacml.java to generate the XACML Guard Policies.

YAML Specification

The YAML specification has 2 sections to it: guard and guards. The guard section section is simply a header defining the version of this guard. The guards section is simply an array of GuardPolicy objects.

guard Object

Field NameTypeRequiredDescription
versionstringrequiredValue for this release if 2.0.0

guards array

The guards section is an array of GuardPolicy objects.

GuardPolicy Object

Field NameTypeRequiredDescription
idstringrequiredUnique ID for the policy.
namestringrequiredPolicy name
descriptionstringoptionalPolicy description
actorstringrequiredName of the actor for this operation: Example: APPC
recipestringrequiredName of recipe to be performed. Example "Restart"
limit_constraintsarray of constraint objectrequiredConstraints used to enforce the guard policy

The guard policy is bound to a specific recipe performed by the actor. When the Control Loop tries to perform the recipe operation by the actor, this guard policy should be evaluated against all the specified constraints. If any of the constraints will be violated, the operation should be abandoned.

constraint Object

Field NameTypeRequiredDescription
numintegerrequired if blacklist is not specifiedThe limited number of the same operations
durationstringrequired if blacklist is not specifiedTime window for counting the same operations
time_in_rangemap<string, string>optionalValid time spans for enforcing the guard policy
blacklistarray of stringrequired if num and duration are not specifiedA list of the entity names that should not be touched by the Control Loop

The first three attributes define the frequency limiter which means that only a limited number of the same operations can be allowed within each valid time window. The last attribute defines a blacklist of the target entities on which the Control Loop should not perform the operation.

The "duration" parameter should have one of the following values: [5min, 10min, 30min, 1h, 12h, 1d, 5d, 1w, 1mon].

Examples of YAML Control Loop Guards

vService-Frequency-Limiter-Guard vService-Blacklist-Guard ONAP-vDNS-Guard

vService Frequency Limiter Guard

guard:
  version: 2.0.0

guards:
  - id: unique_guard_vService_frequency_limiter
    name: APPC 5 Restart
    description: 
      We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am)
    actor: APPC
    recipe: Restart
    limit_constraints:
      - num: 5
        duration: PT15M
        time_in_range:
          arg2: PT5H
          arg3: PT24H	

vService Blacklist Guard

guard:
  version: 2.0.0

guards:
  - id: unique_guard_vService_blacklist
    name: APPC Restart Blacklist
    description: |
      We deny restart of the blacklisted targets (avoid midnight to 5am)
    actor: APPC
    recipe: Restart
    limit_constraints:
      - blacklist:
          - TargetName1
          - TargetName2
        time_in_range:
          arg2: 00:00:00-05:00
          arg3: 23:59:59-05:00

ONAP vDNS Guard

guard:
  version: 2.0.0

guards:
  - id: unique_guard_ONAP_vDNS_1
    name: SO Spinup
    description: We only spin up 1 instance over a 10 minute window
    actor: SO
    recipe: VF Module Create
    limit_constraints:
      - num: 1
        duration: PT10M