Ejemplo n.º 1
0
 def test_CcapCoreIdentification(self):
     try:
         ret = CcapCoreIdentification(index=None)
     except Exception as e:
         self.assertIsInstance(e, AttributeError)
     ret = CcapCoreIdentification(index=1,
                                  core_id="CORE_12312ds",
                                  core_ip_addr="1.1.1.1",
                                  is_principal=True,
                                  core_name="CBR",
                                  vendor_id=9,
                                  core_mode=True)
     self.assertIsInstance(ret, CcapCoreIdentification)
Ejemplo n.º 2
0
    def recvCcapCoreIdentification(self, cfgMsg):
        rcp_msg = self.DeSerializeConfigMsgPayload(cfgMsg)
        if rcp_msg is None:
            return {
                "Status": HalCommon_pb2.FAILED,
                "ErrorDescription": "DeSerialize ConfigMsgPayload fail"
            }
        self.logger.debug(
            "ProvMgr driver receive Config CcapCoreIdentification %s" %
            str(rcp_msg))
        if rcp_msg.RpdDataMessage.RpdDataOperation == t_RpdDataMessage.RPD_CFG_READ:
            rcp_msg.RcpDataResult = t_RcpMessage.RCP_RESULT_OK
            del rcp_msg.RpdDataMessage.RpdData.CcapCoreIdentification[0]
            for key in CcapCoreIdentification.get_keys():
                ccapCoreIdent = rcp_msg.RpdDataMessage.RpdData.CcapCoreIdentification.add(
                )
                ccapCore = CcapCoreIdentification(key)
                ccapCore.read()

                ccapCoreIdent.Index = key
                ccapCoreIdent.CoreId = ccapCore.core_id
                ccapCoreIdent.CoreIpAddress = ccapCore.core_ip_addr
                ccapCoreIdent.IsPrincipal = ccapCore.is_principal
                ccapCoreIdent.CoreName = ccapCore.core_name
                ccapCoreIdent.VendorId = ccapCore.vendor_id
                ccapCoreIdent.InitialConfigurationComplete = ccapCore.initial_configuration_complete
                ccapCoreIdent.MoveToOperational = ccapCore.move_to_operational
                ccapCoreIdent.CoreFunction = ccapCore.core_function
                ccapCoreIdent.ResourceSetIndex = ccapCore.resource_set_index
                ccapCoreIdent.CoreMode = ccapCore.core_mode
                self.logger.debug("ProvMgr driver rsp ccapCoreIdent tlv %s" %
                                  ccapCoreIdent)
            cfgMsg.CfgMsgPayload = rcp_msg.SerializeToString()

            rsp = {
                "Status": HalCommon_pb2.SUCCESS,
                "ErrorDescription": "Serialize ConfigMsgPayload success"
            }
            return rsp
        if rcp_msg.RpdDataMessage.RpdDataOperation == t_RpdDataMessage.RPD_CFG_WRITE or \
           rcp_msg.RpdDataMessage.RpdDataOperation == t_RpdDataMessage.RPD_CFG_ALLOCATE_WRITE:
            rsp = {
                "Status":
                HalCommon_pb2.SUCCESS_IGNORE_RESULT,
                "ErrorDescription":
                "manager hal ignore write and allocate write for ccapCoreIdentification"
            }
            return rsp
Ejemplo n.º 3
0
    def test_RCPMaster(self):
        try:
            RCPMaster(session_descriptor=None, dispatcher=self.dispatcher)
        except Exception as e:
            self.assertIsInstance(e, TypeError)

        cap = CcapCoreIdentification(index=1,
                                     core_id="CORE_12312ds",
                                     core_ip_addr="1.1.1.1",
                                     is_principal=True,
                                     core_name="CBR",
                                     vendor_id=9,
                                     core_mode=True)
        scena = RCPMasterScenario()

        desc = RCPMasterDescriptor(capabilities=cap,
                                   addr="localhost",
                                   scenario=scena)
        master = RCPMaster(session_descriptor=desc,
                           dispatcher=self.dispatcher,
                           scenario=scena)
        self.assertIsInstance(master, RCPMaster)
        master.initiate()
        self.assertTrue(master.is_initiated())

        # start slave working thread
        t = threading.Thread(target=self.__slave_worker())
        t.start()
        fd = master.accept_connection()
        self.assertIsNotNone(fd)

        rsp_list = master.get_responses_list(fd)
        self.assertIsNotNone(rsp_list)

        test = "test"
        master.add_response(pkt=test, fd=fd)
        self.assertEqual(0, master.get_responses_count(fd=fd))

        pkt = rcp.RCPPacket()
        master.add_response(pkt=pkt, fd=fd)
        self.assertEqual(1, master.get_responses_count(fd=fd))
        ret_pkt = master.get_last_response(fd)
        self.assertEqual(pkt, ret_pkt)

        master.close()
        master.remove_connection(fd)
        # wait for the thread
        self.slave_work_run = False
        t.join()
        master.close()
        self.session.close()
        master.dispatcher = None
        master.remove_connection(fd=fd)
        master.close()
Ejemplo n.º 4
0
 def setup_master(cls):
     print "setup master"
     caps = CcapCoreIdentification(index=1,
                                   core_id="SIM",
                                   core_ip_addr=local_ip,
                                   is_principal=True,
                                   core_name="Master_SIM",
                                   vendor_id=0,
                                   core_mode=True,
                                   initial_configuration_complete=True,
                                   move_to_operational=True,
                                   core_function=1,
                                   resource_set_index=2)
     caps.write()
     cls.master_desc = RCPMasterDescriptor(caps,
                                           addr=local_ip,
                                           port=local_port,
                                           addr_family=addr_family,
                                           interface_name=local_interface)
     cls.master_orchestrator = RCPMasterOrchestrator(cls.master_disp)
     cls.master_thread = threading.Thread(target=cls.master_disp.loop)
     cls.master_thread.start()
     time.sleep(1)
Ejemplo n.º 5
0
    def test_RCPMasterDescriptor(self):
        try:
            ret = RCPMasterDescriptor(capabilities=None, addr=None)
        except Exception as e:
            self.assertIsInstance(e, TypeError)

        cap = CcapCoreIdentification(index=1,
                                     core_id="CORE_12312ds",
                                     core_ip_addr="1.1.1.1",
                                     is_principal=True,
                                     core_name="CBR",
                                     vendor_id=9,
                                     core_mode=True)
        test = "test"
        try:
            ret = RCPMasterDescriptor(capabilities=cap,
                                      addr=None,
                                      scenario=test)
        except Exception as e:
            self.assertIsInstance(e, TypeError)

        ret = RCPMasterDescriptor(capabilities=cap, addr="1.1.1.1")
        self.assertIsInstance(ret, RCPMasterDescriptor)
