Loading scripts/show_logs_monitoring.sh +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,4 +24,4 @@ export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} # Automated steps start here # Automated steps start here ######################################################################################################################## ######################################################################################################################## kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/monitoringserver kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/monitoringservice server src/common/tests/LoadScenario.py 0 → 100644 +50 −0 Original line number Original line Diff line number Diff line # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) # # 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 logging from common.tools.descriptor.Loader import DescriptorLoader, compose_notifications from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from slice.client.SliceClient import SliceClient LOGGER = logging.getLogger(__name__) LOGGERS = { 'success': LOGGER.info, 'danger' : LOGGER.error, 'error' : LOGGER.error, } def load_scenario_from_descriptor( descriptor_file : str, context_client : ContextClient, device_client : DeviceClient, service_client : ServiceClient, slice_client : SliceClient ) -> DescriptorLoader: with open(descriptor_file, 'r', encoding='UTF-8') as f: descriptors = f.read() descriptor_loader = DescriptorLoader( descriptors, context_client=context_client, device_client=device_client, service_client=service_client, slice_client=slice_client) results = descriptor_loader.process() num_errors = 0 for message,level in compose_notifications(results): LOGGERS.get(level)(message) if level != 'success': num_errors += 1 if num_errors > 0: MSG = 'Failed to load descriptors in file {:s}' raise Exception(MSG.format(str(descriptor_file))) return descriptor_loader No newline at end of file src/common/tools/context_queries/InterDomain.py +10 −5 Original line number Original line Diff line number Diff line Loading @@ -16,13 +16,13 @@ import logging from typing import Dict, List, Set, Tuple from typing import Dict, List, Set, Tuple from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID, INTERDOMAIN_TOPOLOGY_UUID from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID, INTERDOMAIN_TOPOLOGY_UUID from common.DeviceTypes import DeviceTypeEnum from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import ContextId, Device, Empty, EndPointId, ServiceTypeEnum, Slice, TopologyId from common.proto.context_pb2 import ContextId, Device, Empty, EndPointId, ServiceTypeEnum, Slice from common.proto.pathcomp_pb2 import PathCompRequest from common.proto.pathcomp_pb2 import PathCompRequest from common.tools.context_queries.CheckType import device_type_is_network from common.tools.context_queries.CheckType import device_type_is_network from common.tools.context_queries.Device import get_devices_in_topology, get_uuids_of_devices_in_topology from common.tools.context_queries.Device import get_devices_in_topology from common.tools.context_queries.Topology import get_topology from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Topology import json_topology_id from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient from pathcomp.frontend.client.PathCompClient import PathCompClient from pathcomp.frontend.client.PathCompClient import PathCompClient Loading Loading @@ -60,8 +60,13 @@ def get_local_device_uuids(context_client : ContextClient) -> Set[str]: return local_device_uuids return local_device_uuids def get_interdomain_device_uuids(context_client : ContextClient) -> Set[str]: def get_interdomain_device_uuids(context_client : ContextClient) -> Set[str]: interdomain_topology_id = TopologyId(**json_topology_id(INTERDOMAIN_TOPOLOGY_UUID, context_id=ADMIN_CONTEXT_ID)) context_uuid = DEFAULT_CONTEXT_UUID interdomain_topology = context_client.GetTopology(interdomain_topology_id) topology_uuid = INTERDOMAIN_TOPOLOGY_UUID interdomain_topology = get_topology(context_client, topology_uuid, context_uuid=context_uuid) if interdomain_topology is None: MSG = '[get_interdomain_device_uuids] {:s}/{:s} topology not found' LOGGER.warning(MSG.format(context_uuid, topology_uuid)) return set() # add abstracted devices in the interdomain topology # add abstracted devices in the interdomain topology interdomain_device_ids = interdomain_topology.device_ids interdomain_device_ids = interdomain_topology.device_ids Loading src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/tools/ContextMethods.py→src/common/tools/context_queries/Service.py +39 −0 Original line number Original line Diff line number Diff line # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) # # 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 grpc, logging import grpc, logging from typing import Optional from typing import Optional from common.Constants import DEFAULT_CONTEXT_UUID from common.Constants import DEFAULT_CONTEXT_UUID from common.proto.context_pb2 import Service, ServiceId, Slice, SliceId from common.proto.context_pb2 import Service, ServiceId from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__) def get_service( def get_service( context_client : ContextClient, service_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID context_client : ContextClient, service_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID, rw_copy : bool = False ) -> Optional[Service]: ) -> Optional[Service]: try: try: # pylint: disable=no-member # pylint: disable=no-member service_id = ServiceId() service_id = ServiceId() service_id.context_id.context_uuid.uuid = context_uuid service_id.context_id.context_uuid.uuid = context_uuid service_id.service_uuid.uuid = service_uuid service_id.service_uuid.uuid = service_uuid service_readonly = context_client.GetService(service_id) ro_service = context_client.GetService(service_id) service = Service() if not rw_copy: return ro_service service.CopyFrom(service_readonly) rw_service = Service() return service rw_service.CopyFrom(ro_service) return rw_service except grpc.RpcError: except grpc.RpcError: #LOGGER.exception('Unable to get service({:s} / {:s})'.format(str(context_uuid), str(service_uuid))) #LOGGER.exception('Unable to get service({:s} / {:s})'.format(str(context_uuid), str(service_uuid))) return None return None def get_slice( context_client : ContextClient, slice_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID ) -> Optional[Slice]: try: # pylint: disable=no-member slice_id = SliceId() slice_id.context_id.context_uuid.uuid = context_uuid slice_id.slice_uuid.uuid = slice_uuid slice_readonly = context_client.GetSlice(slice_id) slice_ = Slice() slice_.CopyFrom(slice_readonly) return slice_ except grpc.RpcError: #LOGGER.exception('Unable to get slice({:s} / {:s})'.format(str(context_uuid), str(slice_uuid))) return None src/common/tools/context_queries/Slice.py 0 → 100644 +39 −0 Original line number Original line Diff line number Diff line # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) # # 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 grpc, logging from typing import Optional from common.Constants import DEFAULT_CONTEXT_UUID from common.proto.context_pb2 import Slice, SliceId from context.client.ContextClient import ContextClient LOGGER = logging.getLogger(__name__) def get_slice( context_client : ContextClient, slice_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID, rw_copy : bool = False ) -> Optional[Slice]: try: # pylint: disable=no-member slice_id = SliceId() slice_id.context_id.context_uuid.uuid = context_uuid slice_id.slice_uuid.uuid = slice_uuid ro_slice = context_client.GetSlice(slice_id) if not rw_copy: return ro_slice rw_slice = Slice() rw_slice.CopyFrom(ro_slice) return rw_slice except grpc.RpcError: #LOGGER.exception('Unable to get slice({:s} / {:s})'.format(str(context_uuid), str(slice_uuid))) return None Loading
scripts/show_logs_monitoring.sh +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,4 +24,4 @@ export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} # Automated steps start here # Automated steps start here ######################################################################################################################## ######################################################################################################################## kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/monitoringserver kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/monitoringservice server
src/common/tests/LoadScenario.py 0 → 100644 +50 −0 Original line number Original line Diff line number Diff line # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) # # 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 logging from common.tools.descriptor.Loader import DescriptorLoader, compose_notifications from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from slice.client.SliceClient import SliceClient LOGGER = logging.getLogger(__name__) LOGGERS = { 'success': LOGGER.info, 'danger' : LOGGER.error, 'error' : LOGGER.error, } def load_scenario_from_descriptor( descriptor_file : str, context_client : ContextClient, device_client : DeviceClient, service_client : ServiceClient, slice_client : SliceClient ) -> DescriptorLoader: with open(descriptor_file, 'r', encoding='UTF-8') as f: descriptors = f.read() descriptor_loader = DescriptorLoader( descriptors, context_client=context_client, device_client=device_client, service_client=service_client, slice_client=slice_client) results = descriptor_loader.process() num_errors = 0 for message,level in compose_notifications(results): LOGGERS.get(level)(message) if level != 'success': num_errors += 1 if num_errors > 0: MSG = 'Failed to load descriptors in file {:s}' raise Exception(MSG.format(str(descriptor_file))) return descriptor_loader No newline at end of file
src/common/tools/context_queries/InterDomain.py +10 −5 Original line number Original line Diff line number Diff line Loading @@ -16,13 +16,13 @@ import logging from typing import Dict, List, Set, Tuple from typing import Dict, List, Set, Tuple from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID, INTERDOMAIN_TOPOLOGY_UUID from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID, INTERDOMAIN_TOPOLOGY_UUID from common.DeviceTypes import DeviceTypeEnum from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import ContextId, Device, Empty, EndPointId, ServiceTypeEnum, Slice, TopologyId from common.proto.context_pb2 import ContextId, Device, Empty, EndPointId, ServiceTypeEnum, Slice from common.proto.pathcomp_pb2 import PathCompRequest from common.proto.pathcomp_pb2 import PathCompRequest from common.tools.context_queries.CheckType import device_type_is_network from common.tools.context_queries.CheckType import device_type_is_network from common.tools.context_queries.Device import get_devices_in_topology, get_uuids_of_devices_in_topology from common.tools.context_queries.Device import get_devices_in_topology from common.tools.context_queries.Topology import get_topology from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Topology import json_topology_id from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient from pathcomp.frontend.client.PathCompClient import PathCompClient from pathcomp.frontend.client.PathCompClient import PathCompClient Loading Loading @@ -60,8 +60,13 @@ def get_local_device_uuids(context_client : ContextClient) -> Set[str]: return local_device_uuids return local_device_uuids def get_interdomain_device_uuids(context_client : ContextClient) -> Set[str]: def get_interdomain_device_uuids(context_client : ContextClient) -> Set[str]: interdomain_topology_id = TopologyId(**json_topology_id(INTERDOMAIN_TOPOLOGY_UUID, context_id=ADMIN_CONTEXT_ID)) context_uuid = DEFAULT_CONTEXT_UUID interdomain_topology = context_client.GetTopology(interdomain_topology_id) topology_uuid = INTERDOMAIN_TOPOLOGY_UUID interdomain_topology = get_topology(context_client, topology_uuid, context_uuid=context_uuid) if interdomain_topology is None: MSG = '[get_interdomain_device_uuids] {:s}/{:s} topology not found' LOGGER.warning(MSG.format(context_uuid, topology_uuid)) return set() # add abstracted devices in the interdomain topology # add abstracted devices in the interdomain topology interdomain_device_ids = interdomain_topology.device_ids interdomain_device_ids = interdomain_topology.device_ids Loading
src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/tools/ContextMethods.py→src/common/tools/context_queries/Service.py +39 −0 Original line number Original line Diff line number Diff line # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) # # 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 grpc, logging import grpc, logging from typing import Optional from typing import Optional from common.Constants import DEFAULT_CONTEXT_UUID from common.Constants import DEFAULT_CONTEXT_UUID from common.proto.context_pb2 import Service, ServiceId, Slice, SliceId from common.proto.context_pb2 import Service, ServiceId from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__) def get_service( def get_service( context_client : ContextClient, service_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID context_client : ContextClient, service_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID, rw_copy : bool = False ) -> Optional[Service]: ) -> Optional[Service]: try: try: # pylint: disable=no-member # pylint: disable=no-member service_id = ServiceId() service_id = ServiceId() service_id.context_id.context_uuid.uuid = context_uuid service_id.context_id.context_uuid.uuid = context_uuid service_id.service_uuid.uuid = service_uuid service_id.service_uuid.uuid = service_uuid service_readonly = context_client.GetService(service_id) ro_service = context_client.GetService(service_id) service = Service() if not rw_copy: return ro_service service.CopyFrom(service_readonly) rw_service = Service() return service rw_service.CopyFrom(ro_service) return rw_service except grpc.RpcError: except grpc.RpcError: #LOGGER.exception('Unable to get service({:s} / {:s})'.format(str(context_uuid), str(service_uuid))) #LOGGER.exception('Unable to get service({:s} / {:s})'.format(str(context_uuid), str(service_uuid))) return None return None def get_slice( context_client : ContextClient, slice_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID ) -> Optional[Slice]: try: # pylint: disable=no-member slice_id = SliceId() slice_id.context_id.context_uuid.uuid = context_uuid slice_id.slice_uuid.uuid = slice_uuid slice_readonly = context_client.GetSlice(slice_id) slice_ = Slice() slice_.CopyFrom(slice_readonly) return slice_ except grpc.RpcError: #LOGGER.exception('Unable to get slice({:s} / {:s})'.format(str(context_uuid), str(slice_uuid))) return None
src/common/tools/context_queries/Slice.py 0 → 100644 +39 −0 Original line number Original line Diff line number Diff line # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) # # 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 grpc, logging from typing import Optional from common.Constants import DEFAULT_CONTEXT_UUID from common.proto.context_pb2 import Slice, SliceId from context.client.ContextClient import ContextClient LOGGER = logging.getLogger(__name__) def get_slice( context_client : ContextClient, slice_uuid : str, context_uuid : str = DEFAULT_CONTEXT_UUID, rw_copy : bool = False ) -> Optional[Slice]: try: # pylint: disable=no-member slice_id = SliceId() slice_id.context_id.context_uuid.uuid = context_uuid slice_id.slice_uuid.uuid = slice_uuid ro_slice = context_client.GetSlice(slice_id) if not rw_copy: return ro_slice rw_slice = Slice() rw_slice.CopyFrom(ro_slice) return rw_slice except grpc.RpcError: #LOGGER.exception('Unable to get slice({:s} / {:s})'.format(str(context_uuid), str(slice_uuid))) return None