예제 #1
0
    def test_bool_value(self):
        schema = Schema(BoolVal())
        self.assertEquals(True, schema.validate(True))
        self.assertEquals(True, schema.validate("True"))
        self.assertEquals(True, schema.validate("true"))

        self.assertEquals(False, schema.validate(False))
        self.assertEquals(False, schema.validate("False"))
        self.assertEquals(False, schema.validate("false"))

        with self.assertRaises(SchemaError):
            schema.validate(0)

        with self.assertRaises(SchemaError):
            schema.validate(1)

        with self.assertRaises(SchemaError):
            schema.validate("abc")
예제 #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()
예제 #3
0
    "rpms": [
        "vsftpd"
    ],
    "comment": "Provides the management functions for FTP server"
}

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),
예제 #4
0
파일: san.py 프로젝트: linuxmap/StorLever
    # pt      : passthrough type to export a /dev/sg device
    Optional("device_type"):
    StrRe(r"^(disk|tape|ssc|cd|changer|pt)$"),

    # the type of backend storage. Possible backend types are:
    # rdwr    : Use normal file I/O. This is the default for disk devices
    # aio     : Use Asynchronous I/O
    # sg      : Special backend type for passthrough devices
    #  ssc     : Special backend type for tape emulation
    Optional("bs_type"):
    StrRe(r"^(rdwr|aio|sg|ssc)$"),

    # if true, a direct mapped logical unit (LUN) with the same properties as the
    # physical device (such as VENDOR_ID, SERIAL_NUM, etc.)
    Optional("direct_map"):
    BoolVal(),

    # enable write cache or not
    Optional("write_cache"):
    BoolVal(),

    # readonly or read-write
    Optional("readonly"):
    BoolVal(),

    # online or offline
    Optional("online"):
    BoolVal(),

    # scsi id, if empty, it would automatically be set to a default value
    Optional("scsi_id"):
예제 #5
0
        }
        fs_dict.append(fs_info)
    return fs_dict


add_fs_schema = Schema({
    "fsname":
    StrRe(r"^(.+)$"),
    "type":
    StrRe(r"^([a-zA-Z].+)$"),
    "dev":
    StrRe(r"^(/dev/.+)$"),
    Optional("mountoption"):
    Default(StrRe(), default=""),
    Optional("checkonboot"):
    Default(BoolVal(), default=False),
    Optional("comment"):
    Default(StrRe(), default=""),
    Optional("user"):
    Default(StrRe(), default="unknown"),
    DoNotCare(Use(str)):
    object  # for all those key we don't care
})