Ejemplo n.º 6
0
    with open(
            os.path.dirname(os.path.abspath(__file__)) +
            identification_file) as core_identification:
        ccap_core_identification = json.load(core_identification)
    with open(os.path.dirname(os.path.abspath(__file__)) +
              i07_file) as i07data:
        customize_data = json.load(i07data)
    caps = CcapCoreIdentification(
        index=ccap_core_identification["index"],
        core_id=ccap_core_identification["core_id"],
        core_ip_addr=ccap_core_identification["core_ip_addr"],
        is_principal=ccap_core_identification["is_principal"] == str(True),
        core_name=ccap_core_identification["core_name"],
        vendor_id=ccap_core_identification["vendor_id"],
        core_mode=ccap_core_identification["core_mode"],
        initial_configuration_complete=ccap_core_identification[
            "initial_configuration_complete"] == str(True),
        move_to_operational=ccap_core_identification["move_to_operational"] ==
        str(True),
        core_function=ccap_core_identification["core_function"],
        resource_set_index=ccap_core_identification["resource_set_index"],
        data=customize_data)

    desc = RCPMasterDescriptor(caps,
                               addr=local_ip,
                               port=local_port,
                               addr_family=addr_family,
                               interface_name=local_interface)

    orch = rcp_master_orchestrator.RCPMasterOrchestrator(disp)
Ejemplo n.º 7
0
 def getCoreId(self, ccapLcceIpAddr=None):
     if not ccapLcceIpAddr:
         ccapLcceIpAddr = self.index.ccapLcceIpAddr
     identRecord = CcapCoreIdentification()
     identRecord.allocateIndex(ccapLcceIpAddr)
     return identRecord.core_id
Ejemplo n.º 8
0
    def test_handle_eds_pkt_core_ident_AW(self):
        self.db = RCPDB()
        coreIdentRecord = CcapCoreIdentification()
        coreIdentRecord.Index = 0
        coreIdentRecord.IsPrincipal = True
        coreIdentRecord.CoreMode = 1
        coreIdentRecord.CoreId = 'CoreId'
        coreIdentRecord.CoreIpAddress = '127.0.0.1'
        coreIdentRecord.CoreName = 'CoreName'
        coreIdentRecord.VendorId = 9
        coreIdentRecord.write()
        self.slave_orchestrator.add_sessions([self.slave_desc])
        if not len(self.slave_orchestrator.sessions_active):
            print 'session init fail'
            return
        slave = self.slave_orchestrator.sessions_active.values()[0]
        pkt_handler = self.slave_orchestrator.pkt_handler.handle_msg_eds_req

        # read rpd capability
        pkt, msg = self.construct_eds_pkt_redirect()
        pkt_handler(msg, slave, pkt)

        # write ssd
        slave.ccap_identification = self.master_desc.capabilities
        slave.ccap_identification.is_active = False
        pkt, msg = self.construct_eds_pkt_write_ssd()
        pkt_handler(msg, slave, pkt)

        # Global, not active
        pkt, msg = self.construct_eds_pkt_RpdGlobal()
        pkt_handler(msg, slave, pkt)

        # CcapCoreIdentification
        pkt, msg = self.construct_eds_pkt_CcapCoreIdentification_AW(
            TestOrchestrator.CORE_STATE_INIT)
        pkt_handler(msg, slave, pkt)

        pkt, msg = self.construct_eds_pkt_CcapCoreIdentification_AW(
            TestOrchestrator.CORE_STATE_CFG_COMPLETE)
        pkt_handler(msg, slave, pkt)

        # configuration done
        pkt, msg = self.construct_eds_pkt_RpdConfigurationDone()
        pkt_handler(msg, slave, pkt)

        # Global, principal and active
        pkt, msg = self.construct_eds_pkt_RpdGlobal()
        pkt_handler(msg, slave, pkt)

        pkt, msg = self.construct_eds_pkt_CcapCoreIdentification_AW(
            TestOrchestrator.CORE_STATE_MOVE_TO_OPTIONAL)
        pkt_handler(msg, slave, pkt)
        coreIdentRecord.index = 1
        coreIdentRecord.read()
        self.assertTrue((coreIdentRecord.index == 1))
        self.assertEqual(coreIdentRecord.move_to_operational, True)
Ejemplo n.º 9
0
    def test_handle_eds_pkt_AW(self):
        coreIdentRecord = CcapCoreIdentification()
        coreIdentRecord.Index = 0
        coreIdentRecord.IsPrincipal = True
        coreIdentRecord.CoreMode = 1
        coreIdentRecord.CoreId = 'CoreId'
        coreIdentRecord.CoreIpAddress = '127.0.0.1'
        coreIdentRecord.CoreName = 'CoreName'
        coreIdentRecord.VendorId = 9
        coreIdentRecord.write()
        aw_type = rcp_tlv_def.RCP_OPERATION_TYPE_ALLOCATE_WRITE
        wr_type = rcp_tlv_def.RCP_OPERATION_TYPE_WRITE
        self.slave_orchestrator.add_sessions([self.slave_desc])
        if not len(self.slave_orchestrator.sessions_active):
            print 'session init fail'
            return
        slave = self.slave_orchestrator.sessions_active.values()[0]
        pkt_handler = self.slave_orchestrator.pkt_handler.handle_msg_eds_req

        # CcapCoreIdentification
        pkt, msg = self.construct_eds_pkt_CcapCoreIdentification(
            False, aw_type)
        pkt_handler(msg, slave, pkt)

        pkt, msg = self.construct_eds_pkt_CcapCoreIdentification(True, wr_type)
        pkt_handler(msg, slave, pkt)

        # configuration done
        pkt, msg = self.construct_eds_pkt_RpdConfigurationDone()
        pkt_handler(msg, slave, pkt)

        # Global, principal and active
        pkt, msg = self.construct_eds_pkt_RpdGlobal()
        pkt_handler(msg, slave, pkt)

        # Configured core table
        pkt, msg = self.construct_eds_pkt_ConfiguredCoreTable()
        pkt_handler(msg, slave, pkt)

        # Active principal core get request
        pkt, msg = self.construct_eds_pkt_ActivePrincipalCore()
        pkt_handler(msg, slave, pkt)
        self.assertTrue(slave.is_ira_recv)
