'Get flexvol attributes needed for the storage service catalog.'

def get_flexvol(self, flexvol_path=None, flexvol_name=None):

    volume_id_attributes = {'type': 'rw', 'style': 'flex'}
    if flexvol_path:
        volume_id_attributes['junction-path'] = flexvol_path
    if flexvol_name:
        volume_id_attributes['name'] = flexvol_name
    api_args = {'query': {'volume-attributes': {'volume-id-attributes': volume_id_attributes, 'volume-state-attributes': {'is-vserver-root': 'false', 'is-inconsistent': 'false', 'is-invalid': 'false', 'state': 'online'}}}, 'desired-attributes': {'volume-attributes': {'volume-id-attributes': {'name': None, 'owning-vserver-name': None, 'junction-path': None, 'containing-aggregate-name': None, 'type': None}, 'volume-mirror-attributes': {'is-data-protection-mirror': None, 'is-replica-volume': None}, 'volume-space-attributes': {'is-space-guarantee-enabled': None, 'space-guarantee': None, 'percentage-snapshot-reserve': None, 'size': None}, 'volume-qos-attributes': {'policy-group-name': None}, 'volume-snapshot-attributes': {'snapshot-policy': None}, 'volume-language-attributes': {'language-code': None}}}}
    result = self.send_iter_request('volume-get-iter', api_args)
    if (self._get_record_count(result) != 1):
        msg = _('Could    not    find    unique    volume    %(vol)s.')
        msg_args = {'vol': flexvol_name}
        raise exception.VolumeBackendAPIException(data=(msg % msg_args))
    attributes_list = (result.get_child_by_name('attributes-list') or netapp_api.NaElement('none'))
    volume_attributes = (attributes_list.get_child_by_name('volume-attributes') or netapp_api.NaElement('none'))
    volume_id_attributes = (volume_attributes.get_child_by_name('volume-id-attributes') or netapp_api.NaElement('none'))
    volume_space_attributes = (volume_attributes.get_child_by_name('volume-space-attributes') or netapp_api.NaElement('none'))
    volume_qos_attributes = (volume_attributes.get_child_by_name('volume-qos-attributes') or netapp_api.NaElement('none'))
    volume_snapshot_attributes = (volume_attributes.get_child_by_name('volume-snapshot-attributes') or netapp_api.NaElement('none'))
    volume_language_attributes = (volume_attributes.get_child_by_name('volume-language-attributes') or netapp_api.NaElement('none'))
    volume = {'name': volume_id_attributes.get_child_content('name'), 'vserver': volume_id_attributes.get_child_content('owning-vserver-name'), 'junction-path': volume_id_attributes.get_child_content('junction-path'), 'aggregate': volume_id_attributes.get_child_content('containing-aggregate-name'), 'type': volume_id_attributes.get_child_content('type'), 'space-guarantee-enabled': strutils.bool_from_string(volume_space_attributes.get_child_content('is-space-guarantee-enabled')), 'space-guarantee': volume_space_attributes.get_child_content('space-guarantee'), 'percentage-snapshot-reserve': volume_space_attributes.get_child_content('percentage-snapshot-reserve'), 'size': volume_space_attributes.get_child_content('size'), 'qos-policy-group': volume_qos_attributes.get_child_content('policy-group-name'), 'snapshot-policy': volume_snapshot_attributes.get_child_content('snapshot-policy'), 'language': volume_language_attributes.get_child_content('language-code')}
    return volume
