'Find location string for allocation. Also delete alloc per reqst'

def _alloc_location(self, volume, hostname, delete=0):

    location = ''
    url = ('/storage/arrays/%s/allocations' % self._get_ise_globalid())
    resp = self._send_cmd('GET', url, {'name': volume['name'], 'hostname': hostname})
    if (resp['status'] != 200):
        LOG.error('Could    not    GET    allocation    information    (%d)!', resp['status'])
        RaiseXIODriverException()
    allocation_tree = etree.fromstring(resp['content'])
    for allocation in allocation_tree.iter():
        if (allocation.tag != 'allocation'):
            continue
        volume_tag = allocation.find('volume')
        if (volume_tag is None):
            continue
        volumename_tag = volume_tag.find('volumename')
        if (volumename_tag is None):
            continue
        volumename = volumename_tag.text
        if (volumename != volume['name']):
            continue
        endpoints = allocation.find('endpoints')
        if (endpoints is None):
            continue
        for endpoint in endpoints.iter():
            if (hostname != ''):
                hname_tag = endpoint.find('hostname')
                if (hname_tag is None):
                    continue
                if (hname_tag.text.upper() != hostname.upper()):
                    continue
            location = allocation.attrib['self']
            if (delete == 1):
                self._send_cmd('DELETE', location)
                location = ''
                break
            else:
                return location
    return location
