Commit 6324ced5 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Multiple minor fixes:

- Added lost enum entries in context.proto and Context component's ServiceTypes.
- Corrected NBI composition of service and added static routes
- Corrected NBI test files
- Corrected import in Service component
- Corrected Dockerfile of Service component
parent 8d72cd43
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ enum DeviceDriverEnum {
  DEVICEDRIVER_XR = 6;
  DEVICEDRIVER_IETF_L2VPN = 7;
  DEVICEDRIVER_GNMI_OPENCONFIG = 8;
  DEVICEDRIVER_FLEXSCALE = 9;
}

enum DeviceOperationalStatusEnum {
@@ -285,6 +286,7 @@ enum ServiceTypeEnum {
  SERVICETYPE_L2NM = 2;
  SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3;
  SERVICETYPE_TE = 4;
  SERVICETYPE_E2E = 5;
}

enum ServiceStatusEnum {
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ class ORM_ServiceTypeEnum(enum.Enum):
    L2NM                      = ServiceTypeEnum.SERVICETYPE_L2NM
    TAPI_CONNECTIVITY_SERVICE = ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE
    TE                        = ServiceTypeEnum.SERVICETYPE_TE
    E2E                       = ServiceTypeEnum.SERVICETYPE_E2E

grpc_to_enum__service_type = functools.partial(
    grpc_to_enum, ServiceTypeEnum, ORM_ServiceTypeEnum)
+14 −2
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
import logging, netaddr
from typing import Dict, List, Optional, Tuple
from common.Constants import DEFAULT_CONTEXT_NAME
from common.proto.context_pb2 import Service, ServiceStatusEnum
from common.proto.context_pb2 import Service, ServiceStatusEnum, ServiceTypeEnum
from common.tools.context_queries.Service import get_service_by_uuid
from common.tools.grpc.ConfigRules import update_config_rule_custom
from common.tools.grpc.Constraints import (
@@ -35,6 +35,7 @@ def create_service(
    service_request = Service()
    service_request.service_id.context_id.context_uuid.uuid = context_uuid
    service_request.service_id.service_uuid.uuid = service_uuid
    service_request.service_type = ServiceTypeEnum.SERVICETYPE_L3NM
    service_request.service_status.service_status = ServiceStatusEnum.SERVICESTATUS_PLANNED

    try:
@@ -57,6 +58,7 @@ def update_service_endpoint(
    vlan_tag : int, ipv4_address : str, ipv4_prefix_length : int,
    capacity_gbps : Optional[float] = None, e2e_latency_ms : Optional[float] = None,
    availability : Optional[float] = None, mtu : Optional[int] = None,
    static_routing : Optional[Dict[Tuple[str, str], str]] = None,
    context_uuid : Optional[str] = DEFAULT_CONTEXT_NAME, 
) -> Optional[Exception]:
    context_client = ContextClient()
@@ -79,6 +81,16 @@ def update_service_endpoint(
    if mtu is not None: service_settings['mtu'] = (mtu, True)
    update_config_rule_custom(config_rules, service_settings_key, service_settings)

    if static_routing is not None:
        service_static_routing_key = '/static_routing'
        update_config_rule_custom(config_rules, service_static_routing_key, {
            '{:d}-{:s}/{:d}'.format(lan_tag, ip_range, ip_prefix_len): (
                {'vlan-id': lan_tag, 'ip-network': '{:s}/{:d}'.format(ip_range, ip_prefix_len), 'next-hop': next_hop},
                True
            )
            for (ip_range, ip_prefix_len, lan_tag), next_hop in static_routing.items()
        })

    ENDPOINT_SETTINGS_KEY = '/device[{:s}]/endpoint[{:s}]/vlan[{:d}]/settings'
    endpoint_settings_key = ENDPOINT_SETTINGS_KEY.format(device_uuid, endpoint_uuid, vlan_tag)
    field_updates = {}
@@ -166,7 +178,7 @@ def process_site_network_access(
    exc = update_service_endpoint(
        service_uuid, site_id, device_uuid, endpoint_uuid, vlan_tag, ipv4_provider_address, ipv4_prefix_length,
        capacity_gbps=service_bandwidth_gbps, e2e_latency_ms=max_e2e_latency_ms, availability=availability,
        mtu=service_mtu
        mtu=service_mtu, static_routing=site_static_routing
    )
    if exc is not None: errors.append({'error': str(exc)})

+2 −2
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@
          "site-network-accesses": {
            "site-network-access": [
              {
                "site-network-access-id": "service access 3",
                "site-network-access-id": "500",
                "site-network-access-type": "ietf-l3vpn-svc:multipoint",
                "device-reference": "128.32.33.5",
                "vpn-attachment": {
@@ -158,7 +158,7 @@
          "site-network-accesses": {
            "site-network-access": [
              {
                "site-network-access-id": "service access 4",
                "site-network-access-id": "500",
                "site-network-access-type": "ietf-l3vpn-svc:multipoint",
                "device-reference": "172.10.33.5",
                "vpn-attachment": {
+294 −0
Original line number Diff line number Diff line
@@ -366,6 +366,177 @@
            "device_type": "emu-packet-router",
            "name": "128.32.10.1"
        },
        {
            "components": [],
            "controller_id": {},
            "device_config": {
                "config_rules": [
                    {
                        "action": 1,
                        "custom": {
                            "resource_key": "_connect/address",
                            "resource_value": "127.0.0.1"
                        }
                    },
                    {
                        "action": 1,
                        "custom": {
                            "resource_key": "_connect/port",
                            "resource_value": 0
                        }
                    },
                    {
                        "action": 1,
                        "custom": {
                            "resource_key": "_connect/settings",
                            "resource_value": {
                                "endpoints": [
                                    {
                                        "name": "200",
                                        "type": "copper",
                                        "uuid": "200"
                                    },
                                    {
                                        "name": "201",
                                        "type": "copper",
                                        "uuid": "201"
                                    },
                                    {
                                        "name": "500",
                                        "type": "copper",
                                        "uuid": "500"
                                    }
                                ]
                            }
                        }
                    },
                    {
                        "action": 1,
                        "custom": {
                            "resource_key": "/endpoints/endpoint[200]",
                            "resource_value": {
                                "name": "200",
                                "type": "copper",
                                "uuid": "200"
                            }
                        }
                    },
                    {
                        "action": 1,
                        "custom": {
                            "resource_key": "/endpoints/endpoint[201]",
                            "resource_value": {
                                "name": "201",
                                "type": "copper",
                                "uuid": "201"
                            }
                        }
                    },
                    {
                        "action": 1,
                        "custom": {
                            "resource_key": "/endpoints/endpoint[500]",
                            "resource_value": {
                                "name": "500",
                                "type": "copper",
                                "uuid": "500"
                            }
                        }
                    }
                ]
            },
            "device_drivers": [
                0
            ],
            "device_endpoints": [
                {
                    "endpoint_id": {
                        "device_id": {
                            "device_uuid": {
                                "uuid": "4c367472-545c-544d-935d-829f0a0e1c72"
                            }
                        },
                        "endpoint_uuid": {
                            "uuid": "227b6bb2-dacf-5b3d-84e9-c1d0c107bcd8"
                        },
                        "topology_id": {
                            "context_id": {
                                "context_uuid": {
                                    "uuid": "admin"
                                }
                            },
                            "topology_uuid": {
                                "uuid": "admin"
                            }
                        }
                    },
                    "endpoint_location": {},
                    "endpoint_type": "copper",
                    "kpi_sample_types": [],
                    "name": "201"
                },
                {
                    "endpoint_id": {
                        "device_id": {
                            "device_uuid": {
                                "uuid": "4c367472-545c-544d-935d-829f0a0e1c72"
                            }
                        },
                        "endpoint_uuid": {
                            "uuid": "3d0c36bb-80dc-5bab-8a7d-c47cce8d474f"
                        },
                        "topology_id": {
                            "context_id": {
                                "context_uuid": {
                                    "uuid": "admin"
                                }
                            },
                            "topology_uuid": {
                                "uuid": "admin"
                            }
                        }
                    },
                    "endpoint_location": {},
                    "endpoint_type": "copper",
                    "kpi_sample_types": [],
                    "name": "500"
                },
                {
                    "endpoint_id": {
                        "device_id": {
                            "device_uuid": {
                                "uuid": "4c367472-545c-544d-935d-829f0a0e1c72"
                            }
                        },
                        "endpoint_uuid": {
                            "uuid": "d8528b70-9215-59ed-851d-b9590ab0c94b"
                        },
                        "topology_id": {
                            "context_id": {
                                "context_uuid": {
                                    "uuid": "admin"
                                }
                            },
                            "topology_uuid": {
                                "uuid": "admin"
                            }
                        }
                    },
                    "endpoint_location": {},
                    "endpoint_type": "copper",
                    "kpi_sample_types": [],
                    "name": "200"
                }
            ],
            "device_id": {
                "device_uuid": {
                    "uuid": "4c367472-545c-544d-935d-829f0a0e1c72"
                }
            },
            "device_operational_status": 2,
            "device_type": "emu-datacenter",
            "name": "172.10.33.5"
        },
        {
            "components": [],
            "controller_id": {},
@@ -1917,6 +2088,60 @@
            },
            "name": "10.0.30.1-500"
        },
        {
            "attributes": {
                "total_capacity_gbps": 10.0,
                "used_capacity_gbps": 0.0
            },
            "link_endpoint_ids": [
                {
                    "device_id": {
                        "device_uuid": {
                            "uuid": "4c367472-545c-544d-935d-829f0a0e1c72"
                        }
                    },
                    "endpoint_uuid": {
                        "uuid": "3d0c36bb-80dc-5bab-8a7d-c47cce8d474f"
                    },
                    "topology_id": {
                        "context_id": {
                            "context_uuid": {
                                "uuid": "admin"
                            }
                        },
                        "topology_uuid": {
                            "uuid": "admin"
                        }
                    }
                },
                {
                    "device_id": {
                        "device_uuid": {
                            "uuid": "0392c251-b5d3-526b-8f3b-a3d4137829fa"
                        }
                    },
                    "endpoint_uuid": {
                        "uuid": "1e35cf03-d55d-5648-9cb6-fca37bfbf23a"
                    },
                    "topology_id": {
                        "context_id": {
                            "context_uuid": {
                                "uuid": "admin"
                            }
                        },
                        "topology_uuid": {
                            "uuid": "admin"
                        }
                    }
                }
            ],
            "link_id": {
                "link_uuid": {
                    "uuid": "36643dba-e8fa-5fb7-952d-dff313db957b"
                }
            },
            "name": "172.10.33.5-500"
        },
        {
            "link_endpoint_ids": [
                {
@@ -2337,6 +2562,60 @@
            },
            "name": "128.32.20.1-200"
        },
        {
            "attributes": {
                "total_capacity_gbps": 10.0,
                "used_capacity_gbps": 0.0
            },
            "link_endpoint_ids": [
                {
                    "device_id": {
                        "device_uuid": {
                            "uuid": "0392c251-b5d3-526b-8f3b-a3d4137829fa"
                        }
                    },
                    "endpoint_uuid": {
                        "uuid": "1e35cf03-d55d-5648-9cb6-fca37bfbf23a"
                    },
                    "topology_id": {
                        "context_id": {
                            "context_uuid": {
                                "uuid": "admin"
                            }
                        },
                        "topology_uuid": {
                            "uuid": "admin"
                        }
                    }
                },
                {
                    "device_id": {
                        "device_uuid": {
                            "uuid": "4c367472-545c-544d-935d-829f0a0e1c72"
                        }
                    },
                    "endpoint_uuid": {
                        "uuid": "3d0c36bb-80dc-5bab-8a7d-c47cce8d474f"
                    },
                    "topology_id": {
                        "context_id": {
                            "context_uuid": {
                                "uuid": "admin"
                            }
                        },
                        "topology_uuid": {
                            "uuid": "admin"
                        }
                    }
                }
            ],
            "link_id": {
                "link_uuid": {
                    "uuid": "808b54e8-3d5a-5e03-a42e-d6c2a57cf6f3"
                }
            },
            "name": "10.0.30.1-200"
        },
        {
            "link_endpoint_ids": [
                {
@@ -2671,6 +2950,11 @@
                        "uuid": "118295c8-318a-52ec-a394-529fc4b70f2f"
                    }
                },
                {
                    "device_uuid": {
                        "uuid": "4c367472-545c-544d-935d-829f0a0e1c72"
                    }
                },
                {
                    "device_uuid": {
                        "uuid": "4f2234d0-a9b8-5a86-b1dd-9139d86e3925"
@@ -2753,6 +3037,11 @@
                        "uuid": "35801e61-45f3-564e-ad5c-09baf4aae906"
                    }
                },
                {
                    "link_uuid": {
                        "uuid": "36643dba-e8fa-5fb7-952d-dff313db957b"
                    }
                },
                {
                    "link_uuid": {
                        "uuid": "36856920-3387-5384-b1b1-dbc9e54da226"
@@ -2793,6 +3082,11 @@
                        "uuid": "6fa77ad9-e4d7-5830-bf84-ab206eff613a"
                    }
                },
                {
                    "link_uuid": {
                        "uuid": "808b54e8-3d5a-5e03-a42e-d6c2a57cf6f3"
                    }
                },
                {
                    "link_uuid": {
                        "uuid": "85a18715-3ce0-57f9-8025-5634fe622a06"
Loading