Commit 10fd6c85 authored by Pablo Armingol's avatar Pablo Armingol
Browse files

Merge branch 'develop' of https://labs.etsi.org/rep/tfs/controller into feat/tid-bgp

parents ff059e4c 3cce9755
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -202,6 +202,7 @@ enum DeviceDriverEnum {
  DEVICEDRIVER_IETF_L2VPN = 7;
  DEVICEDRIVER_GNMI_OPENCONFIG = 8;
  DEVICEDRIVER_FLEXSCALE = 9;
  DEVICEDRIVER_IETF_ACTN = 10;
}

enum DeviceOperationalStatusEnum {
+32 −0
Original line number Diff line number Diff line
#!/bin/bash -eu    
# 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.
    
    
export JAVA_COMPONENTS="ztp policy"

export TFS_ROOT_DIR=$(dirname $(dirname $(realpath $0)))
    
for COMPONENT in $JAVA_COMPONENTS; do
  echo "\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/"
  echo
  echo "[TFS] Now building" $COMPONENT
  echo
  echo "\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/"
  cd $TFS_ROOT_DIR/src/$COMPONENT
    
  ./mvnw spotless:apply
  ./mvnw install -DskipUTs
done
+25 −0
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.


PROJECTDIR=`pwd`

cd $PROJECTDIR/src
RCFILE=$PROJECTDIR/coverage/.coveragerc

# Run unitary tests and analyze coverage of code at same time
# helpful pytest flags: --log-level=INFO -o log_cli=true --verbose --maxfail=1 --durations=0
coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    device/tests/test_unitary_ietf_actn.py
+25 −0
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.


PROJECTDIR=`pwd`

cd $PROJECTDIR/src
RCFILE=$PROJECTDIR/coverage/.coveragerc

# Run unitary tests and analyze coverage of code at same time
# helpful pytest flags: --log-level=INFO -o log_cli=true --verbose --maxfail=1 --durations=0
coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    nbi/tests/test_debug_api.py
+106 −55
Original line number Diff line number Diff line
@@ -25,12 +25,13 @@ from common.proto.context_pb2 import (
    Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList,
    Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList)
from common.proto.context_pb2_grpc import ContextServiceServicer
from common.proto.policy_pb2 import PolicyRule, PolicyRuleId, PolicyRuleIdList, PolicyRuleList
from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string
from common.tools.object_factory.Device import json_device_id
from common.tools.object_factory.Link import json_link_id
from .InMemoryObjectDatabase import InMemoryObjectDatabase
from .MockMessageBroker import (
    TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY,
    TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY, TOPIC_POLICY,
    MockMessageBroker, notify_event)

LOGGER = logging.getLogger(__name__)
@@ -164,10 +165,12 @@ class MockServicerImpl_Context(ContextServiceServicer):
            rw_request = Topology()
            rw_request.CopyFrom(request)

            # pylint: disable=no-member
            del rw_request.device_ids[:]
            for device_uuid in sorted(device_uuids):
                rw_request.device_ids.append(DeviceId(**json_device_id(device_uuid)))

            # pylint: disable=no-member
            del rw_request.link_ids[:]
            for link_uuid in sorted(link_uuids):
                rw_request.link_ids.append(LinkId(**json_link_id(link_uuid)))
@@ -181,7 +184,9 @@ class MockServicerImpl_Context(ContextServiceServicer):
            if _topology_id.topology_uuid.uuid == topology_uuid: break
        else:
            # topology not found, add it
            context_.topology_ids.add().topology_uuid.uuid = topology_uuid
            topology_id = context_.topology_ids.add()
            topology_id.context_id.context_uuid.uuid = context_uuid
            topology_id.topology_uuid.uuid = topology_uuid

