'Create lun.'

@_connection_checker
def create_lun(self, volume, pool_name, create_lun_name, reserve):

    lun_thin_allocate = ''
    if reserve:
        lun_thin_allocate = '1'
    else:
        lun_thin_allocate = '0'
    res_details = self._get_res_details('/cgi-bin/disk/iscsi_lun_setting.cgi?', func='add_lun', FileIO='no', LUNThinAllocate=lun_thin_allocate, LUNName=create_lun_name, LUNPath=create_lun_name, poolID=pool_name, lv_ifssd='no', LUNCapacity=volume['size'], lv_threshold='80', sid=self.sid)
    root = ET.fromstring(res_details['data'])
    if (root.find('authPassed').text == '0'):
        raise exception.VolumeBackendAPIException(data=_('Session    id    expired'))
    if (root.find('result').text < '0'):
        raise exception.VolumeBackendAPIException(data=(_('Create    volume    %s    failed') % volume['display_name']))
    return root.find('result').text