Ejemplo n.º 10
0
    def test_rcp_msg_cb_event(self):
        print '############test rcp_msg_cb event case#############'
        RCPDB.DB_CFG_FILE = CONF_FILE
        seq = RCPSequence(gcp_msg_def.DataStructREQ,
                          rcp_tlv_def.RCP_MSG_TYPE_REX,
                          1,
                          rcp_tlv_def.RCP_OPERATION_TYPE_READ,
                          unittest=True)
        desc = GCPSlaveDescriptor(
            '1.1.1.1', port_master='8190', addr_local='1.1.1.2',
            interface_local='eth0',
            addr_family=socket.AF_INET)
        orch = self.agent.process.orchestrator
        session = RCPSlaveSession(desc, self.agent.process.dispatcher,
                                  orch.session_initiate_cb,
                                  orch.session_timeout_cb,
                                  orch.session_connecting_timeout_cb)
        # reboot
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.RPD_REBOOT

        ccap_core_para = {'addr_remote': '1.1.1.1', 'interface_local': 'eth1', 'info': "test"}
        rcp_msg.parameter = json.dumps(ccap_core_para)
        self.agent.rcp_msg_cb(rcp_msg)

        # redirect
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.REDIRECT_NOTIFICATION
        ccap_core_para = {'addr_remote': '1.1.1.1', 'interface_local': 'eth0', 'info': "test"}
        rcp_msg.parameter = json.dumps(ccap_core_para)
        rcp_msg.RedirectCCAPAddresses.append('3.3.3.3')
        self.agent.rcp[('eth0', '1.1.1.1')]['status'] = self.agent.UP
        self.agent.rcp_msg_cb(rcp_msg)

        # configuration
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.RPD_CONFIGURATION
        cfg = rcp_msg.RpdDataMessage.RpdData
        rcp_msg.parameter = 'eth0'
        capability = cfg.CcapCoreIdentification.add()
        capability.Index = 1
        capability.CoreId = 'CoreId'
        capability.CoreIpAddress = '1.1.1.1'
        capability.IsPrincipal = True
        capability.CoreMode = 1
        capability.CoreName = "CiscoRPD"
        capability.VendorId = 1
        capability.InitialConfigurationComplete = True
        capability.MoveToOperational = True
        capability.CoreFunction = 1
        capability.ResourceSetIndex = 2
        self.agent.rcp[('eth0', '1.1.1.1')]['status'] = self.agent.DOWN
        self.agent.rcp_msg_cb(rcp_msg)

        # RedundantCoreIpAddress
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.RPD_CONFIGURATION
        cfg = rcp_msg.RpdDataMessage.RpdData
        rcp_msg.parameter = 'eth0'
        red = cfg.RedundantCoreIpAddress.add()
        red.ActiveCoreIpAddress = '1.1.1.1'
        red.StandbyCoreIpAddress = '1.1.1.3'
        self.agent.rcp_msg_cb(rcp_msg)  # no must field

        desc1 = GCPSlaveDescriptor(
            '1.1.1.1', port_master='8190', addr_local='1.1.1.2',
            interface_local='eth0',
            addr_family=socket.AF_INET)
        orch = self.agent.process.orchestrator
        session_1 = RCPSlaveSession(desc1, self.agent.process.dispatcher,
                                    orch.session_initiate_cb,
                                    orch.session_timeout_cb,
                                    orch.session_connecting_timeout_cb)
        self.agent.process.orchestrator.sessions_active[desc1.get_uniq_id()] = session_1
        caps1 = CcapCoreIdentification(index=1,
                                       core_id="CoreId-1",
                                       core_ip_addr='1.1.1.1',
                                       is_principal=True,
                                       core_name="SIM_GCPP",
                                       vendor_id=0,
                                       core_mode=True,
                                       initial_configuration_complete=True,
                                       move_to_operational=True,
                                       core_function=1,
                                       resource_set_index=2)
        session_1.ccap_identification = caps1

        desc2 = GCPSlaveDescriptor(
            '1.1.1.3', port_master='8190', addr_local='1.1.1.2',
            interface_local='eth0',
            addr_family=socket.AF_INET)
        orch = self.agent.process.orchestrator
        session_2 = RCPSlaveSession(desc2, self.agent.process.dispatcher,
                                    orch.session_initiate_cb,
                                    orch.session_timeout_cb,
                                    orch.session_connecting_timeout_cb)
        # self.agent.process.orchestrator.add_sessions([desc2])
        self.agent.process.orchestrator.sessions_active[desc2.get_uniq_id()] = session_2
        caps2 = CcapCoreIdentification(index=1,
                                       core_id="CoreId-2",
                                       core_ip_addr='1.1.1.1',
                                       is_principal=True,
                                       core_name="SIM_GCPP",
                                       vendor_id=0,
                                       core_mode=True,
                                       initial_configuration_complete=True,
                                       move_to_operational=True,
                                       core_function=1,
                                       resource_set_index=2)
        session_2.ccap_identification = caps2

        caps1.is_active = False
        caps2.is_active = True
        red.Operation = ManagerProcess.OPERATION_ADD
        self.agent.rcp_msg_cb(rcp_msg)

        caps1.is_active = True
        caps2.is_active = False
        red.Operation = ManagerProcess.OPERATION_CHANGE
        self.agent.rcp_msg_cb(rcp_msg)

        # ConfiguredCoreTable
        # miss operation field
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.RPD_CONFIGURATION
        cfg = rcp_msg.RpdDataMessage.RpdData
        cfg_core = cfg.ConfiguredCoreTable.add()
        cfg_core.ConfiguredCoreIp = '1.1.1.1'
        self.agent.rcp_msg_cb(rcp_msg)

        cfg_core.Operation = 0
        self.agent.rcp_msg_cb(rcp_msg)

        # ActivePrincipalCore
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.RPD_CONFIGURATION
        cfg = rcp_msg.RpdDataMessage.RpdData
        cfg.ActivePrincipalCore = '1.1.1.1'
        seq.ipc_msg = rcp_msg
        self.agent.rcp_msg_cb(seq, (session, 'transaction_identifier', 'trans_id'))

        # RPD_CONFIGURATION else
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.RPD_CONFIGURATION
        cfg = rcp_msg.RpdDataMessage.RpdData
        cfg_core = cfg.Ssd
        cfg_core.SsdServerAddress = '1.1.1.1'
        self.agent.rcp_msg_cb(rcp_msg)

        # configuration done
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.RPD_CONFIGURATION_DONE
        rcp_msg.parameter = ';'.join(['eth0', '1.1.1.1'])
        self.agent.principal_core_interface = 'eth0'
        self.agent.principal_core = '1.1.1.1'
        self.agent.rcp_msg_cb(rcp_msg, (session, 'transaction_identifier', 'trans_id'))

        # CONNECT_CLOSE_NOTIFICATION
        rcp_msg = t_RcpMessage()
        rcp_msg.RcpMessageType = rcp_msg.CONNECT_CLOSE_NOTIFICATION
        ccap_core_para = {'addr_remote': '1.1.1.1', 'interface_local': 'eth0', "reconnect": True}
        rcp_msg.parameter = json.dumps(ccap_core_para)
        self.agent.ccap_cores.pop('CORE-1234567890')
        self.agent.rcp_msg_cb(rcp_msg)

        ccap_core_para = {'addr_remote': '1.1.1.1', 'interface_local': 'eth0', "reconnect": False}
        rcp_msg.parameter = json.dumps(ccap_core_para)
        self.agent.rcp_msg_cb(rcp_msg)
