def unassign_hosting_device_from_cfg_agent(self, context, cfg_agent_id,
                                               hosting_device_id):
        """Make config agent handle an (unassigned) hosting device."""
        hd_db = self._get_hosting_device(context, hosting_device_id)
        if hd_db.cfg_agent_id is None and cfg_agent_id is None:
            return
        elif hd_db.cfg_agent_id != cfg_agent_id:
            LOG.debug('Hosting device %(hd_id)s is not assigned to Cisco '
                      'cfg agent %(agent_id)s',
                      {'hd_id': hosting_device_id,
                       'agent_id': cfg_agent_id})
            raise ciscocfgagentscheduler.HostingDeviceNotAssignedToCfgAgent(
                hosting_device_id=hosting_device_id, agent_id=cfg_agent_id)
        cfg_agent_db = get_agent_db_obj(self._get_agent(context, cfg_agent_id))
        cfg_notifier = self.agent_notifiers.get(c_constants.AGENT_TYPE_CFG)
        if cfg_notifier:
            cfg_notifier.hosting_devices_unassigned_from_cfg_agent(
                context, [hosting_device_id], cfg_agent_db.host)
        self._bind_hosting_device_to_cfg_agent(context, hd_db, None)
def unassign_hosting_device_from_cfg_agent ( self , context , cfg_agent_id , hosting_device_id ) : hd_db = self . _get_hosting_device ( context , hosting_device_id ) if hd_db . cfg_agent_id is None and cfg_agent_id is None : return elif hd_db . cfg_agent_id != cfg_agent_id : LOG . debug ( 'Hosting device %(hd_id)s is not assigned to Cisco ' 'cfg agent %(agent_id)s' , { 'hd_id' : hosting_device_id , 'agent_id' : cfg_agent_id } ) raise ciscocfgagentscheduler . HostingDeviceNotAssignedToCfgAgent ( hosting_device_id = hosting_device_id , agent_id = cfg_agent_id ) cfg_agent_db = get_agent_db_obj ( self . _get_agent ( context , cfg_agent_id ) ) cfg_notifier = self . agent_notifiers . get ( c_constants . AGENT_TYPE_CFG ) if cfg_notifier : cfg_notifier . hosting_devices_unassigned_from_cfg_agent ( context , [ hosting_device_id ] , cfg_agent_db . host ) self . _bind_hosting_device_to_cfg_agent ( context , hd_db , None )
Make config agent handle an (unassigned) hosting device.