def set_driver(self, resource):
try:<EOL><INDENT>resource_id = resource['<STR_LIT:id>']<EOL>hosting_device = resource['<STR_LIT>']<EOL>hd_id = hosting_device['<STR_LIT:id>']<EOL>if hd_id in self._hosting_device_routing_drivers_binding:<EOL><INDENT>driver = self._hosting_device_routing_drivers_binding[hd_id]<EOL>self._drivers[resource_id] = driver<EOL><DEDENT>else:<EOL><INDENT>driver_class = resource['<STR_LIT>']['<STR_LIT>']<EOL>obfusc_creds = dict(hosting_device.get('<STR_LIT>'))<EOL>if obfusc_creds:<EOL><INDENT>real_pw = self._cfg_agent.get_hosting_device_password(<EOL>obfusc_creds.get('<STR_LIT>'))<EOL>hosting_device['<STR_LIT>']['<STR_LIT:password>'] = real_pw<EOL><DEDENT>driver = importutils.import_object(driver_class,<EOL>**hosting_device)<EOL>self._hosting_device_routing_drivers_binding[hd_id] = driver<EOL>if obfusc_creds:<EOL><INDENT>hosting_device['<STR_LIT>'] = obfusc_creds<EOL><DEDENT>self._drivers[resource_id] = driver<EOL><DEDENT>return driver<EOL><DEDENT>except ImportError:<EOL><INDENT>with excutils.save_and_reraise_exception(reraise=False):<EOL><INDENT>LOG.exception("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>{'<STR_LIT>': driver_class, '<STR_LIT>': hd_id,<EOL>'<STR_LIT>': resource['<STR_LIT:name>']})<EOL>raise cfg_exceptions.DriverNotExist(driver=driver_class)<EOL><DEDENT><DEDENT>except KeyError as e:<EOL><INDENT>with excutils.save_and_reraise_exception(reraise=False):<EOL><INDENT>raise cfg_exceptions.DriverNotSetForMissingParameter(e)<EOL><DEDENT><DEDENT>
Set the driver for a neutron resource.

        :param resource: Neutron resource in dict format.
            Expected keys::

                {
                    'id': <value>,
                    'hosting_device': { 'id': <value>, },
                    'router_type': {'cfg_agent_driver': <value>,  }
                }

        :returns: driver object