Ejemplo n.º 11
0
    def _service_configure(self, gpb_params):
        self._disable()

        scenario = None
        if None is not gpb_params:
            msg_class = t_ItApiServiceCcapCoreV4 if \
                self.addr_family == socket.AF_INET else \
                t_ItApiServiceCcapCoreV6
            if not isinstance(gpb_params, msg_class):
                self.logger.error(
                    "Invalid GPB message passed {}".format(gpb_params))
                return False

            pkt_builder = RCPMasterPacketBuildDirector()
            scenario = None
            for gpb_scenario in gpb_params.ClientScenarios:
                if gpb_scenario.ScenarioType == gpb_scenario.SCENARIO_DEFAULT:
                    continue

                if None is scenario:
                    scenario = RCPMasterScenario()

                if gpb_scenario.ScenarioType == gpb_scenario.SCENARIO_REDIRECT:
                    if not hasattr(gpb_scenario, "redirect_ip_addr"):
                        self.logger.error(
                            "Redirect scenario GPB message without "
                            "redirect IP address")
                        continue

                    addr_redir = gpb_scenario.redirect_ip_addr
                    if gpb_scenario.HasField("client_ip"):
                        client = "{}".format(gpb_scenario.client_ip)
                    else:
                        # default scenario
                        client = None
                    self.logger.debug(
                        "Adding redirect scenario: client: %s, "
                        "redir_ip: %s", client, addr_redir)
                    scenario.add_next_step(CCAPStep(
                        pkt_builder.get_redirect_packet,
                        param_tuple=([addr_redir], ),
                        description="Redirect to {}".format(addr_redir)),
                                           slave_id=client)

        # continue regardless to result of scenario processing
        if self.addr_family == socket.AF_INET:
            if gpb_params.HasField("IPv4Address"):
                core_addr = gpb_params.IPv4Address
            else:
                core_addr = '0.0.0.0'
            self.caps = CcapCoreIdentification(index=4,
                                               core_name="ServiceSuiteCCAPv4",
                                               core_ip_addr=core_addr)
        else:
            if gpb_params.HasField("IPv6Address"):
                core_addr = gpb_params.IPv6Address
            else:
                core_addr = '::'
            self.caps = CcapCoreIdentification(index=6,
                                               core_name="ServiceSuiteCCAPv6",
                                               core_ip_addr=core_addr)

        if not scenario:
            scenario = self._generate_default_scenario()

        self.descr = RCPMasterDescriptor(capabilities=self.caps,
                                         addr=core_addr,
                                         addr_family=self.addr_family,
                                         scenario=scenario)

        self.orchestrator.add_sessions([self.descr])

        try:
            session = \
                self.orchestrator.sessions_active[self.descr.get_uniq_id()]
            if not session.is_initiated():
                self.logger.error("CCAP core's RCP session is not initiated")
                return False
        except Exception as ex:
            self.logger.error("Failed to check CCAP core's RCP session: %s",
                              ex)
            return False

        return True
