Commit e0bf1a2e authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Device - IETF ACTN Driver:

- Updated test script
- Completed unitary tests
- Improved driver's error handling
- Fixed handlers and RestApiClient
- Minor code fixings
- Rearranged data files
- Added required Python dependencies
- Corrected MockIetfActnSdnCtrl tool
parent 69b96fbc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,5 +20,6 @@ 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
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
anytree==2.8.0
APScheduler==3.10.1
cryptography==36.0.2
deepdiff==6.7.*
deepmerge==1.1.*
#fastcache==1.1.0
Jinja2==3.0.3
ncclient==0.6.13
+48 −27
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class IetfActnDriver(_Driver):
        with self.__lock:
            if self.__started.is_set(): return True
            try:
                self._rest_api_client.get('Check Credentials', '', [])
                self._rest_api_client.get('Check Credentials', '')
            except requests.exceptions.Timeout:
                LOGGER.exception('Timeout exception checking connectivity')
                return False
@@ -75,16 +75,23 @@ class IetfActnDriver(_Driver):
            for i, resource_key in enumerate(resource_keys):
                chk_string('resource_key[#{:d}]'.format(i), resource_key, allow_empty=False)

                try:
                    _results = list()

                    if resource_key == RESOURCE_SERVICES:
                    get_osu_tunnels(self._handler_osu_tunnel, results)
                    get_etht_services(self._handler_etht_service, results)
                        get_osu_tunnels(self._handler_osu_tunnel, _results)
                        get_etht_services(self._handler_etht_service, _results)
                    else:
                        # check if resource key is for a specific OSU tunnel or ETHT service, and get them accordingly
                        osu_tunnel_name, etht_service_name = parse_resource_key(resource_key)
                        if osu_tunnel_name is not None:
                        get_osu_tunnels(self._handler_osu_tunnel, results, osu_tunnel_name=osu_tunnel_name)
                            get_osu_tunnels(self._handler_osu_tunnel, _results, osu_tunnel_name=osu_tunnel_name)
                        if etht_service_name is not None:
                        get_etht_services(self._handler_etht_service, results, etht_service_name=etht_service_name)
                            get_etht_services(self._handler_etht_service, _results, etht_service_name=etht_service_name)

                    results.extend(_results)
                except Exception as e:
                    results.append((resource_key, e))

        return results

@@ -95,16 +102,23 @@ class IetfActnDriver(_Driver):
        with self.__lock:
            for resource_key, resource_value in resources:
                LOGGER.info('resource: key({:s}) => value({:s})'.format(str(resource_key), str(resource_value)))
                try:
                    _results = list()

                    if isinstance(resource_value, str): resource_value = json.loads(resource_value)
                    osu_tunnel_name, etht_service_name = parse_resource_key(resource_key)

                    if osu_tunnel_name is not None:
                        succeeded = self._handler_osu_tunnel.update(resource_value)
                    results.extend(succeeded)
                        _results.append(succeeded)

                    if etht_service_name is not None:
                        succeeded = self._handler_etht_service.update(resource_value)
                    results.extend(succeeded)
                        _results.append(succeeded)

                    results.extend(_results)
                except Exception as e:
                    results.append(e)

        return results

@@ -115,16 +129,23 @@ class IetfActnDriver(_Driver):
        with self.__lock:
            for resource_key, resource_value in resources:
                LOGGER.info('resource: key({:s}) => value({:s})'.format(str(resource_key), str(resource_value)))
                try:
                    _results = list()

                    if isinstance(resource_value, str): resource_value = json.loads(resource_value)
                    osu_tunnel_name, etht_service_name = parse_resource_key(resource_key)

                    if osu_tunnel_name is not None:
                        succeeded = self._handler_osu_tunnel.delete(osu_tunnel_name)
                    results.extend(succeeded)
                        _results.append(succeeded)

                    if etht_service_name is not None:
                        succeeded = self._handler_etht_service.delete(etht_service_name)
                    results.extend(succeeded)
                        _results.append(succeeded)

                    results.extend(_results)
                except Exception as e:
                    results.append(e)

        return results

+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ def get_osu_tunnels(
    for osu_tunnel in osu_tunnels:
        osu_tunnel_name = osu_tunnel['name']
        resource_key = '/osu_tunnels/osu_tunnel[{:s}]'.format(osu_tunnel_name)
        results.extend((resource_key, osu_tunnel))
        results.append((resource_key, osu_tunnel))

def get_etht_services(
    handler_etht_service : EthtServiceHandler, results : List[Tuple[str, Union[Any, None, Exception]]],
@@ -49,4 +49,4 @@ def get_etht_services(
    for etht_service in etht_services:
        etht_service_name = etht_service['name']
        resource_key = '/etht_services/etht_service[{:s}]'.format(etht_service_name)
        results.extend((resource_key, etht_service))
        results.append((resource_key, etht_service))
+0 −91
Original line number Diff line number Diff line
{
    "ietf-eth-tran-service:etht-svc": {
        "etht-svc-instances": [
            {
                "etht-svc-name": "etht_service_2",
                "etht-svc-title": "ETHT_SVC_2",
                "etht-svc-type": "op-p2mp-svc?",
                "source-endpoints": {
                    "source-endpoint": [
                        {
                            "node-id": "10.0.10.1",
                            "tp-id": "200",
                            "protection-role": "work?",
                            "layer-specific": {
                                "access-type": "port"
                            },
                            "is-extendable": false,
                            "is-terminal": true,
                            "static-route-list": [
                                {
                                    "destination": "128.32.10.5",
                                    "destination-mask": 24,
                                    "next-hop": "128.32.33.5"
                                },
                                {
                                    "destination": "128.32.20.5",
                                    "destination-mask": 24,
                                    "next-hop": "128.32.33.5"
                                }
                            ],
                            "outer-tag": {
                                "tag-type": "ietf-eth-tran-types:classify-c-vlan",
                                "vlan-value": 31
                            },
                            "service-classification-type": "ietf-eth-tran-type:vlan-classification",
                            "ingress-egress-bandwidth-profile" : {
                                "bandwidth-profile-type": "ietf-eth-tran-types:mef-10-bwp",
                                "CIR": 10000000,
                                "EIR": 10000000
                            }
                        }
                    ]
                },
                "destination-endpoints": {
                    "destination-endpoint": [
                        {
                            "node-id": "10.0.30.1",
                            "tp-id": "200",
                            "protection-role": "work?",
                            "layer-specific": {
                                "access-type": "port"
                            },
                            "is-extendable": false,
                            "is-terminal": true,
                            "static-route-list": [
                                {
                                    "destination": "172.1.101.22",
                                    "destination-mask": 24,
                                    "next-hop": "172.10.33.5"
                                }
                            ],
                            "outer-tag": {
                                "tag-type": "ietf-eth-tran-types:classify-c-vlan",
                                "vlan-value": 201
                            },
                            "service-classification-type": "ietf-eth-tran-type:vlan-classification",
                            "ingress-egress-bandwidth-profile" : {
                                "bandwidth-profile-type": "ietf-eth-tran-types:mef-10-bwp",
                                "CIR": 10000000,
                                "EIR": 10000000
                            }
                        }
                    ]
                },
                "svc-tunnel": [
                    {
                        "tunnel-name": "osu_tunnel_2"
                    }
                ],
                "optimizations": {
                    "optimization-metric": [
                        {
                            "metric-role": "work?",
                            "metric-type": "ietf-te-types:path-metric-te"
                        }
                    ]
                }
            }
        ]
    }
}
 No newline at end of file
Loading