Commit 2c7babf2 authored by Georgios P. Katsikas's avatar Georgios P. Katsikas Committed by Georgios P. Katsikas
Browse files

refactor: bring policy to its new form

parent ee1b4511
Loading
Loading
Loading
Loading
+5 −9
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
@@ -57,12 +55,10 @@ message PolicyRuleState {
// 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"
  PolicyRuleState policyRuleState = 2;
  uint32 policyRulePriority = 3;

  // Event-Condition-Action (ECA) model
  repeated PolicyRuleAction actionList = 5;        // One or more actions should be applied
  repeated PolicyRuleAction actionList = 4;  // One or more actions should be applied
}

// 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
+5 −631

File changed.

Preview size limit exceeded, changes collapsed.

+0 −51
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.
 */

package org.etsi.tfs.policy.monitoring;

import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import org.etsi.tfs.policy.context.model.Empty;
import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor;
import org.etsi.tfs.policy.monitoring.model.AlarmResponse;
import org.etsi.tfs.policy.monitoring.model.AlarmSubscription;
import org.etsi.tfs.policy.monitoring.model.KpiDescriptor;
import org.etsi.tfs.policy.monitoring.model.MonitorKpiRequest;
import org.etsi.tfs.policy.monitoring.model.SubsDescriptor;
import org.etsi.tfs.policy.monitoring.model.SubsResponse;

public interface MonitoringGateway {

    Uni<String> setKpi(KpiDescriptor kpiDescriptor);

    Uni<KpiDescriptor> getKpiDescriptor(String kpiId);

    Uni<Empty> monitorKpi(MonitorKpiRequest monitorKpiRequest);

    Multi<SubsResponse> setKpiSubscription(SubsDescriptor subsDescriptor);

    Uni<SubsDescriptor> getSubsDescriptor(String subscriptionId);

    Uni<String> setKpiAlarm(AlarmDescriptor alarmDescriptor);

    Uni<AlarmDescriptor> getAlarmDescriptor(String alarmId);

    Multi<AlarmResponse> getAlarmResponseStream(AlarmSubscription alarmSubscription);

    Uni<Empty> deleteAlarm(String deviceId);

    Uni<Empty> deleteKpi(String kpiId);
}
Loading