Ejemplo n.º 12
0
    def rcp_msg_cb(self, seq, args=None):
        """Send 'RpdCapabilities', 'CcapCoreIdentification' to manager.

        :param seq: data format t_RcpMessage defined in rcp.proto or
         rcp sequence
        :param args: RCP message arguments

        """
        status_changed = False
        specific = None
        core_msg_str = None
        if None is seq:
            self.logger.error("Parameters error, can not be NoneType")
            return
        elif isinstance(seq, t_RcpMessage):
            rcp_msg = seq
        else:
            rcp_msg = seq.ipc_msg
        self.logger.info("rcp_msg_cb: %s args, %s", str(rcp_msg), str(args))
        interface_local = ''
        if args:
            session, transaction_identifier, trans_id = args
            interface_local = session.get_descriptor().interface_local
        self.logger.info("RCP message type: %s",
                         rcp_msg.t_RcpMessageType.Name(rcp_msg.RcpMessageType))

        if rcp_msg.RcpMessageType == t_RcpMessage.RPD_REBOOT:
            self.logger.debug("Received RPD Reboot from RCP")
            core_ip = ''
            info = ''
            if rcp_msg.HasField('parameter'):
                core_para = json.loads(rcp_msg.parameter)
                core_ip = core_para['addr_remote'] if None is not core_para[
                    'addr_remote'] else ''
                interface_local = core_para[
                    'interface_local'] if None is not core_para[
                        'interface_local'] else ''
                info = core_para['info'] if None is not core_para[
                    'info'] else ''
            # FixMe, may need to send reboot msg to mgr
            for idx in self.mgrs:
                event_request_rsp = protoDef.msg_event_notification()
                event_request_rsp.mgr_event.mgr_id = idx
                event_request_rsp.mgr_event.event_id = self.id
                event_request_rsp.mgr_event.data = json.dumps("reboot/" +
                                                              interface_local +
                                                              ';' + core_ip +
                                                              ';' + info)
                self.mgrs[idx]['transport'].sock.send(
                    event_request_rsp.SerializeToString(), flags=zmq.NOBLOCK)
                self.logger.debug("Send event notification to id %s, msg:%s" %
                                  (idx, event_request_rsp))

        elif rcp_msg.RcpMessageType == t_RcpMessage.REDIRECT_NOTIFICATION:
            self.logger.debug("Received RPD Redirect message from RCP")
            #  need to send message to manager to handle this
            core_ip = ''
            if rcp_msg.HasField('parameter'):
                core_para = json.loads(rcp_msg.parameter)
                core_ip = core_para['addr_remote'] if None is not core_para[
                    'addr_remote'] else ''
                interface_local = core_para[
                    'interface_local'] if None is not core_para[
                        'interface_local'] else ''
            for idx in self.mgrs:
                event_request_rsp = protoDef.msg_event_notification()
                event_request_rsp.mgr_event.mgr_id = idx
                event_request_rsp.mgr_event.event_id = self.id
                event_request_rsp.mgr_event.data = json.dumps(
                    "redirect/" + ";".join([
                        Convert.format_ip(core)
                        for core in rcp_msg.RedirectCCAPAddresses
                    ]) + '/' + interface_local + ';' + core_ip)
                self.mgrs[idx]['transport'].sock.send(
                    event_request_rsp.SerializeToString(), flags=zmq.NOBLOCK)
                self.logger.debug("Send manager event to id %s, msg:%s" %
                                  (idx, event_request_rsp))

            # changed the status, then send to corresponding requester
            if interface_local != '' and core_ip != '':
                self.logger.info("The redirected core is: (%s, %s)",
                                 interface_local, core_ip)
                if (interface_local, core_ip) in self.rcp:
                    if self.rcp[(interface_local,
                                 core_ip)]['status'] != self.DOWN:
                        status_changed = True
                        specific = (interface_local, core_ip)
                        self.rcp[(interface_local,
                                  core_ip)]['status'] = self.DOWN

        elif rcp_msg.RcpMessageType == t_RcpMessage.RPD_CONFIGURATION:
            self.logger.debug(
                "Received RPD Ccap Core configuration message from RCP")
            cfg_data = rcp_msg.RpdDataMessage.RpdData
            if rcp_msg.HasField('parameter'):
                interface_local = rcp_msg.parameter

            for descr, value in cfg_data.ListFields():
                if descr.name == 'CcapCoreIdentification':
                    #  need to send message to manager to handle this
                    for cap_info in value:
                        coreIpAddress = "0.0.0.0"
                        identRecord = CcapCoreIdentification()
                        index = -1
                        is_principal = False
                        if cap_info.HasField("Index"):
                            index = cap_info.Index
                            identRecord.index = index
                            identRecord.read()
                            coreIpAddress = identRecord.core_ip_addr
                            is_principal = identRecord.is_principal
                            is_active = identRecord.is_active
                            if cap_info.HasField("CoreIpAddress"):
                                coreIpAddress = cap_info.CoreIpAddress
                            if cap_info.HasField("IsPrincipal"):
                                is_principal = cap_info.IsPrincipal
                            if cap_info.HasField("CoreMode"):
                                is_active = cap_info.CoreMode is t_CcapCoreIdentification.COREMODEACTIVE \
                                    if cap_info.HasField("CoreMode") else True
                            self.logger.debug(
                                "CcapCoreIdentification index =%d coreIpAddress is %s is_principal=%d is_active=%d",
                                index, coreIpAddress, is_principal, is_active)
                        else:
                            continue
                        caps = {
                            "index": index,
                            "is_active": is_active,
                            "ccap_core": Convert.format_ip(coreIpAddress),
                            "interface": interface_local,
                            "is_principal": is_principal
                        }
                        for idx in self.mgrs:
                            event_request_rsp = protoDef.msg_event_notification(
                            )
                            event_request_rsp.mgr_event.mgr_id = idx
                            event_request_rsp.mgr_event.event_id = self.id
                            event_request_rsp.mgr_event.data = json.dumps(
                                "role/" + json.dumps(caps))
                            self.mgrs[idx]['transport'].sock.send(
                                event_request_rsp.SerializeToString(),
                                flags=zmq.NOBLOCK)
                            self.logger.debug(
                                "Send event notification to id %s, msg:%s" %
                                (idx, event_request_rsp))

                        # changed the status, then send to corresponding requester, just for CLI test
                        for interface, core_ip in self.rcp:
                            if interface != interface_local or \
                                    not Convert.is_ip_address_equal(core_ip, coreIpAddress):
                                continue
                            ccap_core = self.rcp[(interface, core_ip)]
                            # send the Core Identification
                            for core_id in ccap_core['requester']:
                                info_update = protoDef.msg_event_notification()
                                info_update.agent_info_update.ccap_core_id = core_id

                                # The ugly code is caused by the proto file is different place
                                if cap_info.HasField("CoreId"):
                                    info_update.agent_info_update.ccap_core_identification.CoreId = cap_info.CoreId
                                if cap_info.HasField("CoreIpAddress"):
                                    info_update.agent_info_update.ccap_core_identification.CoreIpAddress = \
                                        Convert.format_ip(coreIpAddress)
                                if cap_info.HasField("IsPrincipal"):
                                    info_update.agent_info_update.ccap_core_identification.IsPrincipal = cap_info.IsPrincipal
                                if cap_info.HasField("CoreName"):
                                    info_update.agent_info_update.ccap_core_identification.CoreName = cap_info.CoreName
                                if cap_info.HasField("VendorId"):
                                    info_update.agent_info_update.ccap_core_identification.VendorId = cap_info.VendorId
                                if cap_info.HasField("CoreMode"):
                                    info_update.agent_info_update.ccap_core_identification.CoreMode = cap_info.CoreMode
                                if cap_info.HasField("CoreFunction"):
                                    info_update.agent_info_update.ccap_core_identification.CoreFunction = cap_info.CoreFunction
                                if cap_info.HasField(
                                        "InitialConfigurationComplete"):
                                    info_update.agent_info_update.ccap_core_identification.InitialConfigurationComplete = cap_info.InitialConfigurationComplete
                                    if cap_info.InitialConfigurationComplete:
                                        status_changed, specific = self.handle_init_conf_completed(
                                            args)
                                        core_msg_str = "GCP_CFG_CPL"
                                if cap_info.HasField("MoveToOperational"):
                                    if cap_info.MoveToOperational:
                                        self._send_event_notification(
                                            core_id, protoDef.
                                            msg_core_event_notification.OK,
                                            "Move to Operational",
                                            "OPERATIONAL")

                                if cap_info.HasField("ResourceSetIndex"):
                                    info_update.agent_info_update.ccap_core_identification.ResourceSetIndex = cap_info.ResourceSetIndex
                                if cap_info.HasField("Index"):
                                    info_update.agent_info_update.ccap_core_identification.Index = cap_info.Index

                                ccap_core_instance = self.ccap_cores[core_id]
                                transport = self.mgrs[
                                    ccap_core_instance["mgr"]]['transport']
                                transport.sock.send(
                                    info_update.SerializeToString(),
                                    flags=zmq.NOBLOCK)
                                self.logger.debug(
                                    "Send info to id %s, msg:%s" %
                                    (core_id, info_update))
                elif descr.name == 'RedundantCoreIpAddress':
                    for ha_info in value:
                        must_field = [
                            'ActiveCoreIpAddress', 'StandbyCoreIpAddress',
                            'Operation'
                        ]
                        ret_field = filter(
                            lambda field: ha_info.HasField(field), must_field)
                        if len(must_field) != len(ret_field):
                            self.logger.warn(
                                "Received RPD HA message {} without must fields"
                                .format(ha_info))
                            return
                        caps = {
                            "ActiveCoreIpAddress":
                            Convert.format_ip(ha_info.ActiveCoreIpAddress),
                            "StandbyCoreIpAddress":
                            Convert.format_ip(ha_info.StandbyCoreIpAddress),
                            'interface':
                            interface_local,
                            "operation":
                            ha_info.Operation
                        }
                        for idx in self.mgrs:
                            event_request_rsp = protoDef.msg_event_notification(
                            )
                            event_request_rsp.mgr_event.mgr_id = idx
                            event_request_rsp.mgr_event.event_id = self.id
                            event_request_rsp.mgr_event.data = json.dumps(
                                "Ha/" + json.dumps(caps))
                            self.mgrs[idx]['transport'].sock.send(
                                event_request_rsp.SerializeToString(),
                                flags=zmq.NOBLOCK)
                            self.logger.debug(
                                "Send event notification to id %s, msg:%s" %
                                (idx, event_request_rsp))
                        # update the capabilities
                        if ha_info.Operation == ManagerProcess.OPERATION_CHANGE:
                            for _, s in self.process.orchestrator.sessions_active.items(
                            ):
                                addr = s.get_descriptor().addr_remote
                                if addr == caps["ActiveCoreIpAddress"]:
                                    if (hasattr(s.ccap_identification,
                                                "is_active") and
                                            s.ccap_identification.is_active):
                                        active_session = s
                                        active_session.ccap_identification.is_active = False
                                        self.logger.info(
                                            "HA CHANGE: set session[%s] to standby"
                                            % caps["StandbyCoreIpAddress"])
                                elif addr == caps["StandbyCoreIpAddress"]:
                                    if (hasattr(s.ccap_identification,
                                                "is_active") and
                                            not s.ccap_identification.is_active
                                        ):
                                        standby_session = s
                                        standby_session.ccap_identification.is_active = True
                                        self.logger.info(
                                            "HA CHANGE: set session[%s] to active"
                                            % caps["StandbyCoreIpAddress"])

                        elif ha_info.Operation == ManagerProcess.OPERATION_ADD:
                            for _, s in self.process.orchestrator.sessions_active.items(
                            ):
                                addr = s.get_descriptor().addr_remote
                                if addr == caps["ActiveCoreIpAddress"]:
                                    if (hasattr(s.ccap_identification,
                                                "is_active") and
                                            not s.ccap_identification.is_active
                                        ):
                                        self.logger.warn(
                                            "HA ADD: session[%s] is not active now"
                                            % caps["ActiveCoreIpAddress"])
                                elif addr == caps["StandbyCoreIpAddress"]:
                                    if (hasattr(s.ccap_identification,
                                                "is_active") and
                                            s.ccap_identification.is_active):
                                        self.logger.warn(
                                            "HA ADD: session[%s] is not inactive now"
                                            % caps["StandbyCoreIpAddress"])

                elif descr.name == 'ConfiguredCoreTable':
                    for cfg_table in value:
                        must_field = ['ConfiguredCoreIp', 'Operation']
                        ret_field = filter(
                            lambda field: cfg_table.HasField(field),
                            must_field)
                        if len(must_field) != len(ret_field):
                            self.logger.warn(
                                "Received RPD ConfiguredCoreTable message {} without must fields"
                                .format(cfg_table))
                            return
                        caps = {
                            "ccap_core":
                            Convert.format_ip(cfg_table.ConfiguredCoreIp),
                            'interface':
                            interface_local,
                            "operation":
                            cfg_table.Operation
                        }
                        for idx in self.mgrs:
                            event_request_rsp = protoDef.msg_event_notification(
                            )
                            event_request_rsp.mgr_event.mgr_id = idx
                            event_request_rsp.mgr_event.event_id = self.id
                            event_request_rsp.mgr_event.data = json.dumps(
                                "config_table/" + json.dumps(caps))
                            self.mgrs[idx]['transport'].sock.send(
                                event_request_rsp.SerializeToString(),
                                flags=zmq.NOBLOCK)
                            self.logger.debug(
                                "Send event notification to id %s, msg:%s" %
                                (idx, event_request_rsp))
                elif descr.name == 'MultiCore':
                    self.logger.info(
                        "Received RPD MultiCore ConfiguredCoreTable message")
                    for configuredCoreTable in value.ConfiguredCoreTable:
                        caps = {
                            "ccap_core":
                            Convert.format_ip(
                                configuredCoreTable.ConfiguredCoreIp),
                            'interface':
                            interface_local,
                            "operation":
                            ManagerProcess.OPERATION_ADD
                        }
                        for idx in self.mgrs:
                            event_request_rsp = protoDef.msg_event_notification(
                            )
                            event_request_rsp.mgr_event.mgr_id = idx
                            event_request_rsp.mgr_event.event_id = self.id
                            event_request_rsp.mgr_event.data = json.dumps(
                                "config_table/" + json.dumps(caps))
                            self.mgrs[idx]['transport'].sock.send(
                                event_request_rsp.SerializeToString(),
                                flags=zmq.NOBLOCK)
                            self.logger.debug(
                                "Send event multi-core tlv notification to id %s, msg:%s"
                                % (idx, event_request_rsp))
                elif descr.name == "ActivePrincipalCore":
                    # record the request info
                    core_ip = ''
                    if None is not args:
                        descr = session.get_descriptor()
                        core_ip = Convert.format_ip(descr.addr_remote)
                        self.rcp_req_group[(seq.seq_number, core_ip)] = \
                            (seq, session, transaction_identifier, trans_id, time())
                    for idx in self.mgrs:
                        event_request_rsp = protoDef.msg_event_notification()
                        event_request_rsp.mgr_event.mgr_id = idx
                        event_request_rsp.mgr_event.event_id = self.id
                        event_request_rsp.mgr_event.data = json.dumps(
                            "get_active_principal/" + str(seq.seq_number) +
                            ',' + core_ip)
                        self.mgrs[idx]['transport'].sock.send(
                            event_request_rsp.SerializeToString(),
                            flags=zmq.NOBLOCK)
                        self.logger.debug(
                            "Send event notification to id %s, msg:%s" %
                            (idx, event_request_rsp))
                else:
                    self.logger.info("Recv {} message {}".format(
                        descr.name, value))
                    return

        elif rcp_msg.RcpMessageType == t_RcpMessage.RPD_CONFIGURATION_DONE:
            self.logger.debug("Got configuration done message...")
            # changed the status, then send to corresponding requester
            status_changed, specific = self.handle_init_conf_completed(args)
            core_msg_str = "GCP_CFG_CPL"

        elif rcp_msg.RcpMessageType == t_RcpMessage.CONNECT_CLOSE_NOTIFICATION:
            specific = self._get_specific_core_para(rcp_msg, args)
            core_msg_str = "TCP_FAIL"
            status_changed = True
            if specific:
                reconnect = False
                if specific in self.rcp:
                    if self.rcp[specific]['status'] != self.DOWN:
                        self.rcp[specific]['status'] = self.DOWN
                        # notify mgr about connection info, mgr will log this,
                        # and send notify message to CCAP Core finally.
                        # TODO remove these code later
                        for idx in self.mgrs:
                            event_request_rsp = protoDef.msg_event_notification(
                            )
                            event_request_rsp.mgr_event.mgr_id = idx
                            event_request_rsp.mgr_event.event_id = self.id
                            event_request_rsp.mgr_event.data = json.dumps(
                                "connect_closed/" + specific[0] + ";" +
                                specific[1] + ";" + str(reconnect))
                            self.mgrs[idx]['transport'].sock.send(
                                event_request_rsp.SerializeToString(),
                                flags=zmq.NOBLOCK)
                            self.logger.debug(
                                "Send event notification to id %s, msg:%s" %
                                (idx, event_request_rsp))
        elif rcp_msg.RcpMessageType == t_RcpMessage.SESSION_INITIATED:
            specific = self._get_specific_core_para(rcp_msg, args)
            core_msg_str = "TCP_OK"
            status_changed = True
        elif rcp_msg.RcpMessageType == t_RcpMessage.IRA_RECEIVED:
            specific = self._get_specific_core_para(rcp_msg, args)
            core_msg_str = "GCP_IRA"
            status_changed = True
        elif rcp_msg.RcpMessageType == t_RcpMessage.REX_RECEIVED:
            specific = self._get_specific_core_para(rcp_msg, args)
            core_msg_str = "GCP_CFG"
            status_changed = True
        else:
            self.logger.error(
                "Unexpected IPC message received from "
                "RCP: type: %s(%u)",
                rcp_msg.t_RcpMessageType.Name(rcp_msg.RcpMessageType),
                rcp_msg.RcpMessageType)
            return

        # send the status change to the requester
        if not status_changed:
            return

        popup_list = list()
        if None is not specific and specific in self.rcp:
            self.rcp[specific]['lastChangeTime'] = time()
            for id in self.rcp[specific]["requester"]:
                if id not in self.ccap_cores:
                    popup_list.append(id)
                    continue
                event_request_rsp = protoDef.msg_event_notification()
                event_request_rsp.core_event.id = id
                event_request_rsp.core_event.ccap_core_id = id
                event_request_rsp.core_event.status = protoDef.msg_core_event_notification.OK
                event_request_rsp.core_event.reason = "Status changed"
                event_request_rsp.core_event.event_id = self.id
                event_request_rsp.core_event.result = core_msg_str if core_msg_str else self.rcp[
                    specific]['status']
                ccap_core = self.ccap_cores[id]
                transport = self.mgrs[ccap_core["mgr"]]['transport']
                transport.sock.send(event_request_rsp.SerializeToString(),
                                    flags=zmq.NOBLOCK)
                self.logger.info("Send status change to id %s, msg:%s" %
                                 (id, event_request_rsp))
            for idx in popup_list:
                self.rcp[specific]['requester'].remove(idx)
