Beispiel #1
0
    def test_autodel(self):
        schema = Schema({'key': str, AutoDel(str): object})
        schema2 = Schema({'key': str})
        data = schema.validate({
            'key': 'abc',
            'key2': 'bbb',
            'key3': [1, 2, 3]
        })
        self.assertEqual({'key': 'abc'}, data)
        with self.assertRaises(SchemaError):
            schema2.validate({'key': 'abc', 'key2': 'bbb', 'key3': [1, 2, 3]})

        with self.assertRaises(SchemaError):
            schema.validate({'key2': 'bbb', 1: [1, 2, 3]})
Beispiel #2
0
    def __init__(self):
        # need a mutex to protect create/delete bond interface
        self.lock = lock()
        self.support_fs_type = {}
        self.conf_file = os.path.join(STORLEVER_CONF_DIR, FS_CONF_FILE_NAME)
        self.fs_conf_schema = Schema({
            "type": Use(str),     # filesystem type
            "dev_file":  Use(str),     # dev file
            "dev_uuid": Use(str),      # dev uuid
            "mount_point": Use(str),  # mount point of this fs,
            "mount_option": Use(str),  # mount option of this fs
            "check_onboot": BoolVal(),  # fsck fs on boot
            Optional("comment"): Default(Use(str), default=""),  # comment,
            AutoDel(str): object  # for all other key we auto delete
        })
        self.fs_dict_schema = Schema({
            DoNotCare(str): self.fs_conf_schema
        })

        # sync fs conf to fstab on boot
        self.sync_to_fstab()
Beispiel #3
0
}

FTP_CONF_FILE_NAME = "ftp_conf.yaml"
VSFTPD_ETC_CONF_DIR = "/etc/vsftpd/"
VSFTPD_ETC_CONF_FILE = "vsftpd.conf"
VSFTPD_ETC_USER_LIST = "user_list"
VSFTPD_ETC_CHROOT_LIST = "chroot_list"

FTP_USER_CONF_SCHEMA = Schema({
    "user_name": Use(str),
    # When enabled, the user can log in ftp
    Optional("login_enable"): Default(BoolVal(), default=True),
    # When enabled, the user will be placed into the chroot jail
    Optional("chroot_enable"): Default(BoolVal(), default=False),

    AutoDel(str): object  # for all other key we auto delete
})

FTP_CONF_SCHEMA = Schema({
    Optional("listen"): Default(BoolVal(), default=False),    # ftp service listen on ipv4 port
    Optional("listen6"): Default(BoolVal(), default=False),   # ftp service listen on ipv6 port
    Optional("listen_port"): Default(IntVal(min=1, max=65535), default=21),  # ftp port number

    # The maximum amount of time between commands from a remote client.
    # Once triggered, the connection to the remote client is closed
    Optional("idle_session_timeout"): Default(Use(int), default=300),

    # the maximum data transfer rate for anonymous users in bytes per second.
    # The default value is 0, which does not limit the transfer rate.
    Optional("anon_max_rate"): Default(Use(int), default=0),
    # the maximum rate data is transferred for local users in bytes per second.
Beispiel #4
0
MAIL_CMD = "/bin/mail"

MAIL_CONF_SCHEMA = Schema({

    # the email address of user's account, it would also be place in the FROM header of the email
    Optional("email_addr"):
    Default(Use(str), default=""),

    # smtp server address to send the mail
    Optional("smtp_server"):
    Default(Use(str), default=""),

    # password for the account
    Optional("password"):
    Default(Use(str), default=""),
    AutoDel(str):
    object  # for all other key we auto delete
})


class MailManager(object):
    """contains all methods to manage NTP server in linux system"""
    def __init__(self):
        # need a mutex to protect create/delete bond interface
        self.lock = lock()
        self.conf_file = os.path.join(STORLEVER_CONF_DIR, MAIL_CONF_FILE_NAME)
        self.mail_conf_schema = MAIL_CONF_SCHEMA

    def _load_conf(self):
        mail_conf = {}
        cfg_mgr().check_conf_dir()