Ejemplo n.º 1
0
def chkopts(opts):
    reg = re.compile("[^a-zA-Z0-9\./_:-]")

    if opts.name:
        if reg.search(opts.name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-n or --name', opts.name))
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-n or --name')

    if opts.pool_name:
        if reg.search(opts.pool_name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-p or --pool_name', opts.pool_name))
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-p or --pool_name')

    if opts.use:
        if opts.use not in DISK_USES.values():
            raise KssCommandOptException('ERROR: Disk usage is not available. '
                                         'images or disk is available. use=%s' % opts.use)
Ejemplo n.º 2
0
def chkopts(opts):
    reg = re.compile("[^a-zA-Z0-9\./_:-]")

    if opts.name:
        if reg.search(opts.name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-n or --name', opts.name))
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-n or --name')

    if opts.pool_name:
        if reg.search(opts.pool_name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-p or --pool_name', opts.pool_name))
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-p or --pool_name')

    if opts.volume_name:
        if reg.search(opts.pool_name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-p or --pool_name', opts.pool_name))

    if opts.format:
        if reg.search(opts.format):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-f or --format', opts.format))

        if opts.format not in STORAGE_VOLUME_FORMAT.values():
            raise KssCommandOptException('ERROR: Format is not available. '
                                         'raw or qcow2... is available. format=%s' % opts.format)
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-f or format')

    if opts.unit:
        if opts.unit not in STORAGE_VOLUME_UNIT.keys():
            raise KssCommandOptException('ERROR: Volume size unit is not available. '
                                         'K or M... is available. unit=%s' % opts.unit)

    reg = re.compile("[^0-9]")
    if opts.permission_owner:
        if reg.search(opts.permission_owner):
            if opts.permission_owner not in [user[0] for user in get_pwd_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. owner=%s' % (opts.permission_owner))
        else:
            if int(opts.permission_owner) not in [user[2] for user in get_pwd_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. owner=%s' % (opts.permission_owner))

    if opts.permission_group:
        if reg.search(opts.permission_group):
            if opts.permission_group not in [group[0] for group in get_grp_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. group=%s' % (opts.permission_group))
        else:
            if int(opts.permission_group) not in [group[2] for group in get_grp_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. group=%s' % (opts.permission_group))

    reg = re.compile("^[0-9]{3,4}$")
    if opts.permission_mode:
        if not reg.match(opts.permission_mode):
            raise KssCommandOptException('ERROR: Illigal permission mode. mode=%s' % (opts.permission_mode))

    if opts.use:
        if opts.use not in DISK_USES.values():
            raise KssCommandOptException('ERROR: Disk usage is not available. '
                                         'images or disk is available. use=%s' % opts.use)

        if opts.use == DISK_USES["IMAGES"]:
            if not opts.volume_name:
                raise KssCommandOptException('ERROR: %s option is required.' % '-v or --volume_name')
Ejemplo n.º 3
0
def chkopts(opts):
    reg = re.compile("[^a-zA-Z0-9\./_:-]")

    if opts.name:
        if reg.search(opts.name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-n or --name', opts.name))
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-n or --name')

    if opts.pool_name:
        if reg.search(opts.pool_name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-p or --pool_name', opts.pool_name))
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-p or --pool_name')

    if opts.volume_name:
        if reg.search(opts.pool_name):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-p or --pool_name', opts.pool_name))

    if opts.format:
        if reg.search(opts.format):
            raise KssCommandOptException('ERROR: Illigal option value. option=%s value=%s' % ('-f or --format', opts.format))

        if opts.format not in STORAGE_VOLUME_FORMAT.values():
            raise KssCommandOptException('ERROR: Format is not available. '
                                         'raw or qcow2... is available. format=%s' % opts.format)
    else:
        raise KssCommandOptException('ERROR: %s option is required.' % '-f or format')

    if opts.unit:
        if opts.unit not in STORAGE_VOLUME_UNIT.keys():
            raise KssCommandOptException('ERROR: Volume size unit is not available. '
                                         'K or M... is available. unit=%s' % opts.unit)

    reg = re.compile("[^0-9]")
    if opts.permission_owner:
        if reg.search(opts.permission_owner):
            if opts.permission_owner not in [user[0] for user in get_pwd_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. owner=%s' % (opts.permission_owner))
        else:
            if int(opts.permission_owner) not in [user[2] for user in get_pwd_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. owner=%s' % (opts.permission_owner))

    if opts.permission_group:
        if reg.search(opts.permission_group):
            if opts.permission_group not in [group[0] for group in get_grp_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. group=%s' % (opts.permission_group))
        else:
            if int(opts.permission_group) not in [group[2] for group in get_grp_info()]:
                raise KssCommandOptException('ERROR: Permission user not found. group=%s' % (opts.permission_group))

    reg = re.compile("^[0-9]{3,4}$")
    if opts.permission_mode:
        if not reg.match(opts.permission_mode):
            raise KssCommandOptException('ERROR: Illigal permission mode. mode=%s' % (opts.permission_mode))

    if opts.use:
        if opts.use not in DISK_USES.values():
            raise KssCommandOptException('ERROR: Disk usage is not available. '
                                         'images or disk is available. use=%s' % opts.use)

        if opts.use == DISK_USES["IMAGES"]:
            if not opts.volume_name:
                raise KssCommandOptException('ERROR: %s option is required.' % '-v or --volume_name')