Beispiel #1
0
 def _toggle_visibility(self, share, snap_name, on=True):
     for se in NFSExport.objects.filter(share=share):
         snap_realname = ('%s_%s' % (share.name, snap_name))
         mnt_pt = ('%s%s/%s' % (settings.MNT_PT, share.pool.name,
                                snap_realname))
         export_pt = mnt_pt.replace(settings.MNT_PT,
                                    settings.NFS_EXPORT_ROOT)
         export = None
         if (on):
             if (not NFSExport.objects.filter(share=share, nohide=False)):
                 #master share is not exported, so don't export the snap
                 continue
             export = NFSExport(share=share, mount=export_pt,
                                host_str=se.host_str, nohide=True)
             export.full_clean()
             export.save()
         else:
             try:
                 export = NFSExport.objects.get(share=share,
                                                host_str=se.host_str,
                                                mount=export_pt,
                                                nohide=True)
                 export.enabled = False
             except Exception, e:
                 logger.exception(e)
                 continue
         exports = create_nfs_export_input(export)
         refresh_nfs_exports(exports)
         if (not on):
             export.delete()