        LOGGER.debug('[SetTopology] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply
@@ -195,7 +200,8 @@ class MockServicerImpl_Context(ContextServiceServicer):

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _topology_id in context_.topology_ids:
            if _topology_id.topology_uuid.uuid == topology_uuid:
            if _topology_id.context_id.context_uuid.uuid != context_uuid: continue
            if _topology_id.topology_uuid.uuid != topology_uuid: continue
            context_.topology_ids.remove(_topology_id)
            break

@@ -423,7 +429,9 @@ class MockServicerImpl_Context(ContextServiceServicer):
            if _slice_id.slice_uuid.uuid == slice_uuid: break
        else:
            # slice not found, add it
            context_.slice_ids.add().slice_uuid.uuid = slice_uuid
            slice_id = context_.slice_ids.add()
            slice_id.context_id.context_uuid.uuid = context_uuid
            slice_id.slice_uuid.uuid = slice_uuid

        LOGGER.debug('[SetSlice] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply
@@ -437,7 +445,8 @@ class MockServicerImpl_Context(ContextServiceServicer):

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _slice_id in context_.slice_ids:
            if _slice_id.slice_uuid.uuid == slice_uuid:
            if _slice_id.context_id.context_uuid.uuid != context_uuid: continue
            if _slice_id.slice_uuid.uuid != slice_uuid: continue
            context_.slice_ids.remove(_slice_id)
            break

@@ -515,7 +524,9 @@ class MockServicerImpl_Context(ContextServiceServicer):
            if _service_id.service_uuid.uuid == service_uuid: break
        else:
            # service not found, add it
            context_.service_ids.add().service_uuid.uuid = service_uuid
            service_id = context_.service_ids.add()
            service_id.context_id.context_uuid.uuid = context_uuid
            service_id.service_uuid.uuid = service_uuid

        LOGGER.debug('[SetService] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply
@@ -529,7 +540,8 @@ class MockServicerImpl_Context(ContextServiceServicer):

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _service_id in context_.service_ids:
            if _service_id.service_uuid.uuid == service_uuid:
            if _service_id.context_id.context_uuid.uuid != context_uuid: continue
            if _service_id.service_uuid.uuid != service_uuid: continue
            context_.service_ids.remove(_service_id)
            break

@@ -615,3 +627,42 @@ class MockServicerImpl_Context(ContextServiceServicer):
    def GetConnectionEvents(self, request : Empty, context : grpc.ServicerContext) -> Iterator[ConnectionEvent]:
        LOGGER.debug('[GetConnectionEvents] request={:s}'.format(grpc_message_to_json_string(request)))
        for message in self.msg_broker.consume({TOPIC_CONNECTION}): yield ConnectionEvent(**json.loads(message.content))

    def ListPolicyRuleIds(self, request : Empty, context : grpc.ServicerContext):   # pylint: disable=unused-argument
        LOGGER.debug('[ListPolicyRuleIds] request={:s}'.format(grpc_message_to_json_string(request)))
        reply = PolicyRuleIdList(policyRuleIdList=[
            getattr(policy_rule, policy_rule.WhichOneof('policy_rule')).policyRuleBasic.policyRuleId
            for policy_rule in self.obj_db.get_entries('policy')
        ])
        LOGGER.debug('[ListPolicyRuleIds] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

    def ListPolicyRules(self, request : Empty, context : grpc.ServicerContext):     # pylint: disable=unused-argument
        LOGGER.debug('[ListPolicyRules] request={:s}'.format(grpc_message_to_json_string(request)))
        reply = PolicyRuleList(policyRules=self.obj_db.get_entries('policy'))
        LOGGER.debug('[ListPolicyRules] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

    def GetPolicyRule(self, request : PolicyRuleId, context : grpc.ServicerContext):
        LOGGER.debug('[GetPolicyRule] request={:s}'.format(grpc_message_to_json_string(request)))
        reply = self.obj_db.get_entry('policy_rule', request.uuid.uuid, context)
        LOGGER.debug('[GetPolicyRule] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

    def SetPolicyRule(self, request : PolicyRule, context : grpc.ServicerContext):  # pylint: disable=unused-argument
        LOGGER.debug('[SetPolicyRule] request={:s}'.format(grpc_message_to_json_string(request)))
        policy_type = request.WhichOneof('policy_rule')
        policy_uuid = getattr(request, policy_type).policyRuleBasic.policyRuleId.uuid.uuid
        rule_id_field = '{:s}.policyRuleBasic.policyRuleId'.format(policy_type)
        reply, _ = self._set(request, 'policy', policy_uuid, rule_id_field, TOPIC_POLICY)
        LOGGER.debug('[SetPolicyRule] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

    def RemovePolicyRule(self, request : PolicyRuleId, context : grpc.ServicerContext):
        LOGGER.debug('[RemovePolicyRule] request={:s}'.format(grpc_message_to_json_string(request)))
        policy_type = request.WhichOneof('policy_rule')
        policy_uuid = getattr(request, policy_type).policyRuleBasic.policyRuleId.uuid.uuid
        rule_id_field = '{:s}.policyRuleBasic.policyRuleId'.format(policy_type)
        reply = self._del(request, 'policy', policy_uuid, rule_id_field, TOPIC_CONTEXT, context)
        LOGGER.debug('[RemovePolicyRule] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply
Loading