当前位置: 首页>>代码示例>>Python>>正文


Python RUNTIME.load_tenant_by_plmn_id方法代码示例

本文整理汇总了Python中empower.main.RUNTIME.load_tenant_by_plmn_id方法的典型用法代码示例。如果您正苦于以下问题:Python RUNTIME.load_tenant_by_plmn_id方法的具体用法?Python RUNTIME.load_tenant_by_plmn_id怎么用?Python RUNTIME.load_tenant_by_plmn_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在empower.main.RUNTIME的用法示例。


在下文中一共展示了RUNTIME.load_tenant_by_plmn_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _handle_UEs_id_repl

# 需要导入模块: from empower.main import RUNTIME [as 别名]
# 或者: from empower.main.RUNTIME import load_tenant_by_plmn_id [as 别名]
    def _handle_UEs_id_repl(self, main_msg):
        """Handle an incoming UEs ID reply.

        Args:
            message, a emage_msg containing UE IDs (RNTIs)
        Returns:
            None
        """

        active_ues = {}
        inactive_ues = {}

        event_type = main_msg.WhichOneof("event_types")
        msg = protobuf_to_dict(main_msg)
        ues_id_msg_repl = msg[event_type]["mUEs_id"]["repl"]

        if ues_id_msg_repl["status"] != configs_pb2.CREQS_SUCCESS:
            return

        # List of active UEs
        if "active_ue_id" in ues_id_msg_repl:
            for ue in ues_id_msg_repl["active_ue_id"]:
                active_ues[(self.vbs.addr, ue["rnti"])] = {}
                if "imsi" in ue:
                    active_ues[(self.vbs.addr, ue["rnti"])]["imsi"] = ue["imsi"]
                else:
                    active_ues[(self.vbs.addr, ue["rnti"])]["imsi"] = None
                if "plmn_id" in ue:
                    active_ues[(self.vbs.addr, ue["rnti"])]["plmn_id"] = \
                                                                ue["plmn_id"]
                else:
                    active_ues[(self.vbs.addr, ue["rnti"])]["plmn_id"] = None

        # List of inactive UEs
        if "inactive_ue_id" in ues_id_msg_repl:
            for ue in ues_id_msg_repl["inactive_ue_id"]:
                inactive_ues[(self.vbs.addr, ue["rnti"])] = {}
                if "imsi" in ue:
                    inactive_ues[(self.vbs.addr, ue["rnti"])]["imsi"] = \
                                                                    ue["imsi"]
                else:
                    inactive_ues[(self.vbs.addr, ue["rnti"])]["imsi"] = None
                if "plmn_id" in ue:
                    inactive_ues[(self.vbs.addr, ue["rnti"])]["plmn_id"] = \
                                                                ue["plmn_id"]
                else:
                    inactive_ues[(self.vbs.addr, ue["rnti"])]["plmn_id"] = None

        for vbs_id, rnti in active_ues.keys():

            ue_id = (self.vbs.addr, rnti)

            if ue_id not in RUNTIME.ues:
                new_ue = UE(ue_id, ue_id[1], self.vbs)
                RUNTIME.ues[ue_id] = new_ue

            ue = RUNTIME.ues[ue_id]

            imsi = active_ues[ue_id]["imsi"]
            plmn_id = int(active_ues[ue_id]["plmn_id"])

            # Setting IMSI of UE
            ue.imsi = imsi

            if not ue.plmn_id and plmn_id:

                # Setting tenant
                ue.tenant = RUNTIME.load_tenant_by_plmn_id(plmn_id)

                if ue.tenant:

                    # Adding UE to tenant
                    LOG.info("Adding %s to tenant %s", ue.addr,
                             ue.tenant.plmn_id)
                    ue.tenant.ues[ue.addr] = ue

                    # Raise UE join
                    self.server.send_ue_join_message_to_self(ue)

                    # Create a trigger for reporting RRC measurements config.
                    from empower.ue_confs.ue_rrc_meas_confs import ue_rrc_meas_confs

                    conf_req = {
                        "event_type": "trigger"
                    }

                    ue_rrc_meas_confs(tenant_id=ue.tenant.tenant_id,
                                      vbs=ue.vbs.addr,
                                      ue=ue.rnti,
                                      conf_req=conf_req)

            if ue.plmn_id and not plmn_id:

                # Raise UE leave
                self.server.send_ue_leave_message_to_self(ue)

                # Removing UE from tenant
                LOG.info("Removing %s from tenant %s", ue.addr,
                         ue.tenant.plmn_id)
                del ue.tenant.ues[ue.addr]
