Generate the XML string to define a libvirt storage pool

def _gen_pool_xml(name,
                  ptype,
                  target=None,
                  permissions=None,
                  source_devices=None,
                  source_dir=None,
                  source_adapter=None,
                  source_hosts=None,
                  source_auth=None,
                  source_name=None,
                  source_format=None):
    '''
    Generate the XML string to define a libvirt storage pool
    '''
    hosts = [host.split(':') for host in source_hosts or []]
    context = {
        'name': name,
        'ptype': ptype,
        'target': {'path': target, 'permissions': permissions},
        'source': {
            'devices': source_devices or [],
            'dir': source_dir,
            'adapter': source_adapter,
            'hosts': [{'name': host[0], 'port': host[1] if len(host) > 1 else None} for host in hosts],
            'auth': source_auth,
            'name': source_name,
            'format': source_format
        }
    }
    fn_ = 'libvirt_pool.jinja'
    try:
        template = JINJA.get_template(fn_)
    except jinja2.exceptions.TemplateNotFound:
        log.error('Could not load template %s', fn_)
        return ''
    return template.render(**context)