def _agent_registration(self):
for attempts in range(MAX_REGISTRATION_ATTEMPTS):<EOL><INDENT>context = bc.context.get_admin_context_without_session()<EOL>self.send_agent_report(self.agent_state, context)<EOL>try:<EOL><INDENT>res = self.devmgr_rpc.register_for_duty(context)<EOL><DEDENT>except Exception:<EOL><INDENT>res = False<EOL>LOG.warning("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", REGISTRATION_RETRY_DELAY)<EOL><DEDENT>if res is True:<EOL><INDENT>LOG.info("<STR_LIT>")<EOL>return<EOL><DEDENT>elif res is False:<EOL><INDENT>LOG.warning("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", REGISTRATION_RETRY_DELAY)<EOL>time.sleep(REGISTRATION_RETRY_DELAY)<EOL><DEDENT>elif res is None:<EOL><INDENT>LOG.error("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise SystemExit(_("<STR_LIT>"))<EOL><DEDENT><DEDENT>LOG.error("<STR_LIT>"<EOL>"<STR_LIT>", MAX_REGISTRATION_ATTEMPTS)<EOL>raise SystemExit(_("<STR_LIT>"))<EOL>
Register this agent with the server.

        This method registers the cfg agent with the neutron server so hosting
        devices can be assigned to it. In case the server is not ready to
        accept registration (it sends a False) then we retry registration
        for `MAX_REGISTRATION_ATTEMPTS` with a delay of
        `REGISTRATION_RETRY_DELAY`. If there is no server response or a
        failure to register after the required number of attempts,
        the agent stops itself.