#.........这里部分代码省略.........
开发者ID:5g-empower,项目名称:empower-runtime,代码行数:103,代码来源:vbspconnection.py

示例2: _handle_UEs_id_repl

# 需要导入模块: from empower.main import RUNTIME [as 别名]
# 或者: from empower.main.RUNTIME import load_tenant_by_plmn_id [as 别名]
    def _handle_UEs_id_repl(self, main_msg):
        """Handle an incoming UEs ID reply.

        Args:
            message, a emage_msg containing UE IDs (RNTIs)
        Returns:
            None
        """

        active_ues = {}
        inactive_ues = {}

        event_type = main_msg.WhichOneof("event_types")
        msg = protobuf_to_dict(main_msg)
        ues_id_msg_repl = msg[event_type]["mUEs_id"]["repl"]

        if ues_id_msg_repl["status"] != configs_pb2.CREQS_SUCCESS:
            return

        # List of active UEs
        if "active_ue_id" in ues_id_msg_repl:
            for ue in ues_id_msg_repl["active_ue_id"]:
                active_ues[ue["rnti"]] = {}
                if "imsi" in ue:
                    active_ues[ue["rnti"]]["imsi"] = ue["imsi"]
                else:
                    active_ues[ue["rnti"]]["imsi"] = None
                if "plmn_id" in ue:
                    active_ues[ue["rnti"]]["plmn_id"] = ue["plmn_id"]
                else:
                    active_ues[ue["rnti"]]["plmn_id"] = None

        # List of inactive UEs
        if "inactive_ue_id" in ues_id_msg_repl:
            for ue in ues_id_msg_repl["inactive_ue_id"]:
                inactive_ues[ue["rnti"]] = {}
                if "imsi" in ue:
                    inactive_ues[ue["rnti"]]["imsi"] = ue["imsi"]
                else:
                    inactive_ues[ue["rnti"]]["imsi"] = None
                if "plmn_id" in ue:
                    inactive_ues[ue["rnti"]]["plmn_id"] = ue["plmn_id"]
                else:
                    inactive_ues[ue["rnti"]]["plmn_id"] = None

        for rnti in active_ues:

            ue_id = hex_to_ether(rnti)

            if ue_id not in RUNTIME.ues:

                ue_id = hex_to_ether(rnti)
                imsi = active_ues[ue["rnti"]]["imsi"]
                new_ue = UE(ue_id, imsi, self.vbs)

                RUNTIME.ues[ue_id] = new_ue

            ue = RUNTIME.ues[ue_id]
            plmn_id = int(active_ues[rnti]["plmn_id"])

            if not ue.plmn_id and plmn_id:

                # setting tenant
                ue.tenant = RUNTIME.load_tenant_by_plmn_id(plmn_id)

                if ue.tenant:

                    # adding UE to tenant
                    LOG.info("Adding %s to tenant %s", ue.addr,
                             ue.tenant.plmn_id)
                    ue.tenant.ues[ue.addr] = ue

                    # Raise UE join
                    self.server.send_ue_join_message_to_self(ue)

            if ue.plmn_id and not plmn_id:

                # removing UE from tenant
                LOG.info("Removing %s from tenant %s", ue.addr,
                         ue.tenant.plmn_id)
                del ue.tenant.ues[ue.addr]

                # Raise UE leave
                self.server.send_ue_leave_message_to_self(ue)

                # setting tenant
                ue.tenant = None

        existing_ues = []
        existing_ues.extend(RUNTIME.ues.keys())

        for ue_id in existing_ues:
            if ether_to_hex(ue_id) not in active_ues:
                RUNTIME.remove_ue(ue_id)
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:96,代码来源:vbspconnection.py


注:本文中的empower.main.RUNTIME.load_tenant_by_plmn_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。