Commit 396d66f1 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-merge code cleanup and header fixing.

parent 97c50e87
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -50,10 +50,10 @@ spec:
            command: ["/bin/grpc_health_probe", "-addr=:10001"]
        resources:
          requests:
            cpu: 100m
            cpu: 250m
            memory: 512Mi
          limits:
            cpu: 150m
            cpu: 700m
            memory: 1024Mi
---
apiVersion: v1
@@ -93,7 +93,7 @@ spec:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 0.99
        averageUtilization: 0.80
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 120
+9 −8
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_m

LOGGER = logging.getLogger(__name__)

METRICS_POOL = MetricsPool("l3_attackmitigator", "RPC")
METRICS_POOL = MetricsPool('l3_attackmitigator', 'RPC')


class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
@@ -107,8 +107,8 @@ class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
        acl_entry.action.forward_action = AclForwardActionEnum.ACLFORWARDINGACTION_DROP
        acl_entry.action.log_action = AclLogActionEnum.ACLLOGACTION_NOLOG

        LOGGER.info("ACL Rule Set: %s", acl_rule_set)
        LOGGER.info("ACL Config Rule: %s", acl_config_rule)
        LOGGER.info("ACL Rule Set: %s", grpc_message_to_json_string(acl_rule_set))
        LOGGER.info("ACL Config Rule: %s", grpc_message_to_json_string(acl_config_rule))

        # Add the ACLRuleSet to the list of configured ACLRuleSets
        self.configured_acl_config_rules.append(acl_config_rule)
@@ -116,7 +116,7 @@ class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
        # Update the Service with the new ACL RuleSet
        service_reply: ServiceId = self.service_client.UpdateService(service_request)

        LOGGER.info("Service reply: %s", service_reply)
        LOGGER.info("Service reply: %s", grpc_message_to_json_string(service_reply))

        if service_reply != service_request.service_id:  # pylint: disable=no-member
            raise Exception("Service update failed. Wrong ServiceId was returned")
@@ -141,7 +141,7 @@ class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
        counter = 0
        service_id = request.service_id

        LOGGER.info("Service Id.:\n{}".format(service_id))
        LOGGER.info("Service Id.:\n{}".format(grpc_message_to_json_string(service_id)))

        LOGGER.info("Retrieving service from Context")
        while sentinel:
@@ -153,7 +153,7 @@ class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
                LOGGER.debug("Waiting 2 seconds", counter, e)
                time.sleep(2)

        LOGGER.info(f"Service with Service Id.: {service_id}\n{service}")
        LOGGER.info(f"Service with Service Id.: {grpc_message_to_json_string(service_id)}\n{grpc_message_to_json_string(service)}")

        LOGGER.info("Adding new rule to the service to block the attack")
        self.configure_acl_rule(
@@ -166,14 +166,15 @@ class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
            src_port=port_o,
            dst_port=port_d,
        )
        LOGGER.info("Service with new rule:\n{}".format(service))
        LOGGER.info("Service with new rule:\n{}".format(grpc_message_to_json_string(service)))

        LOGGER.info("Updating service with the new rule")
        self.service_client.UpdateService(service)
        service = self.context_client.GetService(service_id)

        LOGGER.info(
            "Service obtained from Context after updating with the new rule:\n{}".format(
                self.context_client.GetService(service_id)
                grpc_message_to_json_string(service)
            )
        )

+0 −25
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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.

# Set the variables for the remote host and destination directory
REMOTE_HOST="192.168.165.73"
DEST_DIR="/home/ubuntu/TeraflowDockerDistributed/l3_distributedattackdetector/proto"

# Copy the files to the remote host
sshpass -p "ubuntu" scp /home/ubuntu/tfs-ctrl-new/proto/src/python/l3_centralizedattackdetector_pb2.py "$REMOTE_HOST:$DEST_DIR"
sshpass -p "ubuntu" scp /home/ubuntu/tfs-ctrl-new/proto/src/python/l3_centralizedattackdetector_pb2_grpc.py "$REMOTE_HOST:$DEST_DIR"

sshpass -p "ubuntu" scp /home/ubuntu/tfs-ctrl-new/proto/src/python/l3_attackmitigator_pb2.py "$REMOTE_HOST:$DEST_DIR"
sshpass -p "ubuntu" scp /home/ubuntu/tfs-ctrl-new/proto/src/python/l3_attackmitigator_pb2_grpc.py "$REMOTE_HOST:$DEST_DIR"
+0 −22
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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.

pod=$(kubectl get pods -n "tfs" -l app=l3-centralizedattackdetectorservice | sed -n '2p' | cut -d " " -f1)
while true; do
    kubectl -n "tfs" cp $pod:prediction_accuracy.txt ./prediction_accuracy.txt
    clear
    cat prediction_accuracy.txt | tail -n 10
    sleep 1
done

tmp.yaml

deleted100644 → 0
+0 −0

Empty file deleted.