Ejemplo n.º 13
0
    def handle_msg_eds_req(self, msg, slave, pkt):
        """Handles GCP EDS REQ message.

        :param msg: The GCP EDS REQ message
        :type msg: Message
        :param slave: The RCP slave sessions on which the message has been
         received.
        :type slave: RCPSlaveSession
        :param pkt: The RCP packet where the message was encapsulated
        :type pkt: RCPPacket
        :return:

        """
        seq_list = []
        for rcp_msg in msg.tlv_data.rcp_msgs:
            for seq in rcp_msg.sequences:

                # Handle special messages including redirect
                # and CCAP Capabilities and ssd
                if rcp_msg.rcp_message_id == rcp_tlv_def.RCP_MSG_TYPE_IRA:
                    if slave.is_ira_recv == False:
                        slave.is_ira_recv = True
                        self.callback_set.configuration_to_rcp_wrapper(
                            slave,
                            seq,
                            pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val(),
                            msg_type=t_RcpMessage.IRA_RECEIVED)
                if rcp_msg.rcp_message_id == rcp_tlv_def.RCP_MSG_TYPE_REX:
                    if slave.is_rex_recv == False:
                        slave.is_rex_recv = True
                        self.callback_set.configuration_to_rcp_wrapper(
                            slave,
                            seq,
                            pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val(),
                            msg_type=t_RcpMessage.REX_RECEIVED)
                if seq.parent_gpb.HasField("Ssd"):
                    self.logger.info("Handling Ssd received at %s" %
                                     slave.get_descriptor())
                    if (not slave.ccap_identification.is_active) \
                            or (not slave.ccap_identification.is_principal):
                        self.logger.debug(
                            "Ssd received from non active %d or non principal %d ",
                            slave.ccap_identification.is_active,
                            slave.ccap_identification.is_principal)
                        try:
                            resp = self.pkt_director.get_positive_rsp_packets(
                                slave, pkt)
                        except Exception as ex:
                            self.logger.warning(
                                "Got exception when constructing ssd rsp packet: %s",
                                str(ex))
                            raise
                        if 1 != len(resp):
                            raise RCPMSGHandlingError(
                                "Invalid packet response returned by director")
                        resp = resp[0]
                        try:
                            slave.io_ctx.add_tx_packet(resp)
                            self.logger.debug("send ssd response")
                        except GCPSessionFull:
                            self.logger.error(
                                "GCP session tx full, failed to send SSD response msg"
                            )
                            raise
                        continue

                if len(seq.parent_gpb.RpdRedirect) > 0:
                    self.logger.info("Handling redirect received at %s" %
                                     slave.get_descriptor())
                    # handle redirect and drop all next data
                    addr_list = []
                    for redir_item in seq.parent_gpb.RpdRedirect:
                        ip_addr = redir_item.RedirectIpAddress
                        addr_family = (socket.AF_INET if
                                       Convert.is_valid_ipv4_address(ip_addr)
                                       else socket.AF_INET6)
                        addr_list.append((ip_addr, addr_family))

                    # send redirect response
                    try:
                        resp = self.pkt_director.get_positive_rsp_packets(
                            slave, pkt)
                    except Exception as ex:
                        self.logger.warning(
                            "Got exception when constructing  redirect rsp packet: %s",
                            str(ex))
                        raise

                    if 1 != len(resp):
                        raise RCPMSGHandlingError(
                            "Invalid packet response returned by director")
                    resp = resp[0]

                    try:
                        slave.io_ctx.add_tx_packet(resp)
                    except GCPSessionFull:
                        self.logger.error(
                            "GCP session tx full, failed to send redirect response msg"
                        )
                        raise

                    slave.dispatcher.fd_modify(slave.get_socket_fd(),
                                               slave.dispatcher.MASK_WR_ERR)
                    self.logger.debug("Response to redirect added to TX queue")
                    try:
                        self.callback_set.redirect_received(slave, addr_list)
                    except Exception as ex:
                        self.logger.warning(
                            "Got exception when handling redirect msg: %s",
                            str(ex))
                        raise
                    continue

                if len(seq.parent_gpb.CcapCoreIdentification) > 0:
                    index = -1
                    identRecord = CcapCoreIdentification()
                    self.logger.info("Handling CcapCoreIdentification update")
                    ccap_caps = seq.parent_gpb.CcapCoreIdentification[0]
                    self.logger.debug("msg is: %s", ccap_caps)
                    op = seq.operation
                    if len(seq.parent_gpb.CcapCoreIdentification) > 1:
                        self.logger.warning(
                            "Only one instance of CCAP caps is expected, but received: %u",
                            len(seq.parent_gpb.CcapCoreIdentification))

                    core_ip = slave.get_descriptor().addr_remote

                    if ccap_caps.HasField("CoreIpAddress"):
                        core_ip = Convert.format_ip(ccap_caps.CoreIpAddress)
                        ip = Convert.format_ip(ccap_caps.CoreIpAddress)

                    if op == rcp_tlv_def.RCP_OPERATION_TYPE_WRITE:
                        if ccap_caps.HasField("Index"):
                            index = ccap_caps.Index
                            identRecord.index = index
                            identRecord.read()
                        else:
                            self.logger.warning(
                                "RCP write type %d should include index", op)
                            self.pkt_director.send_eds_response_directly(
                                slave, pkt.transaction_identifier,
                                msg.msg_fields.TransactionID.get_val(), seq,
                                False)
                            continue
                    elif op == rcp_tlv_def.RCP_OPERATION_TYPE_ALLOCATE_WRITE:
                        identRecord.allocateIndex(core_ip)
                        ccap_caps.Index = identRecord.index
                    elif op == rcp_tlv_def.RCP_OPERATION_TYPE_READ:
                        seq_list.append(seq)
                        continue

                    identRecord.core_ip_addr = core_ip
                    if ccap_caps.HasField("IsPrincipal"):
                        self.logger.info(
                            "Received NotifyRSP from CCAP core is_principal[%s]",
                            ccap_caps.IsPrincipal)
                        identRecord.is_principal = True if ccap_caps.IsPrincipal else False

                    self.logger.debug(
                        "CcapCoreIdentification operation=%d index=%d", op,
                        ccap_caps.Index)

                    if ccap_caps.HasField("CoreId"):
                        identRecord.core_id = ccap_caps.CoreId

                    if ccap_caps.HasField("CoreName"):
                        identRecord.core_name = ccap_caps.CoreName

                    if ccap_caps.HasField("VendorId"):
                        identRecord.vendor_id = ccap_caps.VendorId

                    if ccap_caps.HasField("CoreMode"):
                        identRecord.core_mode = ccap_caps.CoreMode
                        identRecord.is_active = ccap_caps.CoreMode is t_CcapCoreIdentification.COREMODEACTIVE

                    if ccap_caps.HasField("InitialConfigurationComplete"):
                        identRecord.initial_configuration_complete = ccap_caps.InitialConfigurationComplete

                    if ccap_caps.HasField("MoveToOperational"):
                        identRecord.move_to_operational = ccap_caps.MoveToOperational

                    if ccap_caps.HasField("CoreFunction"):
                        identRecord.core_function = ccap_caps.CoreFunction

                    if ccap_caps.HasField("ResourceSetIndex"):
                        identRecord.resource_set_index = ccap_caps.ResourceSetIndex

                    if op in [
                            rcp_tlv_def.RCP_OPERATION_TYPE_WRITE,
                            rcp_tlv_def.RCP_OPERATION_TYPE_ALLOCATE_WRITE
                    ]:
                        identRecord.write()
                        self.logger.debug(
                            "Core ident DB save index =%d core_ip_addr=%s op=%d",
                            identRecord.index, identRecord.core_ip_addr, op)
                    # Set the ccap core Identification into the slave session
                    slave.ccap_identification = identRecord

                    # call CCAP caps update callback
                    self.callback_set.ccap_identification_update(slave)

                    try:
                        self.callback_set.configuration_to_rcp_wrapper(
                            slave, seq, pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val())
                    except Exception as ex:
                        self.logger.warning(
                            "Got exception when handling core identification msg: %s",
                            str(ex))
                        raise

                if seq.parent_gpb.HasField('RpdConfigurationDone'):
                    self.logger.info(
                        "Handling configuration done message to MGR")
                    self.pkt_director.send_eds_response_directly(
                        slave, pkt.transaction_identifier,
                        msg.msg_fields.TransactionID.get_val(), seq)
                    try:
                        self.callback_set.configuration_to_rcp_wrapper(
                            slave,
                            seq,
                            pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val(),
                            msg_type=t_RcpMessage.RPD_CONFIGURATION_DONE)
                    except Exception as ex:
                        self.logger.warning(
                            "Got exception when handling cfg_done msg: %s",
                            str(ex))
                        raise

                    continue

                if seq.parent_gpb.HasField('RpdGlobal'):
                    if slave.ccap_identification.is_principal and slave.ccap_identification.is_active:
                        self.logger.info(
                            "Receive RpdGlobal message from active principal core via session %s",
                            slave.get_descriptor())
                    else:
                        self.logger.info(
                            "Receive RpdGlobal message from non active principal core via session %s",
                            slave.get_descriptor())
                        self.pkt_director.send_eds_response_directly(
                            slave, pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val(), seq)
                        continue

                if len(seq.parent_gpb.ConfiguredCoreTable) > 0:
                    self.logger.info(
                        "Handling configuration core table message to MGR")
                    self.pkt_director.send_eds_response_directly(
                        slave, pkt.transaction_identifier,
                        msg.msg_fields.TransactionID.get_val(), seq)
                    try:
                        self.callback_set.configuration_to_rcp_wrapper(
                            slave, seq, pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val())
                    except Exception as ex:
                        self.logger.warning(
                            "Got exception when handling core_table msg: %s",
                            str(ex))
                        raise

                    continue

                if seq.parent_gpb.HasField('MultiCore'):
                    self.logger.info(
                        "Handling MultiCore configuration msg is_principal=%d is_active=%d",
                        slave.ccap_identification.is_principal,
                        slave.ccap_identification.is_active)
                    #                   ****** temporary 4 line hack follows to work around
                    #                   ****** the issue described in C3RPHY-122
                    resource_set_index = 0
                    for resource_set in seq.parent_gpb.MulitCore.ResourceSet:
                        resource_set.ResourceSetIndex = resource_set_index
                        resource_set_index = resource_set_index + 1


