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

feat: policy re-design and fixes

parent 4e2802f5
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -43,22 +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;
  uint32 policyRulePriority = 3;

  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
+22 −12
Original line number Diff line number Diff line
@@ -39,19 +39,9 @@ import org.etsi.tfs.policy.acl.AclRuleTypeEnum;
import org.etsi.tfs.policy.context.model.*;
import org.etsi.tfs.policy.kpi_sample_types.model.KpiSampleType;
import org.etsi.tfs.policy.policy.model.*;
import org.etsi.tfs.policy.policy.model.PolicyRule;
import org.etsi.tfs.policy.policy.model.PolicyRuleAction;
import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig;
import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum;
import org.etsi.tfs.policy.policy.model.PolicyRuleBasic;
import org.etsi.tfs.policy.policy.model.PolicyRuleDevice;
import org.etsi.tfs.policy.policy.model.PolicyRuleService;
import org.etsi.tfs.policy.policy.model.PolicyRuleState;
import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum;
import org.etsi.tfs.policy.policy.model.PolicyRuleTypeDevice;
import org.etsi.tfs.policy.policy.model.PolicyRuleTypeService;
import policy.Policy;
import policy.Policy.PolicyRuleId;
import policy.Policy.PolicyRuleKpiId;
import policy.PolicyAction;

@Singleton
@@ -96,6 +86,19 @@ public class Serializer {
        return policyRuleId.getUuid().getUuid();
    }

    public PolicyRuleKpiId serializePolicyRuleKpiId(String expectedPolicyRuleKpiId) {
        final var builder = PolicyRuleKpiId.newBuilder();
        final var uuid = serializeUuid(expectedPolicyRuleKpiId);

        builder.setPolicyRuleKpiUuid(uuid);

        return builder.build();
    }

    public String deserialize(PolicyRuleKpiId policyRuleKpiId) {
        return policyRuleKpiId.getPolicyRuleKpiUuid().getUuid();
    }

    public ContextOuterClass.TopologyId serialize(TopologyId topologyId) {
        final var builder = ContextOuterClass.TopologyId.newBuilder();

@@ -1523,16 +1526,20 @@ public class Serializer {
        final var policyRuleState = policyRuleBasic.getPolicyRuleState();
        final var policyRulePriority = policyRuleBasic.getPolicyRulePriority();
        final var policyRuleActions = policyRuleBasic.getPolicyRuleActions();
        final var policyRuleKPIs = policyRuleBasic.getPolicyRuleKPIs();

        final var serializedPolicyRuleId = serializePolicyRuleId(policyRuleId);
        final var serializedPolicyRuleState = serialize(policyRuleState);
        final var serializedPolicyRuleActions =
                policyRuleActions.stream().map(this::serialize).collect(Collectors.toList());
        final var serializedPolicyRuleKPIs =
                policyRuleKPIs.stream().map(this::serializePolicyRuleKpiId).collect(Collectors.toList());

        builder.setPolicyRuleId(serializedPolicyRuleId);
        builder.setPolicyRuleState(serializedPolicyRuleState);
        builder.setPolicyRulePriority(policyRulePriority);
        builder.addAllActionList(serializedPolicyRuleActions);
        builder.addAllPolicyRuleKpiList(serializedPolicyRuleKPIs);

        return builder.build();
    }
@@ -1542,14 +1549,17 @@ public class Serializer {
        final var serializedPolicyRuleState = serializedPolicyRuleBasic.getPolicyRuleState();
        final var policyRulePriority = serializedPolicyRuleBasic.getPolicyRulePriority();
        final var serializedPolicyRuleActions = serializedPolicyRuleBasic.getActionListList();
        final var serializedPolicyRuleKPIs = serializedPolicyRuleBasic.getPolicyRuleKpiListList();

        final var policyRuleId = deserialize(serializedPolicyRuleId);
        final var policyRuleState = deserialize(serializedPolicyRuleState);
        final var policyRuleActions =
                serializedPolicyRuleActions.stream().map(this::deserialize).collect(Collectors.toList());
        final var policyRuleKPIs =
                serializedPolicyRuleKPIs.stream().map(this::deserialize).collect(Collectors.toList());

        return new PolicyRuleBasic(
                policyRuleId, policyRuleState, policyRulePriority, policyRuleActions);
                policyRuleId, policyRuleState, policyRulePriority, policyRuleActions, policyRuleKPIs);
    }

    public Policy.PolicyRuleService serialize(PolicyRuleService policyRuleService) {
+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
+39 −1
Original line number Diff line number Diff line
@@ -20,8 +20,46 @@ public enum KpiSampleType {
    UNKNOWN,
    PACKETS_TRANSMITTED,
    PACKETS_RECEIVED,
    PACKETS_DROPPED,
    BYTES_TRANSMITTED,
    BYTES_RECEIVED,
    BYTES_DROPPED,
    LINK_TOTAL_CAPACITY_GBPS,
    LINK_USED_CAPACITY_GBPS
    LINK_USED_CAPACITY_GBPS,
    ML_CONFIDENCE,
    OPTICAL_SECURITY_STATUS,
    L3_UNIQUE_ATTACK_CONNS,
    L3_TOTAL_DROPPED_PACKTS,
    L3_UNIQUE_ATTACKERS,
    L3_UNIQUE_COMPROMISED_CLIENTS,
    L3_SECURITY_STATUS_CRYPTO,
    SERVICE_LATENCY_MS,
    PACKETS_TRANSMITTED_AGG_OUTPUT,
    PACKETS_RECEIVED_AGG_OUTPUT,
    PACKETS_DROPPED_AGG_OUTPUT,
    BYTES_TRANSMITTED_AGG_OUTPUT,
    BYTES_RECEIVED_AGG_OUTPUT,
    BYTES_DROPPED_AGG_OUTPUT,
    SERVICE_LATENCY_MS_AGG_OUTPUT,
    INT_SEQ_NUM,
    INT_TS_ING,
    INT_TS_EGR,
    INT_HOP_LAT,
    INT_PORT_ID_ING,
    INT_PORT_ID_EGR,
    INT_QUEUE_OCCUP,
    INT_QUEUE_ID,
    INT_HOP_LAT_SW01,
    INT_HOP_LAT_SW02,
    INT_HOP_LAT_SW03,
    INT_HOP_LAT_SW04,
    INT_HOP_LAT_SW05,
    INT_HOP_LAT_SW06,
    INT_HOP_LAT_SW07,
    INT_HOP_LAT_SW08,
    INT_HOP_LAT_SW09,
    INT_HOP_LAT_SW10,
    INT_LAT_ON_TOTAL,
    INT_IS_DROP,
    INT_DROP_REASON
}
+0 −2
Original line number Diff line number Diff line
@@ -39,8 +39,6 @@ public class AddPolicyDeviceImpl {

    @Inject private PolicyRuleConditionValidator policyRuleConditionValidator;

    @Inject private CommonPolicyServiceImpl commonPolicyServiceImpl;

    @Inject private ContextService contextService;

    public Uni<List<Boolean>> returnInvalidDeviceIds(List<String> deviceIds) {
Loading