'Return a dict composed by the name of services and ids of shares
dependent of this Volume
This is mainly used by the VolumeDelete form.
Responsible for telling the user whether there is a related
share, asking for confirmation'

def has_attachments(self):

    from freenasUI.jails.models import Jails, JailsConfiguration
    from freenasUI.sharing.models import CIFS_Share, AFP_Share, NFS_Share_Path
    from freenasUI.services.models import iSCSITargetExtent
    attachments = {'cifs': [], 'afp': [], 'nfs': [], 'iscsitarget': [], 'jails': [], 'collectd': []}
    for cifs in CIFS_Share.objects.filter((Q(cifs_path=self.vol_path) | Q(cifs_path__startswith=(self.vol_path + '/')))):
        attachments['cifs'].append(cifs.id)
    for afp in AFP_Share.objects.filter((Q(afp_path=self.vol_path) | Q(afp_path__startswith=(self.vol_path + '/')))):
        attachments['afp'].append(afp.id)
    for nfsp in NFS_Share_Path.objects.filter((Q(path=self.vol_path) | Q(path__startswith=(self.vol_path + '/')))):
        if (nfsp.share.id not in attachments['nfs']):
            attachments['nfs'].append(nfsp.share.id)
    zvols = notifier().list_zfs_vols(self.vol_name)
    for zvol in zvols:
        qs = iSCSITargetExtent.objects.filter(iscsi_target_extent_path=('zvol/' + zvol), iscsi_target_extent_type='ZVOL')
        if qs.exists():
            attachments['iscsitarget'].append(qs[0].id)
    try:
        jc = JailsConfiguration.objects.latest('id')
    except:
        jc = None
    if (jc and jc.jc_path.startswith(self.vol_path)):
        attachments['jails'].extend([j.id for j in Jails.objects.all()])
    return attachments