#                   ****** end of 4 line hack to get around C3RPHY-122
                    self.pkt_director.send_eds_response_directly(
                        slave, pkt.transaction_identifier,
                        msg.msg_fields.TransactionID.get_val(), seq)
                    try:
                        self.callback_set.configuration_to_rcp_wrapper(
                            slave, seq, pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val())
                    except Exception as ex:
                        self.logger.warning(
                            "Got exception when handling  MultiCore msg: %s",
                            str(ex))
                        raise

                    continue

                if seq.parent_gpb.HasField('ActivePrincipalCore'):
                    self.logger.info(
                        "Handling get active principal request on session %s",
                        slave.get_descriptor())
                    try:
                        self.callback_set.configuration_to_rcp_wrapper(
                            slave, seq, pkt.transaction_identifier,
                            msg.msg_fields.TransactionID.get_val())
                    except Exception as ex:
                        self.logger.warning(
                            "Got exception when handling Active Principal core msg: %s",
                            str(ex))
                        raise

                    continue
                seq_list.append(seq)

        if not seq_list:
            self.logger.info("EDS message without any RCPSequence received")
            return

        try:
            self.callback_set.configuration_operation(
                session=slave,
                rcp_sequence_list=seq_list,
                pkt_req=pkt,
                gcp_msg=msg)
        except Exception as ex:
            # TODO we need to handle failures with a granularity
            self.logger.error("Failed to process configuration: %s", ex)
            import traceback
            self.logger.error(traceback.format_stack())
            raise RCPMSGHandlingError()