Commit 6df5f305 authored by Georgios P. Katsikas's avatar Georgios P. Katsikas
Browse files

Merge branch 'pr-policy' into 'develop'

refactor: bring policy to its new form

See merge request !427
parents ee1b4511 6e1d0a0b
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@ syntax = "proto3";
package policy;

import "context.proto";
import "policy_condition.proto";
import "policy_action.proto";
import "monitoring.proto"; // to be migrated to: "kpi_manager.proto"

service PolicyService {
  rpc PolicyAddService (PolicyRuleService) returns (PolicyRuleState) {}
@@ -36,8 +34,8 @@ enum PolicyRuleStateEnum {
  POLICY_FAILED = 1;        // Rule failed
  POLICY_INSERTED = 2;      // Rule is just inserted
  POLICY_VALIDATED = 3;     // Rule content is correct
  POLICY_PROVISIONED = 4;   // Rule subscribed to Monitoring
  POLICY_ACTIVE = 5;        // Rule is currently active (alarm is just thrown by Monitoring)
  POLICY_PROVISIONED = 4;   // Rule subscribed to Analyzer
  POLICY_ACTIVE = 5;        // Rule is currently active (alarm is just thrown by Analyzer)
  POLICY_ENFORCED = 6;      // Rule action is successfully enforced
  POLICY_INEFFECTIVE = 7;   // The applied rule action did not work as expected
  POLICY_EFFECTIVE = 8;     // The applied rule action did work as expected
@@ -45,24 +43,26 @@ enum PolicyRuleStateEnum {
  POLICY_REMOVED = 10;      // Operator requires to remove a policy
}

message PolicyRuleState {
  PolicyRuleStateEnum policyRuleState = 1;
  string policyRuleStateMessage = 2;
}

message PolicyRuleId {
  context.Uuid uuid = 1;
}

message PolicyRuleState {
  PolicyRuleStateEnum policyRuleState = 1;
  string policyRuleStateMessage = 2;
message PolicyRuleKpiId {
  context.Uuid policyRuleKpiUuid = 1;        // Same as defined in kpi_manager.proto
}

// Basic policy rule attributes
message PolicyRuleBasic {
  PolicyRuleId policyRuleId = 1;
  PolicyRuleState policyRuleState = 2; //policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
  uint32 priority = 3;
  monitoring.KpiId    kpiId       = 4;  // to be migrated to: "kpi_manager.KpiId"

  // Event-Condition-Action (ECA) model
  repeated PolicyRuleAction actionList = 5;        // One or more actions should be applied
  PolicyRuleId policyRuleId = 1;                  // Unique rule ID
  PolicyRuleState policyRuleState = 2;            // Rule lifecycle information
  uint32 policyRulePriority = 3;                  // The priority of this rule
  repeated PolicyRuleAction actionList = 4;       // One or more actions should be applied
  repeated PolicyRuleKpiId policyRuleKpiList = 5; // List of KPIs associated with this policy
}

// Service-oriented policy rule
+0 −5
Original line number Diff line number Diff line
@@ -35,8 +35,3 @@ message PolicyRuleActionConfig {
  string action_key = 1;
  string action_value = 2;
}

// message PolicyRuleAction {
//   PolicyRuleActionEnum action = 1;
//   repeated string parameters = 2;
// }

proto/policy_condition.proto

deleted100644 → 0
+0 −43
Original line number Diff line number Diff line
// Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";
package policy;

import "monitoring.proto"; // to be migrated to: "kpi_manager.proto"

// Condition
message PolicyRuleCondition {
  monitoring.KpiId    kpiId             = 1;  // to be migrated to: "kpi_manager.KpiId"
  NumericalOperator   numericalOperator = 2;
  monitoring.KpiValue kpiValue          = 3;
}

// Operator to be used when comparing Kpis with condition values
enum NumericalOperator {
  POLICYRULE_CONDITION_NUMERICAL_UNDEFINED = 0;          // Kpi numerical operator undefined
  POLICYRULE_CONDITION_NUMERICAL_EQUAL = 1;              // Kpi is equal with value
  POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL = 2;          // Kpi is not equal with value
  POLICYRULE_CONDITION_NUMERICAL_LESS_THAN = 3;          // Kpi is less than value
  POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL = 4;    // Kpi is less than or equal with value
  POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN = 5;       // Kpi is greater than value
  POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL = 6; // Kpi is less than or equal with value
}

// Operator to be used when evaluating each condition
enum BooleanOperator {
  POLICYRULE_CONDITION_BOOLEAN_UNDEFINED = 0;  // Boolean operator undefined
  POLICYRULE_CONDITION_BOOLEAN_AND = 1;        // Boolean AND operator
  POLICYRULE_CONDITION_BOOLEAN_OR = 2;         // Boolean OR operator
}
 No newline at end of file
+26 −642

File changed.

Preview size limit exceeded, changes collapsed.

+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ public class ContextGatewayImpl implements ContextGateway {

    @Override
    public Uni<String> setPolicyRule(PolicyRule policyRule) {
        // return Uni.createFrom().item("571eabc1-0f59-48da-b608-c45876c3fa8a");
        final var serializedPolicyRuleBasic = serializer.serialize(policyRule);

        return streamingDelegateContextPolicy
Loading