diff --git a/my_deploy.sh b/my_deploy.sh index f1f2d580f2f77b90250715b8dd36e685a2ddef12..0fcb51f90509732452620126c9062597a17735ed 100755 --- a/my_deploy.sh +++ b/my_deploy.sh @@ -44,7 +44,7 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_gene #export TFS_COMPONENTS="${TFS_COMPONENTS} forecaster" # Uncomment to activate E2E Orchestrator -#export TFS_COMPONENTS="${TFS_COMPONENTS} e2eorchestrator" +#export TFS_COMPONENTS="${TFS_COMPONENTS} e2e_orchestrator" # Set the tag you want to use for your images. export TFS_IMAGE_TAG="dev" diff --git a/proto/context.proto b/proto/context.proto new file mode 100644 index 0000000000000000000000000000000000000000..3ccc13ab199ae7587b0c99340c85524f16e86431 --- /dev/null +++ b/proto/context.proto @@ -0,0 +1,611 @@ +// 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. + +syntax = "proto3"; +package context; + +import "acl.proto"; +import "kpi_sample_types.proto"; + +service ContextService { + rpc ListContextIds (Empty ) returns ( ContextIdList ) {} + rpc ListContexts (Empty ) returns ( ContextList ) {} + rpc GetContext (ContextId ) returns ( Context ) {} + rpc SetContext (Context ) returns ( ContextId ) {} + rpc RemoveContext (ContextId ) returns ( Empty ) {} + rpc GetContextEvents (Empty ) returns (stream ContextEvent ) {} + + rpc ListTopologyIds (ContextId ) returns ( TopologyIdList ) {} + rpc ListTopologies (ContextId ) returns ( TopologyList ) {} + rpc GetTopology (TopologyId ) returns ( Topology ) {} + rpc GetTopologyDetails (TopologyId ) returns ( TopologyDetails ) {} + rpc SetTopology (Topology ) returns ( TopologyId ) {} + rpc RemoveTopology (TopologyId ) returns ( Empty ) {} + rpc GetTopologyEvents (Empty ) returns (stream TopologyEvent ) {} + + rpc ListDeviceIds (Empty ) returns ( DeviceIdList ) {} + rpc ListDevices (Empty ) returns ( DeviceList ) {} + rpc GetDevice (DeviceId ) returns ( Device ) {} + rpc SetDevice (Device ) returns ( DeviceId ) {} + rpc RemoveDevice (DeviceId ) returns ( Empty ) {} + rpc GetDeviceEvents (Empty ) returns (stream DeviceEvent ) {} + rpc SelectDevice (DeviceFilter ) returns ( DeviceList ) {} + rpc ListEndPointNames (EndPointIdList) returns ( EndPointNameList) {} + + rpc ListLinkIds (Empty ) returns ( LinkIdList ) {} + rpc ListLinks (Empty ) returns ( LinkList ) {} + rpc GetLink (LinkId ) returns ( Link ) {} + rpc SetLink (Link ) returns ( LinkId ) {} + rpc RemoveLink (LinkId ) returns ( Empty ) {} + rpc GetLinkEvents (Empty ) returns (stream LinkEvent ) {} + + rpc ListServiceIds (ContextId ) returns ( ServiceIdList ) {} + rpc ListServices (ContextId ) returns ( ServiceList ) {} + rpc GetService (ServiceId ) returns ( Service ) {} + rpc SetService (Service ) returns ( ServiceId ) {} + rpc UnsetService (Service ) returns ( ServiceId ) {} + rpc RemoveService (ServiceId ) returns ( Empty ) {} + rpc GetServiceEvents (Empty ) returns (stream ServiceEvent ) {} + rpc SelectService (ServiceFilter ) returns ( ServiceList ) {} + + rpc ListSliceIds (ContextId ) returns ( SliceIdList ) {} + rpc ListSlices (ContextId ) returns ( SliceList ) {} + rpc GetSlice (SliceId ) returns ( Slice ) {} + rpc SetSlice (Slice ) returns ( SliceId ) {} + rpc UnsetSlice (Slice ) returns ( SliceId ) {} + rpc RemoveSlice (SliceId ) returns ( Empty ) {} + rpc GetSliceEvents (Empty ) returns (stream SliceEvent ) {} + rpc SelectSlice (SliceFilter ) returns ( SliceList ) {} + + rpc ListConnectionIds (ServiceId ) returns ( ConnectionIdList) {} + rpc ListConnections (ServiceId ) returns ( ConnectionList ) {} + rpc GetConnection (ConnectionId ) returns ( Connection ) {} + rpc SetConnection (Connection ) returns ( ConnectionId ) {} + rpc RemoveConnection (ConnectionId ) returns ( Empty ) {} + rpc GetConnectionEvents(Empty ) returns (stream ConnectionEvent ) {} +} + +// ----- Generic ------------------------------------------------------------------------------------------------------- +message Empty {} + +message Uuid { + string uuid = 1; +} + +enum EventTypeEnum { + EVENTTYPE_UNDEFINED = 0; + EVENTTYPE_CREATE = 1; + EVENTTYPE_UPDATE = 2; + EVENTTYPE_REMOVE = 3; +} + +message Timestamp { + double timestamp = 1; +} + +message Event { + Timestamp timestamp = 1; + EventTypeEnum event_type = 2; +} + +// ----- Context ------------------------------------------------------------------------------------------------------- +message ContextId { + Uuid context_uuid = 1; +} + +message Context { + ContextId context_id = 1; + string name = 2; + repeated TopologyId topology_ids = 3; + repeated ServiceId service_ids = 4; + repeated SliceId slice_ids = 5; + TeraFlowController controller = 6; +} + +message ContextIdList { + repeated ContextId context_ids = 1; +} + +message ContextList { + repeated Context contexts = 1; +} + +message ContextEvent { + Event event = 1; + ContextId context_id = 2; +} + + +// ----- Topology ------------------------------------------------------------------------------------------------------ +message TopologyId { + ContextId context_id = 1; + Uuid topology_uuid = 2; +} + +message Topology { + TopologyId topology_id = 1; + string name = 2; + repeated DeviceId device_ids = 3; + repeated LinkId link_ids = 4; +} + +message TopologyDetails { + TopologyId topology_id = 1; + string name = 2; + repeated Device devices = 3; + repeated Link links = 4; +} + +message TopologyIdList { + repeated TopologyId topology_ids = 1; +} + +message TopologyList { + repeated Topology topologies = 1; +} + +message TopologyEvent { + Event event = 1; + TopologyId topology_id = 2; +} + + +// ----- Device -------------------------------------------------------------------------------------------------------- +message DeviceId { + Uuid device_uuid = 1; +} + +message Device { + DeviceId device_id = 1; + string name = 2; + string device_type = 3; + DeviceConfig device_config = 4; + DeviceOperationalStatusEnum device_operational_status = 5; + repeated DeviceDriverEnum device_drivers = 6; + repeated EndPoint device_endpoints = 7; + repeated Component components = 8; // Used for inventory + DeviceId controller_id = 9; // Identifier of node controlling the actual device +} + +message Component { //Defined previously to this section - Tested OK + Uuid component_uuid = 1; + string name = 2; + string type = 3; + + map<string, string> attributes = 4; // dict[attr.name => json.dumps(attr.value)] + string parent = 5; +} + +message DeviceConfig { + repeated ConfigRule config_rules = 1; +} + +enum DeviceDriverEnum { + DEVICEDRIVER_UNDEFINED = 0; // also used for emulated + DEVICEDRIVER_OPENCONFIG = 1; + DEVICEDRIVER_TRANSPORT_API = 2; + DEVICEDRIVER_P4 = 3; + DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4; + DEVICEDRIVER_ONF_TR_532 = 5; + DEVICEDRIVER_XR = 6; + DEVICEDRIVER_IETF_L2VPN = 7; + DEVICEDRIVER_GNMI_OPENCONFIG = 8; +} + +enum DeviceOperationalStatusEnum { + DEVICEOPERATIONALSTATUS_UNDEFINED = 0; + DEVICEOPERATIONALSTATUS_DISABLED = 1; + DEVICEOPERATIONALSTATUS_ENABLED = 2; +} + +message DeviceIdList { + repeated DeviceId device_ids = 1; +} + +message DeviceList { + repeated Device devices = 1; +} + +message DeviceFilter { + DeviceIdList device_ids = 1; + bool include_endpoints = 2; + bool include_config_rules = 3; + bool include_components = 4; +} + +message DeviceEvent { + Event event = 1; + DeviceId device_id = 2; + DeviceConfig device_config = 3; +} + + +// ----- Link ---------------------------------------------------------------------------------------------------------- +message LinkId { + Uuid link_uuid = 1; +} + +message LinkAttributes { + float total_capacity_gbps = 1; + float used_capacity_gbps = 2; +} + +message Link { + LinkId link_id = 1; + string name = 2; + repeated EndPointId link_endpoint_ids = 3; + LinkAttributes attributes = 4; +} + +message LinkIdList { + repeated LinkId link_ids = 1; +} + +message LinkList { + repeated Link links = 1; +} + +message LinkEvent { + Event event = 1; + LinkId link_id = 2; +} + + +// ----- Service ------------------------------------------------------------------------------------------------------- +message ServiceId { + ContextId context_id = 1; + Uuid service_uuid = 2; +} + +message Service { + ServiceId service_id = 1; + string name = 2; + ServiceTypeEnum service_type = 3; + repeated EndPointId service_endpoint_ids = 4; + repeated Constraint service_constraints = 5; + ServiceStatus service_status = 6; + ServiceConfig service_config = 7; + Timestamp timestamp = 8; +} + +enum ServiceTypeEnum { + SERVICETYPE_UNKNOWN = 0; + SERVICETYPE_L3NM = 1; + SERVICETYPE_L2NM = 2; + SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3; + SERVICETYPE_TE = 4; +} + +enum ServiceStatusEnum { + SERVICESTATUS_UNDEFINED = 0; + SERVICESTATUS_PLANNED = 1; + SERVICESTATUS_ACTIVE = 2; + SERVICESTATUS_UPDATING = 3; + SERVICESTATUS_PENDING_REMOVAL = 4; + SERVICESTATUS_SLA_VIOLATED = 5; +} + +message ServiceStatus { + ServiceStatusEnum service_status = 1; +} + +message ServiceConfig { + repeated ConfigRule config_rules = 1; +} + +message ServiceIdList { + repeated ServiceId service_ids = 1; +} + +message ServiceList { + repeated Service services = 1; +} + +message ServiceFilter { + ServiceIdList service_ids = 1; + bool include_endpoint_ids = 2; + bool include_constraints = 3; + bool include_config_rules = 4; +} + +message ServiceEvent { + Event event = 1; + ServiceId service_id = 2; +} + +// ----- Slice --------------------------------------------------------------------------------------------------------- +message SliceId { + ContextId context_id = 1; + Uuid slice_uuid = 2; +} + +message Slice { + SliceId slice_id = 1; + string name = 2; + repeated EndPointId slice_endpoint_ids = 3; + repeated Constraint slice_constraints = 4; + repeated ServiceId slice_service_ids = 5; + repeated SliceId slice_subslice_ids = 6; + SliceStatus slice_status = 7; + SliceConfig slice_config = 8; + SliceOwner slice_owner = 9; + Timestamp timestamp = 10; +} + +message SliceOwner { + Uuid owner_uuid = 1; + string owner_string = 2; +} + +enum SliceStatusEnum { + SLICESTATUS_UNDEFINED = 0; + SLICESTATUS_PLANNED = 1; + SLICESTATUS_INIT = 2; + SLICESTATUS_ACTIVE = 3; + SLICESTATUS_DEINIT = 4; + SLICESTATUS_SLA_VIOLATED = 5; +} + +message SliceStatus { + SliceStatusEnum slice_status = 1; +} + +message SliceConfig { + repeated ConfigRule config_rules = 1; +} + +message SliceIdList { + repeated SliceId slice_ids = 1; +} + +message SliceList { + repeated Slice slices = 1; +} + +message SliceFilter { + SliceIdList slice_ids = 1; + bool include_endpoint_ids = 2; + bool include_constraints = 3; + bool include_service_ids = 4; + bool include_subslice_ids = 5; + bool include_config_rules = 6; +} + +message SliceEvent { + Event event = 1; + SliceId slice_id = 2; +} + +// ----- Connection ---------------------------------------------------------------------------------------------------- +message ConnectionId { + Uuid connection_uuid = 1; +} + +message ConnectionSettings_L0 { + string lsp_symbolic_name = 1; +} + +message ConnectionSettings_L2 { + string src_mac_address = 1; + string dst_mac_address = 2; + uint32 ether_type = 3; + uint32 vlan_id = 4; + uint32 mpls_label = 5; + uint32 mpls_traffic_class = 6; +} + +message ConnectionSettings_L3 { + string src_ip_address = 1; + string dst_ip_address = 2; + uint32 dscp = 3; + uint32 protocol = 4; + uint32 ttl = 5; +} + +message ConnectionSettings_L4 { + uint32 src_port = 1; + uint32 dst_port = 2; + uint32 tcp_flags = 3; + uint32 ttl = 4; +} + +message ConnectionSettings { + ConnectionSettings_L0 l0 = 1; + ConnectionSettings_L2 l2 = 2; + ConnectionSettings_L3 l3 = 3; + ConnectionSettings_L4 l4 = 4; +} + +message Connection { + ConnectionId connection_id = 1; + ServiceId service_id = 2; + repeated EndPointId path_hops_endpoint_ids = 3; + repeated ServiceId sub_service_ids = 4; + ConnectionSettings settings = 5; +} + +message ConnectionIdList { + repeated ConnectionId connection_ids = 1; +} + +message ConnectionList { + repeated Connection connections = 1; +} + +message ConnectionEvent { + Event event = 1; + ConnectionId connection_id = 2; +} + + +// ----- Endpoint ------------------------------------------------------------------------------------------------------ +message EndPointId { + TopologyId topology_id = 1; + DeviceId device_id = 2; + Uuid endpoint_uuid = 3; +} + +message EndPoint { + EndPointId endpoint_id = 1; + string name = 2; + string endpoint_type = 3; + repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; + Location endpoint_location = 5; +} + +message EndPointName { + EndPointId endpoint_id = 1; + string device_name = 2; + string endpoint_name = 3; + string endpoint_type = 4; +} + +message EndPointIdList { + repeated EndPointId endpoint_ids = 1; +} + +message EndPointNameList { + repeated EndPointName endpoint_names = 1; +} + + +// ----- Configuration ------------------------------------------------------------------------------------------------- +enum ConfigActionEnum { + CONFIGACTION_UNDEFINED = 0; + CONFIGACTION_SET = 1; + CONFIGACTION_DELETE = 2; +} + +message ConfigRule_Custom { + string resource_key = 1; + string resource_value = 2; +} + +message ConfigRule_ACL { + EndPointId endpoint_id = 1; + acl.AclRuleSet rule_set = 2; +} + +message ConfigRule { + ConfigActionEnum action = 1; + oneof config_rule { + ConfigRule_Custom custom = 2; + ConfigRule_ACL acl = 3; + } +} + + +// ----- Constraint ---------------------------------------------------------------------------------------------------- +enum ConstraintActionEnum { + CONSTRAINTACTION_UNDEFINED = 0; + CONSTRAINTACTION_SET = 1; + CONSTRAINTACTION_DELETE = 2; +} + +message Constraint_Custom { + string constraint_type = 1; + string constraint_value = 2; +} + +message Constraint_Schedule { + float start_timestamp = 1; + float duration_days = 2; +} + +message GPS_Position { + float latitude = 1; + float longitude = 2; +} + +message Location { + oneof location { + string region = 1; + GPS_Position gps_position = 2; + } +} + +message Constraint_EndPointLocation { + EndPointId endpoint_id = 1; + Location location = 2; +} + +message Constraint_EndPointPriority { + EndPointId endpoint_id = 1; + uint32 priority = 2; +} + +message Constraint_SLA_Latency { + float e2e_latency_ms = 1; +} + +message Constraint_SLA_Capacity { + float capacity_gbps = 1; +} + +message Constraint_SLA_Availability { + uint32 num_disjoint_paths = 1; + bool all_active = 2; + float availability = 3; // 0.0 .. 100.0 percentage of availability +} + +enum IsolationLevelEnum { + NO_ISOLATION = 0; + PHYSICAL_ISOLATION = 1; + LOGICAL_ISOLATION = 2; + PROCESS_ISOLATION = 3; + PHYSICAL_MEMORY_ISOLATION = 4; + PHYSICAL_NETWORK_ISOLATION = 5; + VIRTUAL_RESOURCE_ISOLATION = 6; + NETWORK_FUNCTIONS_ISOLATION = 7; + SERVICE_ISOLATION = 8; +} + +message Constraint_SLA_Isolation_level { + repeated IsolationLevelEnum isolation_level = 1; +} + +message Constraint_Exclusions { + bool is_permanent = 1; + repeated DeviceId device_ids = 2; + repeated EndPointId endpoint_ids = 3; + repeated LinkId link_ids = 4; +} + +message Constraint { + ConstraintActionEnum action = 1; + oneof constraint { + Constraint_Custom custom = 2; + Constraint_Schedule schedule = 3; + Constraint_EndPointLocation endpoint_location = 4; + Constraint_EndPointPriority endpoint_priority = 5; + Constraint_SLA_Capacity sla_capacity = 6; + Constraint_SLA_Latency sla_latency = 7; + Constraint_SLA_Availability sla_availability = 8; + Constraint_SLA_Isolation_level sla_isolation = 9; + Constraint_Exclusions exclusions = 10; + } +} + + +// ----- Miscellaneous ------------------------------------------------------------------------------------------------- +message TeraFlowController { + ContextId context_id = 1; + string ip_address = 2; + uint32 port = 3; +} + +message AuthenticationResult { + ContextId context_id = 1; + bool authenticated = 2; +} diff --git a/src/device/service/drivers/flexscale/FlexScaleDriver.py b/src/device/service/drivers/flexscale/FlexScaleDriver.py index 23a7bc00631a5bbe1c3ce41f015d6df688c0e385..f91ee1cebbd686cceed2370df98445aa247d5990 100644 --- a/src/device/service/drivers/flexscale/FlexScaleDriver.py +++ b/src/device/service/drivers/flexscale/FlexScaleDriver.py @@ -106,9 +106,9 @@ class FlexScaleDriver(_Driver): for _, resource in resources: LOGGER.info('resource = {:s}'.format(str(resource))) - src_node = '1' # find_key(resource, 'src_node') - dst_node = '2' # find_key(resource, 'dst_node') - bitrate = '3' # find_key(resource, 'bitrate') + src_node = find_key(resource, 'src_node') + dst_node = find_key(resource, 'dst_node') + bitrate = find_key(resource, 'bitrate') response = add_lightpath(self.__flexscale_root, src_node, dst_node, bitrate, auth=self.__auth, timeout=self.__timeout) diff --git a/src/device/service/drivers/flexscale/Tools.py b/src/device/service/drivers/flexscale/Tools.py index 1fffc20947bc4b79c37a9c026a1df1d298baf75b..2f74f36571e3918fdc6a963f4ab221ddbe3216e4 100644 --- a/src/device/service/drivers/flexscale/Tools.py +++ b/src/device/service/drivers/flexscale/Tools.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json, logging, operator, requests +import json, logging, requests from requests.auth import HTTPBasicAuth from typing import Optional -from device.service.driver_api._Driver import RESOURCE_ENDPOINTS, RESOURCE_SERVICES LOGGER = logging.getLogger(__name__) @@ -52,13 +51,11 @@ def get_lightpaths(root_url : str, resource_key : str,auth : Optional[HTTPBasicA result.append((resource_key, e)) return result - # if resource_key == RESOURCE_ENDPOINTS: for flow in flows: flow_id = flow.get('flow_id') source = flow.get('src') destination = flow.get('dst') bitrate = flow.get('bitrate') - # more TODO endpoint_url = '/flows/flow[{:s}]'.format(flow_id) endpoint_data = {'flow_id': flow_id, 'src': source, 'dst': destination, 'bitrate': bitrate} @@ -69,64 +66,19 @@ def get_lightpaths(root_url : str, resource_key : str,auth : Optional[HTTPBasicA def add_lightpath(root_url, src_node, dst_node, bitrate, auth : Optional[HTTPBasicAuth] = None, timeout : Optional[int] = None): - + headers = {'accept': 'application/json'} - # url = '{:s}/OpticalTFS/AddLightpath/{:s}/{:s}/{:s}'.format(root_url, src_node, dst_node, bitrate) + url = '{:s}/OpticalTFS/AddLightpath/{:s}/{:s}/{:s}'.format( + root_url, src_node, dst_node, bitrate) results = [] try: LOGGER.info('Lightpath request: {:s} <-> {:s} with {:s} bitrate'.format( str(src_node), str(dst_node), str(bitrate))) - - device1= 'T1' - ep1= 'ep1' - device2= 'T2' - ep2= 'ep2' - context_uuid = 'admin' - service_uuid = 'T1-T2_service' - - data = { - "services": [ - { - "service_id": { - "context_id": {"context_uuid": {"uuid": context_uuid}}, "service_uuid": {"uuid": service_uuid} - }, - "service_type": 5, - } - ] - } - url = '{:s}'.format(root_url) + '/context/{:s}/service/{:s}'.format(context_uuid, service_uuid) - response = requests.post(url=url, timeout=timeout, headers=headers, verify=False, auth=auth, data=json.dumps(data)).json() - - - data = { - "services": [ - { - "service_id": { - "context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "service_uuid"} - }, - "service_type": 5, - "service_status": {"service_status": 1}, - "service_endpoint_ids": [ - {"device_id":{"device_uuid":{"uuid":device1}},"endpoint_uuid":{"uuid":ep1}}, - {"device_id":{"device_uuid":{"uuid":device2}},"endpoint_uuid":{"uuid":ep2}} - ], - "service_config": {"config_rules": [ - {"action": 1, "custom": {"resource_key": "/settings", "resource_value": { - }} - } - ] - } - } - ] - } - url = '{:s}'.format(root_url) + '/context/{:s}/service/{:s}'.format(context_uuid, service_uuid) - response = requests.put(url=url, timeout=timeout, headers=headers, verify=False, auth=auth, data=json.dumps(data)) - - - #response = requests.put(url=url, timeout=timeout, headers=headers, verify=False, auth=auth) + response = requests.put(url=url, timeout=timeout, headers=headers, verify=False, auth=auth) results.append(response.json()) LOGGER.info('Response: {:s}'.format(str(response))) + except Exception as e: # pylint: disable=broad-except LOGGER.exception('Exception requesting Lightpath: {:s} <-> {:s} with {:s} bitrate'.format( str(src_node), str(dst_node), str(bitrate))) @@ -136,20 +88,22 @@ def add_lightpath(root_url, src_node, dst_node, bitrate, msg = 'Could not create Lightpath(status_code={:s} reply={:s}' LOGGER.error(msg.format(str(response.status_code), str(response))) results.append(response.status_code in HTTP_OK_CODES) - + return results def del_lightpath(root_url, flow_id, src_node, dst_node, bitrate, auth : Optional[HTTPBasicAuth] = None, timeout : Optional[int] = None): - url = '{:s}/OpticalTFS/DelLightpath/{:s}/{:s}/{:s}/{:s}'.format(root_url, flow_id, src_node, dst_node, bitrate) + url = '{:s}/OpticalTFS/DelLightpath/{:s}/{:s}/{:s}/{:s}'.format( + root_url, flow_id, src_node, dst_node, bitrate) headers = {'accept': 'application/json'} results = [] try: - response = requests.delete(url=url, timeout=timeout, headers=headers, verify=False, auth=auth) + response = requests.delete( + url=url, timeout=timeout, headers=headers, verify=False, auth=auth) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Exception deleting Lightpath(uuid={:s})'.format(str(flow_id))) results.append(e) @@ -179,18 +133,11 @@ def get_topology(root_url : str, resource_key : str,auth : Optional[HTTPBasicAut return result try: - links = json.loads(response.content) + response = json.loads(response.content) except Exception as e: # pylint: disable=broad-except LOGGER.warning('Unable to decode reply: {:s}'.format(str(response.content))) result.append((resource_key, e)) return result - - # if resource_key == RESOURCE_ENDPOINTS: - #for link in links: - # TODO - - # endpoint_url = '/flows/flow[{:s}]'.format(flow_id) - # endpoint_data = {'flow_id': flow_id, 'src': source, 'dst': destination, 'bitrate': bitrate} - # result.append((endpoint_url, endpoint_data)) - + + result.append(response) return result diff --git a/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py b/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py index 24e91aa4c1603ea006ad7e2570ea55ff3197140d..06c55c5dc1b0feb77d817581ae5d735e1158e38d 100644 --- a/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py +++ b/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py @@ -45,7 +45,6 @@ MAPPING_DRIVER = { 'DEVICEDRIVER_IETF_L2VPN' : 7, 'DEVICEDRIVER_GNMI_OPENCONFIG' : 8, 'DEVICEDRIVER_FLEXSCALE' : 9, - 'DEVICEDRIVER_OC' : 1, } MSG_ERROR = 'Could not retrieve devices in remote TeraFlowSDN instance({:s}). status_code={:s} reply={:s}' diff --git a/src/service/service/service_handlers/__init__.py b/src/service/service/service_handlers/__init__.py index 32df661a241bd1045e92960d16ce63c4dfc1758d..48b5e694c39bfe22e678e5710bbf49f55fbb928c 100644 --- a/src/service/service/service_handlers/__init__.py +++ b/src/service/service/service_handlers/__init__.py @@ -26,7 +26,6 @@ from .tapi_tapi.TapiServiceHandler import TapiServiceHandler from .tapi_xr.TapiXrServiceHandler import TapiXrServiceHandler from .e2e_orch.E2EOrchestratorServiceHandler import E2EOrchestratorServiceHandler - SERVICE_HANDLERS = [ (L2NMEmulatedServiceHandler, [ { diff --git a/src/tests/Fixtures.py b/src/tests/Fixtures.py index 55ef90340dd3f32460ca30fd4a64801f7bf45974..842bd83f410e1c737f4948dc33fc0b8b01dbd6ac 100644 --- a/src/tests/Fixtures.py +++ b/src/tests/Fixtures.py @@ -17,7 +17,6 @@ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from monitoring.client.MonitoringClient import MonitoringClient - @pytest.fixture(scope='session') def context_client(): _client = ContextClient() diff --git a/src/tests/tools/mock_flexscale_opt_ctrl/test_mw.py b/src/tests/tools/mock_flexscale_opt_ctrl/test_mw.py deleted file mode 100644 index 0329d30ad234398200c0fe29aac46f72f5a2e924..0000000000000000000000000000000000000000 --- a/src/tests/tools/mock_flexscale_opt_ctrl/test_mw.py +++ /dev/null @@ -1,84 +0,0 @@ -import json, logging, requests -from requests.auth import HTTPBasicAuth -from typing import Optional - -LOGGER = logging.getLogger(__name__) - -HTTP_OK_CODES = { - 200, # OK - 201, # Created - 202, # Accepted - 204, # No Content -} - -def create_connectivity_service( - root_url, uuid, node_id_src, tp_id_src, node_id_dst, tp_id_dst, vlan_id, - auth : Optional[HTTPBasicAuth] = None, timeout : Optional[int] = None -): - - url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc'.format(root_url) - headers = {'content-type': 'application/json'} - data = { - 'etht-svc-instances': [ - { - 'etht-svc-name': uuid, - 'etht-svc-type': 'ietf-eth-tran-types:p2p-svc', - 'etht-svc-end-points': [ - { - 'etht-svc-access-points': [ - {'access-node-id': node_id_src, 'access-ltp-id': tp_id_src, 'access-point-id': '1'} - ], - 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, - 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_src), str(tp_id_src)), - 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' - }, - { - 'etht-svc-access-points': [ - {'access-node-id': node_id_dst, 'access-ltp-id': tp_id_dst, 'access-point-id': '2'} - ], - 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, - 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_dst), str(tp_id_dst)), - 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' - } - ] - } - ] - } - results = [] - try: - LOGGER.info('Connectivity service {:s}: {:s}'.format(str(uuid), str(data))) - response = requests.post( - url=url, data=json.dumps(data), timeout=timeout, headers=headers, verify=False, auth=auth) - LOGGER.info('Microwave Driver response: {:s}'.format(str(response))) - except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Exception creating ConnectivityService(uuid={:s}, data={:s})'.format(str(uuid), str(data))) - results.append(e) - else: - if response.status_code not in HTTP_OK_CODES: - msg = 'Could not create ConnectivityService(uuid={:s}, data={:s}). status_code={:s} reply={:s}' - LOGGER.error(msg.format(str(uuid), str(data), str(response.status_code), str(response))) - results.append(response.status_code in HTTP_OK_CODES) - return results - -def delete_connectivity_service(root_url, uuid, auth : Optional[HTTPBasicAuth] = None, timeout : Optional[int] = None): - url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc/etht-svc-instances={:s}' - url = url.format(root_url, uuid) - results = [] - try: - response = requests.delete(url=url, timeout=timeout, verify=False, auth=auth) - except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Exception deleting ConnectivityService(uuid={:s})'.format(str(uuid))) - results.append(e) - else: - if response.status_code not in HTTP_OK_CODES: - msg = 'Could not delete ConnectivityService(uuid={:s}). status_code={:s} reply={:s}' - LOGGER.error(msg.format(str(uuid), str(response.status_code), str(response))) - results.append(response.status_code in HTTP_OK_CODES) - return results - -if __name__ == '__main__': - ROOT_URL = 'https://127.0.0.1:8443' - SERVICE_UUID = 'my-service' - - create_connectivity_service(ROOT_URL, SERVICE_UUID, '172.18.0.1', '1', '172.18.0.2', '2', 300) - delete_connectivity_service(ROOT_URL, SERVICE_UUID)