Commit 0c949f77 authored by Carlos Manso's avatar Carlos Manso
Browse files

Merge branch 'develop' into feat/68-cttc-add-sbi-driver-for-flex-scale-optical-sdn-controller

parents 0a48591d 1cdafbad
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@ spec:
          value: "nats"
        - name: LOG_LEVEL
          value: "INFO"
        - name: ALLOW_EXPLICIT_ADD_DEVICE_TO_TOPOLOGY
          value: "FALSE"
        - name: ALLOW_EXPLICIT_ADD_LINK_TO_TOPOLOGY
          value: "FALSE"
        envFrom:
        - secretRef:
            name: crdb-data
+57 −6
Original line number Diff line number Diff line
@@ -143,17 +143,34 @@ class MockServicerImpl_Context(ContextServiceServicer):

    def SetTopology(self, request: Topology, context : grpc.ServicerContext) -> TopologyId:
        LOGGER.debug('[SetTopology] request={:s}'.format(grpc_message_to_json_string(request)))
        container_name = 'topology[{:s}]'.format(str(request.topology_id.context_id.context_uuid.uuid))
        context_uuid = str(request.topology_id.context_id.context_uuid.uuid)
        container_name = 'topology[{:s}]'.format(context_uuid)
        topology_uuid = request.topology_id.topology_uuid.uuid
        reply,_ = self._set(request, container_name, topology_uuid, 'topology_id', TOPIC_TOPOLOGY)

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _topology_id in context_.topology_ids:
            if _topology_id.topology_uuid.uuid == topology_uuid: break
        else:
            # topology not found, add it
            context_.topology_ids.add().topology_uuid.uuid = topology_uuid

        LOGGER.debug('[SetTopology] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

    def RemoveTopology(self, request: TopologyId, context : grpc.ServicerContext) -> Empty:
        LOGGER.debug('[RemoveTopology] request={:s}'.format(grpc_message_to_json_string(request)))
        container_name = 'topology[{:s}]'.format(str(request.context_id.context_uuid.uuid))
        context_uuid = str(request.context_id.context_uuid.uuid)
        container_name = 'topology[{:s}]'.format(context_uuid)
        topology_uuid = request.topology_uuid.uuid
        reply = self._del(request, container_name, topology_uuid, 'topology_id', TOPIC_TOPOLOGY, context)

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _topology_id in context_.topology_ids:
            if _topology_id.topology_uuid.uuid == topology_uuid:
                context_.topology_ids.remove(_topology_id)
                break

        LOGGER.debug('[RemoveTopology] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

@@ -368,17 +385,34 @@ class MockServicerImpl_Context(ContextServiceServicer):

    def SetSlice(self, request: Slice, context : grpc.ServicerContext) -> SliceId:
        LOGGER.debug('[SetSlice] request={:s}'.format(grpc_message_to_json_string(request)))
        container_name = 'slice[{:s}]'.format(str(request.slice_id.context_id.context_uuid.uuid))
        context_uuid = str(request.slice_id.context_id.context_uuid.uuid)
        container_name = 'slice[{:s}]'.format(context_uuid)
        slice_uuid = request.slice_id.slice_uuid.uuid
        reply,_ = self._set(request, container_name, slice_uuid, 'slice_id', TOPIC_SLICE)

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _slice_id in context_.slice_ids:
            if _slice_id.slice_uuid.uuid == slice_uuid: break
        else:
            # slice not found, add it
            context_.slice_ids.add().slice_uuid.uuid = slice_uuid

        LOGGER.debug('[SetSlice] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

    def RemoveSlice(self, request: SliceId, context : grpc.ServicerContext) -> Empty:
        LOGGER.debug('[RemoveSlice] request={:s}'.format(grpc_message_to_json_string(request)))
        container_name = 'slice[{:s}]'.format(str(request.context_id.context_uuid.uuid))
        context_uuid = str(request.slice_id.context_id.context_uuid.uuid)
        container_name = 'slice[{:s}]'.format(context_uuid)
        slice_uuid = request.slice_uuid.uuid
        reply = self._del(request, container_name, slice_uuid, 'slice_id', TOPIC_SLICE, context)

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _slice_id in context_.slice_ids:
            if _slice_id.slice_uuid.uuid == slice_uuid:
                context_.slice_ids.remove(_slice_id)
                break

        LOGGER.debug('[RemoveSlice] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

@@ -443,17 +477,34 @@ class MockServicerImpl_Context(ContextServiceServicer):

    def SetService(self, request: Service, context : grpc.ServicerContext) -> ServiceId:
        LOGGER.debug('[SetService] request={:s}'.format(grpc_message_to_json_string(request)))
        container_name = 'service[{:s}]'.format(str(request.service_id.context_id.context_uuid.uuid))
        context_uuid = str(request.service_id.context_id.context_uuid.uuid)
        container_name = 'service[{:s}]'.format(context_uuid)
        service_uuid = request.service_id.service_uuid.uuid
        reply,_ = self._set(request, container_name, service_uuid, 'service_id', TOPIC_SERVICE)

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _service_id in context_.service_ids:
            if _service_id.service_uuid.uuid == service_uuid: break
        else:
            # service not found, add it
            context_.service_ids.add().service_uuid.uuid = service_uuid

        LOGGER.debug('[SetService] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

    def RemoveService(self, request: ServiceId, context : grpc.ServicerContext) -> Empty:
        LOGGER.debug('[RemoveService] request={:s}'.format(grpc_message_to_json_string(request)))
        container_name = 'service[{:s}]'.format(str(request.context_id.context_uuid.uuid))
        context_uuid = str(request.service_id.context_id.context_uuid.uuid)
        container_name = 'service[{:s}]'.format(context_uuid)
        service_uuid = request.service_uuid.uuid
        reply = self._del(request, container_name, service_uuid, 'service_id', TOPIC_SERVICE, context)

        context_ = self.obj_db.get_entry('context', context_uuid, context)
        for _service_id in context_.service_ids:
            if _service_id.service_uuid.uuid == service_uuid:
                context_.service_ids.remove(_service_id)
                break

        LOGGER.debug('[RemoveService] reply={:s}'.format(grpc_message_to_json_string(reply)))
        return reply

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ def get_topology(
def get_topology_details(
        context_client : ContextClient, topology_uuid : str, context_uuid : str = DEFAULT_CONTEXT_NAME,
        rw_copy : bool = False
    ) -> Optional[Topology]:
    ) -> Optional[TopologyDetails]:
    try:
        # pylint: disable=no-member
        topology_id = TopologyId()
+19 −9
Original line number Diff line number Diff line
@@ -240,11 +240,16 @@ class DescriptorLoader:
        self._process_descr('slice',      'add',    self.__ctx_cli.SetSlice,      Slice,      self.__slices        )
        self._process_descr('connection', 'add',    self.__ctx_cli.SetConnection, Connection, self.__connections   )

        # Update context and topology is useless:
        # - devices and links are assigned to topologies automatically by Context component
        # - topologies, services, and slices are assigned to contexts automatically by Context component
        # By default the Context component automatically assigns devices and links to topologies based on their
        # endpoints, and assigns topologies, services, and slices to contexts based on their identifiers.

        # The following statement is useless; up to now, any use case requires assigning a topology, service, or
        # slice to a different context.
        #self._process_descr('context',    'update', self.__ctx_cli.SetContext,    Context,    self.__contexts      )
        #self._process_descr('topology',   'update', self.__ctx_cli.SetTopology,   Topology,   self.__topologies    )

        # In some cases, it might be needed to assign devices and links to multiple topologies; the
        # following statement performs that assignment.
        self._process_descr('topology',   'update', self.__ctx_cli.SetTopology,   Topology,   self.__topologies    )

        #self.__ctx_cli.close()

@@ -272,11 +277,16 @@ class DescriptorLoader:
        self._process_descr('slice',    'add',    self.__slc_cli.CreateSlice,     Slice,    self.__slices_add    )
        self._process_descr('slice',    'update', self.__slc_cli.UpdateSlice,     Slice,    self.__slices        )

        # Update context and topology is useless:
        # - devices and links are assigned to topologies automatically by Context component
        # - topologies, services, and slices are assigned to contexts automatically by Context component
        # By default the Context component automatically assigns devices and links to topologies based on their
        # endpoints, and assigns topologies, services, and slices to contexts based on their identifiers.

        # The following statement is useless; up to now, any use case requires assigning a topology, service, or
        # slice to a different context.
        #self._process_descr('context',  'update', self.__ctx_cli.SetContext,      Context,  self.__contexts      )
        #self._process_descr('topology', 'update', self.__ctx_cli.SetTopology,     Topology, self.__topologies    )

        # In some cases, it might be needed to assign devices and links to multiple topologies; the
        # following statement performs that assignment.
        self._process_descr('topology', 'update', self.__ctx_cli.SetTopology,     Topology, self.__topologies    )

        #self.__slc_cli.close()
        #self.__svc_cli.close()
+12 −0
Original line number Diff line number Diff line
@@ -12,3 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from common.Settings import get_setting

TRUE_VALUES = {'Y', 'YES', 'T', 'TRUE', 'E', 'ENABLE', 'ENABLED'}
def is_enabled(setting_name : str, default_value : bool) -> bool:
    _is_enabled = get_setting(setting_name, default=None)
    if _is_enabled is None: return default_value
    str_is_enabled = str(_is_enabled).upper()
    return str_is_enabled in TRUE_VALUES

DEFAULT_VALUE = False
ALLOW_EXPLICIT_ADD_DEVICE_TO_TOPOLOGY = is_enabled('ALLOW_EXPLICIT_ADD_DEVICE_TO_TOPOLOGY', DEFAULT_VALUE)
ALLOW_EXPLICIT_ADD_LINK_TO_TOPOLOGY   = is_enabled('ALLOW_EXPLICIT_ADD_LINK_TO_TOPOLOGY',   DEFAULT_VALUE)
Loading