Пример #1
0
class NFS_Share(Model):
    nfs_comment = models.CharField(
        max_length=120,
        verbose_name=_("Comment"),
        blank=True,
    )
    nfs_network = models.TextField(
        verbose_name=_("Authorized networks"),
        help_text=_(
            "Networks that are authorized to access the NFS share."
            " Specify network numbers of the form 1.2.3.4/xx where xx is "
            "the number of bits of netmask."),
        blank=True,
    )
    nfs_hosts = models.TextField(
        verbose_name=_("Authorized IP addresses or hosts"),
        help_text=_("IP addresses or hostnames that are authorized to "
                    "access the NFS share."),
        blank=True,
    )
    nfs_alldirs = models.BooleanField(
        verbose_name=_('All Directories'),
        help_text=_(
            'Allow mounting of any subdirectory under this mount point if'
            'selected. Otherwise, only the top level directory can be mounted.'
        ),
        default=False,
    )
    nfs_ro = models.BooleanField(
        verbose_name=_('Read Only'),
        help_text=_('Export the share read only. Writes are not permitted.'),
        default=False,
    )
    nfs_quiet = models.BooleanField(
        verbose_name=_('Quiet'),
        help_text=_(
            'Inhibit syslog warnings if there are problems with exporting '
            'this share.'),
        default=False,
    )
    nfs_maproot_user = UserField(
        verbose_name=_("Maproot User"),
        max_length=120,
        blank=True,
        null=True,
        default='',
        help_text=_("If a user is selected, the root user is limited to "
                    "that user's permissions"),
    )
    nfs_maproot_group = GroupField(
        verbose_name=_("Maproot Group"),
        max_length=120,
        blank=True,
        null=True,
        default='',
        help_text=_("If a group is selected, the root user will also be "
                    "limited to that group's permissions"),
    )
    nfs_mapall_user = UserField(
        verbose_name=_("Mapall User"),
        max_length=120,
        blank=True,
        null=True,
        default='',
        help_text=_(
            "The specified user's permissions are used by all clients"),
    )
    nfs_mapall_group = GroupField(
        verbose_name=_("Mapall Group"),
        max_length=120,
        blank=True,
        null=True,
        default='',
        help_text=_(
            "The specified group's permission are used by all clients"),
    )
    nfs_security = MultiSelectField(
        verbose_name=_('Security'),
        max_length=200,
        blank=True,
        choices=(
            ('sys', 'sys'),
            ('krb5', 'krb5'),
            ('krb5i', 'krb5i'),
            ('krb5p', 'krb5p'),
        ),
    )

    def __unicode__(self):
        if self.nfs_comment:
            return unicode(self.nfs_comment)
        return u"[%s]" % ', '.join([p.path for p in self.paths.all()])

    def delete(self, *args, **kwargs):
        super(NFS_Share, self).delete(*args, **kwargs)
        notifier().reload("nfs")

    @property
    def nfs_paths(self):
        return [p.path for p in self.paths.all()]

    class Meta:
        verbose_name = _("Unix (NFS) Share")
        verbose_name_plural = _("Unix (NFS) Shares")
Пример #2
0
class CIFS_Share(Model):
    cifs_path = PathField(
        verbose_name=_("Path"),
        blank=True,
    )
    cifs_home = models.BooleanField(
        verbose_name=_('Use as home share'),
        default=False,
    )
    cifs_name = models.CharField(max_length=120, verbose_name=_("Name"))
    cifs_comment = models.CharField(
        max_length=120,
        verbose_name=_("Comment"),
        blank=True,
    )
    cifs_default_permissions = models.BooleanField(
        verbose_name=_('Apply Default Permissions'),
        help_text=_(
            'Recursively set sane default windows permissions on share'),
        default=True)
    cifs_ro = models.BooleanField(
        verbose_name=_('Export Read Only'),
        default=False,
    )
    cifs_browsable = models.BooleanField(
        verbose_name=_('Browsable to Network Clients'),
        default=True,
    )
    cifs_recyclebin = models.BooleanField(
        verbose_name=_('Export Recycle Bin'),
        default=False,
    )
    cifs_showhiddenfiles = models.BooleanField(
        verbose_name=_('Show Hidden Files'),
        default=False,
    )
    cifs_guestok = models.BooleanField(
        verbose_name=_('Allow Guest Access'),
        help_text=_(
            'If true then no password is required to connect to the share. '
            'Privileges will be those of the guest account.'),
        default=False,
    )
    cifs_guestonly = models.BooleanField(
        verbose_name=_('Only Allow Guest Access'),
        help_text=_(
            'If true then only guest connections to the share are permitted. '
            'This parameter will have no effect if Allow Guest Access is not '
            'set for the share.'),
        default=False,
    )
    cifs_hostsallow = models.TextField(
        blank=True,
        verbose_name=_("Hosts Allow"),
        help_text=_(
            "This option is a comma, space, or tab delimited set of hosts "
            "which are permitted to access this share. You can specify the "
            "hosts by name or IP number. Leave this field empty to use "
            "default settings."),
    )
    cifs_hostsdeny = models.TextField(
        blank=True,
        verbose_name=_("Hosts Deny"),
        help_text=_(
            "This option is a comma, space, or tab delimited set of host "
            "which are NOT permitted to access this share. Where the lists "
            "conflict, the allow list takes precedence. In the event that it "
            "is necessary to deny all by default, use the keyword ALL (or the "
            "netmask 0.0.0.0/0) and then explicitly specify to the hosts "
            "allow parameter those hosts that should be permitted access. "
            "Leave this field empty to use default settings."),
    )
    cifs_vfsobjects = MultiSelectField(verbose_name=_('VFS Objects'),
                                       max_length=255,
                                       blank=True,
                                       default='aio_pthread,streams_xattr',
                                       choices=list(
                                           choices.CIFS_VFS_OBJECTS()))
    cifs_storage_task = models.ForeignKey(
        Task,
        verbose_name=_("Periodic Snapshot Task"),
        on_delete=models.SET_NULL,
        blank=True,
        null=True)
    cifs_auxsmbconf = models.TextField(
        max_length=120,
        verbose_name=_("Auxiliary Parameters"),
        blank=True,
        help_text=_(
            "These parameters are added to [Share] section of smb.conf"))

    def __unicode__(self):
        return self.cifs_name

    def delete(self, *args, **kwargs):
        super(CIFS_Share, self).delete(*args, **kwargs)
        notifier().reload("cifs")

    class Meta:
        verbose_name = _("Windows (CIFS) Share")
        verbose_name_plural = _("Windows (CIFS) Shares")
        ordering = ["cifs_name"]
