'Prepares an agent and adds it to the DB using
`self._add_agent()`'

def add_agent(self, masterid, host, remotepath, rsync=None, source=None, maxwaiting=60):

    if (rsync is None):
        rsync = ['rsync']
    if (not remotepath.endswith('/')):
        remotepath += '/'
    if (source is None):
        source = (remotepath if (host is None) else ('%s:%s' % (host, remotepath)))
    master = self.get_master(masterid)
    localpath = tempfile.mkdtemp(prefix='', dir=master['path'])
    for dirname in (['input'] + [os.path.join('remote', dname) for dname in ['input', 'cur', 'output']]):
        utils.makedirs(os.path.join(localpath, dirname))
    agent = {'host': host, 'path': {'remote': remotepath, 'local': localpath}, 'source': source, 'rsync': rsync, 'maxwaiting': maxwaiting, 'scan': None, 'sync': True, 'master': masterid}
    return self._add_agent(agent)
