Commit 9c83759f authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Device - IETF ACTN Driver:

- Intermediate backup
- Added example messages
- Implemented request message composers
- Implemented handlers (work in progress)
parent d0bbc4e7
Loading
Loading
Loading
Loading
+0 −80
Original line number Diff line number Diff line
# 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.

import enum
from typing import Dict

OSU_TUNNEL_URL = '/restconf/data/ietf-te:tunnel'

class EndpointProtectionRoleEnum(enum.Enum):
    WORK = 'work'

class LspProtectionTypeEnum(enum.Enum):
    UNPROTECTED = 'ietf-te-types:lsp-protection-unprotected'

class LspRestorationTypeEnum(enum.Enum):
    NOT_APPLICABLE = 'ietf-te-types:lsp-restoration-not-applicable'

class TunnelAdminStateEnum(enum.Enum):
    UP = 'ietf-te-types:tunnel-admin-state-up'

class OduTypeEnum(enum.Enum):
    OSUFLEX = 'osuflex'

def compose_osu_tunnel_endpoint(
    node_id : str, tp_id : str, ttp_channel_name : str,
    protection_role : EndpointProtectionRoleEnum = EndpointProtectionRoleEnum.WORK
) -> Dict:
    return {
        'node-id': node_id, 'tp-id': tp_id, 'ttp-channel-name': ttp_channel_name,
        'protection-role': protection_role.value
    }

def compose_osu_tunnel_te_bandwidth_odu(odu_type : OduTypeEnum, number : int) -> Dict:
    return {'layer': 'odu', 'odu-type': odu_type.value, 'number': number}

def compose_osu_tunnel_protection(
    type_ : LspProtectionTypeEnum = LspProtectionTypeEnum.UNPROTECTED, reversion_disable : bool = True
) -> Dict:
    return {'protection-type': type_.value, 'protection-reversion-disable': reversion_disable}

def compose_osu_tunnel_restoration(
    type_ : LspRestorationTypeEnum = LspRestorationTypeEnum.NOT_APPLICABLE, restoration_lock : bool = False
) -> Dict:
    return {'restoration-type': type_.value, 'restoration-lock': restoration_lock}

def compose_osu_tunnel(
    name : str,
    src_node_id : str, src_tp_id : str, src_ttp_channel_name : str,
    dst_node_id : str, dst_tp_id : str, dst_ttp_channel_name : str,
    odu_type : OduTypeEnum, osuflex_number : int,
    delay : int, bidirectional : bool = True,
    admin_state : TunnelAdminStateEnum = TunnelAdminStateEnum.UP
) -> Dict:
    return {'ietf-te:tunnel': [{
        'name': name.lower(),
        'title': name.upper(),
        'admin-state': admin_state.value,
        'delay': delay,
        'te-bandwidth': compose_osu_tunnel_te_bandwidth_odu(odu_type, osuflex_number),
        'bidirectional': bidirectional,
        'source-endpoints': {'source-endpoint': [
            compose_osu_tunnel_endpoint(src_node_id, src_tp_id, src_ttp_channel_name),
        ]},
        'destination-endpoints': {'destination-endpoint': [
            compose_osu_tunnel_endpoint(dst_node_id, dst_tp_id, dst_ttp_channel_name),
        ]},
        'restoration': compose_osu_tunnel_restoration(),
        'protection': compose_osu_tunnel_protection(),
    }]}
+3 −36
Original line number Diff line number Diff line
@@ -140,40 +140,7 @@ def create_resource(

    url = '{:s}/restconf/data/tapi-common:context/tapi-connectivity:connectivity-context'.format(base_url)
    headers = {'content-type': 'application/json'}
    data = {
        'tapi-connectivity:connectivity-service': [
            {
                'uuid': uuid,
                'connectivity-constraint': {
                    'requested-capacity': {
                        'total-size': {
                            'value': capacity_value,
                            'unit': capacity_unit
                        }
                    },
                    'connectivity-direction': direction
                },
                'end-point': [
                    {
                        'service-interface-point': {
                            'service-interface-point-uuid': input_sip
                        },
                        'layer-protocol-name': layer_protocol_name,
                        'layer-protocol-qualifier': layer_protocol_qualifier,
                        'local-id': input_sip
                    },
                    {
                        'service-interface-point': {
                            'service-interface-point-uuid': output_sip
                        },
                        'layer-protocol-name': layer_protocol_name,
                        'layer-protocol-qualifier': layer_protocol_qualifier,
                        'local-id': output_sip
                    }
                ]
            }
        ]
    }
    data = compose_...
    results = []
    try:
        LOGGER.info('Connectivity service {:s}: {:s}'.format(str(uuid), str(data)))
@@ -194,9 +161,9 @@ def delete_resource(
    base_url : str, resource_key : str, resource_value : Dict,
    auth : Optional[HTTPBasicAuth] = None, timeout : Optional[int] = None
):
    uuid = find_key(resource, 'uuid')
    uuid = find_key(resource_value, 'uuid')

    url = '{:s}/restconf/data/tapi-common:context/tapi-connectivity:connectivity-context/connectivity-service={:s}'
    url = '{:s}/tapi-common:context/tapi-connectivity:connectivity-context/connectivity-service={:s}'
    url = url.format(base_url, uuid)
    results = []
    try:
+91 −0
Original line number Diff line number Diff line
{
    "ietf-eth-tran-service:etht-svc": {
        "etht-svc-instances": [
            {
                "etht-svc-name": "etht_service_1",
                "etht-svc-title": "ETHT_SVC_1",
                "etht-svc-type": "op-mp2mp-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": 21
                            },
                            "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": 101
                            },
                            "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_1"
                    }
                ],
                "optimizations": {
                    "optimization-metric": [
                        {
                            "metric-role": "work?",
                            "metric-type": "ietf-te-types:path-metric-te"
                        }
                    ]
                }
            }
        ]
    }
}
 No newline at end of file
+91 −0
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
+44 −0
Original line number Diff line number Diff line
{
    "ietf-te:tunnel": [
        {
            "name": "osu_tunnel_1",
            "title": "OSU_TUNNEL_1",
            "admin-state": "ietf-te-types:tunnel-admin-state-up",
            "delay": 20,
            "te-bandwidth": {
                "layer": "odu",
                "odu-type": "osuflex",
                "number": 1
            },
            "bidirectional": true,
            "destination-endpoints": {
                "destination-endpoint": [
                    {
                        "node-id": "10.0.30.1",
                        "tp-id": "200",
                        "ttp-channel-name": "och:1-odu2:1-oduflex:3-osuflex:1?",
                        "protection-role": "work"
                    }
                ]
            },
            "source-endpoints": {
                "source-endpoint": [
                    {
                        "node-id": "10.0.10.1",
                        "tp-id": "200",
                        "ttp-channel-name": "och:1-odu2:1-oduflex:1-osuflex:2?",
                        "protection-role": "work"
                    }
                ]
            },
            "restoration": {
                "restoration-type": "ietf-te-types:lsp-restoration-not-applicable",
                "restoration-lock": false
            },
            "protection": {
                "protection-type": "ietf-te-types:lsp-protection-unprotected",
                "protection-reversion-disable": true
            }
        }
    ]
}
 No newline at end of file
Loading