Пример #3
0
class CIFS_Share(Model):
    cifs_path = PathField(
        verbose_name=_("Path"),
        blank=True,
    )
    cifs_home = models.BooleanField(
        verbose_name=_('Use as home share'),
        default=False,
    )
    cifs_timemachine = models.BooleanField(
        verbose_name=_('Time Machine'),
        help_text=_(
            'Enable Time Machine backups on this share.'
        ),
        default=False,
    )
    cifs_name = models.CharField(
        max_length=120,
        verbose_name=_("Name")
    )
    cifs_comment = models.CharField(
        max_length=120,
        verbose_name=_("Comment"),
        blank=True,
    )
    cifs_ro = models.BooleanField(
        verbose_name=_('Export Read Only'),
        default=False,
    )
    cifs_browsable = models.BooleanField(
        verbose_name=_('Browsable to Network Clients'),
        default=True,
    )
    cifs_recyclebin = models.BooleanField(
        verbose_name=_('Export Recycle Bin'),
        default=False,
    )
    cifs_showhiddenfiles = models.BooleanField(
        verbose_name=_('Show Hidden Files'),
        default=False,
    )
    cifs_shadowcopy = models.BooleanField(
        verbose_name=_('Enable Shadow Copies'),
        help_text=_(
            'Export ZFS snapshots as Shadow Copies for VSS clients.'
        ),
        default=False
    )
    cifs_guestok = models.BooleanField(
        verbose_name=_('Allow Guest Access'),
        help_text=_(
            'If true then no password is required to connect to the share. '
            'Privileges will be those of the guest account.'
        ),
        default=False,
    )
    cifs_guestonly = models.BooleanField(
        verbose_name=_('Only Allow Guest Access'),
        help_text=_(
            'If true then only guest connections to the share are permitted. '
            'This parameter will have no effect if Allow Guest Access is not '
            'set for the share.'
        ),
        default=False,
    )
    cifs_abe = models.BooleanField(
        verbose_name=_('Access Based Share Enumeration'),
        default=False
    )
    cifs_hostsallow = models.TextField(
        blank=True,
        verbose_name=_("Hosts Allow"),
        help_text=_(
            "This option is a comma, space, or tab delimited set of hosts "
            "which are permitted to access this share. You can specify the "
            "hosts by name or IP number. Leave this field empty to use "
            "default settings."
        ),
    )
    cifs_hostsdeny = models.TextField(
        blank=True,
        verbose_name=_("Hosts Deny"),
        help_text=_(
            "This option is a comma, space, or tab delimited set of host "
            "which are NOT permitted to access this share. Where the lists "
            "conflict, the allow list takes precedence. In the event that it "
            "is necessary to deny all by default, use the keyword ALL (or the "
            "netmask 0.0.0.0/0) and then explicitly specify to the hosts "
            "allow parameter those hosts that should be permitted access. "
            "Leave this field empty to use default settings."
        ),
    )
    cifs_vfsobjects = MultiSelectField(
        verbose_name=_('VFS Objects'),
        max_length=255,
        blank=True,
        default='zfs_space,zfsacl,streams_xattr',
        choices=list(choices.CIFS_VFS_OBJECTS())
    )
    cifs_vuid = models.CharField(
        max_length=36,
        verbose_name=_('vuid for Time Machine'),
        blank=True,
        editable=False,
    )
    cifs_auxsmbconf = models.TextField(
        verbose_name=_("Auxiliary Parameters"),
        blank=True,
        help_text=_(
            "These parameters are added to [Share] section of smb.conf"
        )
    )

    def __str__(self):
        return self.cifs_name

    class Meta:
        verbose_name = _("Windows (SMB) Share")
        verbose_name_plural = _("Windows (SMB) Shares")
        ordering = ["cifs_name"]