#curl -v -X POST -d fsname=test -d dev=/dev/mapper/vg1-lv -d type=ext4  http://192.168.1.2:6543/storlever/api/v1//fs/list
@post_view(route_name='fs_list')
def add_fs(request):
    fs_mrg = fsmgr.fs_mgr()
    params = get_params_from_request(request, add_fs_schema)
    fs_mrg.add_fs(params["fsname"],params["type"],params["dev"],\
예제 #6
0
    # When a directory is created, the necessary permissions are calculated
    # according to the mapping from DOS modes to UNIX permissions, and the
    # resulting UNIX mode is then bit-wise ANDed with this parameter. This
    # parameter may be thought of as a bit-wise MASK for the UNIX modes of a
    # directory. Any bit not set here will be removed from the modes set on a
    # directory when it is created
    # default is 755, which means removes the ?group? and ?other? write
    # bits from the UNIX mode, allowing only the user who owns the directory to
    # modify it.
    Optional("directory_mask"):
    Default(IntVal(min=0, max=0777), default=0755),

    #  If this parameter is True for a share, then no password is required to
    # connect to the share. Privileges will be those of the guest account..
    Optional("guest_ok"):
    Default(BoolVal(), default=False),

    #  If this parameter is true, then users of a service may not create or modify
    # files in the service?s directory..
    Optional("read_only"):
    Default(BoolVal(), default=True),

    # This controls whether this share is seen in the list of available shares in
    # a net view and in the browse list..
    Optional("browseable"):
    Default(BoolVal(), default=True),

    # This is a list of users that should be allowed to login to this service.
    # If this is empty (the default) then any user can login
    Optional("valid_users"):
    Default(Use(str), default=""),
예제 #7
0
파일: block.py 프로젝트: linuxmap/StorLever
# http://192.168.1.10:6543/storlever/api/v1/block/scsi/host_list
@get_view(route_name='dev_host_list')
def host_list_get(request):
    scsi_mgr =  scsimgr.scsi_mgr()
    scsi_list = scsi_mgr.get_scsi_host_list()
    return scsi_list



scan_bus_schema = Schema({                
    Optional("opt"): StrRe(r"^(re_scan)$"),
    Optional("host"): Default(ListVal(IntVal(0, 16)), default=[]),
    Optional("channels"): Default(ListVal(IntVal(0, 1)), default=[]),
    Optional("targets"): Default(ListVal(IntVal(0, 16)), default=[]),
    Optional("luns"): Default(ListVal(IntVal(0, 7)), default=[]),
    Optional("remove"): BoolVal(),
    Optional("force_rescan"): BoolVal(),
    Optional("force_remove"): BoolVal(),
    DoNotCare(Use(str)): object   # for all those key we don't care
})
# curl -v -X put -d opt=re_scan  http://192.168.1.10:6543/storlever/api/v1/block/scsi/scan_bus
@put_view(route_name='scan_bus')
def scan_bus(request):
    scsi_mgr =  scsimgr.scsi_mgr()
    params = get_params_from_request(request, scan_bus_schema)
    remove = params.get("remove", False),
    force_rescan = params.get("force_rescan", False),
    force_remove = params.get("force_remove", False),
    if params['opt'] == "re_scan":  
        scsi_mgr.rescan_bus(params['host'], params['channels'], params['targets'],\
                             params['luns'],remove,force_rescan, force_remove)
예제 #8
0

NTP_CONF_FILE_NAME = "ntp_conf.yaml"
NTP_ETC_CONF_DIR = "/etc/"
NTP_ETC_CONF_FILE = "ntp.conf"
NTP_ETC_STORLEVER_CONF_DIR = "/etc/ntp/"
NTP_ETC_STORLEVER_CONF_FILE = "ntp.storlever.conf"
NTPQ_CMD = "/usr/sbin/ntpq"


NTP_SERVER_CONF_SCHEMA = Schema({
    # it can be a ipv4 address, ipv6 address, or host dns name
    "server_addr": Use(str),
    # if set to True, it would be forced to resolve the host name to
    # ipv6 address in DNS resolution
    Optional("ipv6"):  Default(BoolVal(), default=False),

    # Marks the server as preferred.  All other things being equal,
    # this host will be chosen for synchronization among set of correctly operating hosts
    Optional("prefer"): Default(BoolVal(), default=False),

    # Specifies a mode number which is interpreted in a device
    # specific fashion.	For instance, it selects a dialing,
    # protocol in the ACTS driver and a device subtype in the
    # parse drivers.
    # Only valid for reference clock server, i.e. server_addr is 127.127.t.n
    Optional("mode"): Default(IntVal(min=0, max=65535), default=0),


    # Specifies the stratum number assigned to the driver, an
    # integer between 0 and 15.	This number overrides the
예제 #9
0
@get_view(route_name='user_list')
def get_user_list(request):
    user_mgr = usermgr.user_mgr()  # get user manager
    return user_mgr.user_list()


user_info_schema = Schema({
    "name": Use(unicode),  # name should be string
    Optional("uid"): Use(int),  # uid must int
    Optional("password"): Use(unicode),  # password should be a string
    Optional("comment"): Use(unicode),  # comment must int,
    Optional("primary_group"): Use(unicode),  # primay_group must int
    Optional("groups"): Use(unicode),
    Optional("home_dir"): Use(unicode),
    Optional("login"): BoolVal(),
    DoNotCare(Use(str)): object  # for all those key we don't care
})


@post_view(route_name='user_list')
def add_user(request):
    user_info = get_params_from_request(request, user_info_schema)
    user_mgr = usermgr.user_mgr()
    user_mgr.user_add(user_info["name"],
                      user_info.get("password"),
                      user_info.get("uid"),
                      user_info.get("primary_group"),
                      user_info.get("groups"),
                      user_info.get("home_dir"),
                      user_info.get("login"),
예제 #10
0
파일: nas.py 프로젝트: linuxmap/StorLever
    config.add_route('smb_share_conf', '/nas/smb/share_list/{share_name}')
    config.add_route('smb_connection_list', '/nas/smb/connection_list')
    config.add_route('smb_account_list', '/nas/smb/account_list')
    config.add_route('smb_account_conf',
                     '/nas/smb/account_list/{account_name}')


@get_view(route_name='ftp_conf')
def get_ftp_conf(request):
    ftp_mgr = ftpmgr.FtpManager
    return ftp_mgr.get_ftp_conf()


ftp_conf_schema = Schema({
    Optional("listen"):
    BoolVal(),  # ftp service listen on ipv4 port
    Optional("listen6"):
    BoolVal(),  # ftp service listen on ipv6 port
    Optional("listen_port"):
    IntVal(min=1, max=65535),  # 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"):
    Use(int),

    # 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"):
    Use(int),
    # the maximum rate data is transferred for local users in bytes per second.