Пример #1
0
def check_password(request):
    check_web_password_request = get_params_from_request(request, web_password_check_schema)
    if webconfig.WebPassword().check_password(check_web_password_request['login'],
                                              check_web_password_request['password']):
        return Response(status=200)
    else:
        raise StorLeverError('Wrong user name or password')
Пример #2
0
def put_service(request):
    service_name = request.matchdict["service_name"]
    cmd = get_params_from_request(request, service_mod_schema)

    service_mgr = servicemgr.service_mgr()      # get service manager
    service = service_mgr.get_service_by_name(service_name)

    if "state" in cmd:
        if cmd["state"]:
            service.start(request.client_addr)
        else:
            service.stop(request.client_addr)
    elif "restart" in cmd:
        if cmd["restart"]:
            service.restart(request.client_addr)
    elif "reload" in cmd:
        if cmd["restart"]:
            service.reload(request.client_addr)

    if "auto_start" in cmd:
        if cmd["auto_start"]:
            service.enable_auto_start(request.client_addr)
        else:
            service.disable_auto_start(request.client_addr)

    return Response(status=200)
Пример #3
0
def put_service(request):
    service_name = request.matchdict["service_name"]
    cmd = get_params_from_request(request, service_mod_schema)

    service_mgr = servicemgr.service_mgr()  # get service manager
    service = service_mgr.get_service_by_name(service_name)

    if "state" in cmd:
        if cmd["state"]:
            service.start(request.client_addr)
        else:
            service.stop(request.client_addr)
    elif "restart" in cmd:
        if cmd["restart"]:
            service.restart(request.client_addr)
    elif "reload" in cmd:
        if cmd["restart"]:
            service.reload(request.client_addr)

    if "auto_start" in cmd:
        if cmd["auto_start"]:
            service.enable_auto_start(request.client_addr)
        else:
            service.disable_auto_start(request.client_addr)

    return Response(status=200)
Пример #4
0
def set_scsi_dev_smart(request):
    scsi_id = request.matchdict['scsi_id']
    scsi_mgr =  scsimgr.scsi_mgr()
    scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id)
    params = get_params_from_request(request, scsi_dev_smart_schema)
    smart_set = params.get("smart", None),
    offline_set = params.get("offline_auto", None),
    scsi_dev_info.set_smart_config(smart_set,offline_set)
    return Response(status=200)



#@get_view(route_name='adapter_list')
#def adapters_get(request):
    #pass


#@get_view(route_name='adapter')
#def adapters_get(request):
    #pass


#@get_view(route_name='adapter_disk_list')
#def adapters_get(request):
    #pass


#@get_view(route_name='adapter_vdisk_list')
#def adapters_get(request):
    #pass
Пример #5
0
def post_tgt_target_lun_list(request):
    iqn = request.matchdict['target_iqn']
    tgt_mgr = tgtmgr.TgtManager
    target = tgt_mgr.get_target_by_iqn(iqn)
    new_lun_conf = get_params_from_request(request, lun_conf_schema)
    if "path" not in new_lun_conf:
        raise StorLeverError("New LUN's path must be configured", 400)

    target.add_lun(new_lun_conf["lun"],
                   new_lun_conf["path"],
                   new_lun_conf.get("device_type", "disk"),
                   new_lun_conf.get("bs_type", "rdwr"),
                   new_lun_conf.get("direct_map", False),
                   new_lun_conf.get("write_cache", True),
                   new_lun_conf.get("readonly", False),
                   new_lun_conf.get("online", True),
                   new_lun_conf.get("scsi_id", ""),
                   new_lun_conf.get("scsi_sn", ""),
                   operator=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('tgt_target_lun_info',
                                      target_iqn=iqn,
                                      lun_number=new_lun_conf["lun"])
    return resp
Пример #6
0
def post_tgt_target_lun_list(request):
    iqn = request.matchdict['target_iqn']
    tgt_mgr = tgtmgr.TgtManager
    target = tgt_mgr.get_target_by_iqn(iqn)
    new_lun_conf = get_params_from_request(request, lun_conf_schema)
    if "path" not in new_lun_conf:
        raise StorLeverError("New LUN's path must be configured", 400)

    target.add_lun(new_lun_conf["lun"],
                   new_lun_conf["path"],
                   new_lun_conf.get("device_type", "disk"),
                   new_lun_conf.get("bs_type", "rdwr"),
                   new_lun_conf.get("direct_map", False),
                   new_lun_conf.get("write_cache", True),
                   new_lun_conf.get("readonly", False),
                   new_lun_conf.get("online", True),
                   new_lun_conf.get("scsi_id", ""),
                   new_lun_conf.get("scsi_sn", ""),
                   operator=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('tgt_target_lun_info',
                                      target_iqn=iqn,
                                      lun_number=new_lun_conf["lun"])
    return resp
Пример #7
0
def post_send_mail(request):
    mail_mgr = mailmgr.MailManager
    send_mail_conf = get_params_from_request(request, send_mail_schema)
    info = mail_mgr.send_email(
        send_mail_conf["to"], send_mail_conf["subject"], send_mail_conf["content"], send_mail_conf["debug"]
    )
    return {"debug_info": info}
Пример #8
0
def post_send_mail(request):
    mail_mgr = mailmgr.MailManager
    send_mail_conf = get_params_from_request(request, send_mail_schema)
    info = mail_mgr.send_email(send_mail_conf["to"], send_mail_conf["subject"],
                               send_mail_conf["content"],
                               send_mail_conf["debug"])
    return {"debug_info": info}
Пример #9
0
def put_zabbix_passive_server_list(request):
    zabbix_agent = zabbixagent.ZabbixAgentManager
    server_list_conf = get_params_from_request(
        request, zabbix_passive_server_list_schema)
    zabbix_agent.set_passive_check_server_list(server_list_conf,
                                               operator=request.client_addr)
    return Response(status=200)
Пример #10
0
def set_scsi_dev_smart(request):
    scsi_id = request.matchdict['scsi_id']
    scsi_mgr =  scsimgr.scsi_mgr()
    scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id)
    params = get_params_from_request(request, scsi_dev_smart_schema)
    smart_set = params.get("smart", None),
    offline_set = params.get("offline_auto", None),
    scsi_dev_info.set_smart_config(smart_set,offline_set)
    return Response(status=200)



#@get_view(route_name='adapter_list')
#def adapters_get(request):
    #pass


#@get_view(route_name='adapter')
#def adapters_get(request):
    #pass


#@get_view(route_name='adapter_disk_list')
#def adapters_get(request):
    #pass


#@get_view(route_name='adapter_vdisk_list')
#def adapters_get(request):
    #pass
Пример #11
0
def del_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, del_quoat_group_schema)
    user = params["user"]
    fs.quota_group_set(user, 0, 0, 0, 0)
    return Response(status=200)
Пример #12
0
def del_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, del_quoat_group_schema)
    user = params["user"]
    fs.quota_group_set(user,0,0,0,0)
    return Response(status=200)
Пример #13
0
def change_password(request):
    change_password_request = get_params_from_request(request, web_password_change_schema)
    if webconfig.WebPassword().change_password(change_password_request['login'],
                                               change_password_request['old_password'],
                                               change_password_request['new_password']):
        return Response(status=200)
    else:
        raise StorLeverError('Unable to change password')
Пример #14
0
def get_fs_ls(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, get_fs_ls_schema)
    path = params["path"]
    ls_info = fs.ls_dir(path)
    return ls_info
Пример #15
0
def get_fs_ls(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, get_fs_ls_schema)
    path = params["path"]
    ls_info = fs.ls_dir(path)
    return ls_info
Пример #16
0
def check_password(request):
    check_web_password_request = get_params_from_request(
        request, web_password_check_schema)
    if webconfig.WebPassword().check_password(
            check_web_password_request['login'],
            check_web_password_request['password']):
        return Response(status=200)
    else:
        raise StorLeverError('Wrong user name or password')
Пример #17
0
def post_lv_snapshot(request):
    params = get_params_from_request(request, lv_snapshot_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv.snapshot(params['name'], params['size'])
    return Response(status=200)
Пример #18
0
def set_block_opt(request):
    scsi_id = request.matchdict['scsi_id']
    scsi_mgr =  scsimgr.scsi_mgr()
    scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id)
    params = get_params_from_request(request, scsi_dev_smart_schema)
    smart_set = params.get("smart", None),
    offline_set = params.get("offline_auto", None),
    scsi_dev_info.set_smart_config(smart_set,offline_set)
    return Response(status=200)
Пример #19
0
def post_lv_snapshot(request):
    params = get_params_from_request(request, lv_snapshot_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv.snapshot(params['name'], params['size'])
    return Response(status=200)
Пример #20
0
def set_block_opt(request):
    scsi_id = request.matchdict['scsi_id']
    scsi_mgr =  scsimgr.scsi_mgr()
    scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id)
    params = get_params_from_request(request, scsi_dev_smart_schema)
    smart_set = params.get("smart", None),
    offline_set = params.get("offline_auto", None),
    scsi_dev_info.set_smart_config(smart_set,offline_set)
    return Response(status=200)
Пример #21
0
def add_bond_group(request):
    params = get_params_from_request(request, bond_add_schema)
    bond_manager = bond.bond_mgr()
    bond_name = bond_manager.add_group(params['miimon'], params['mode'], params['ifs'],
                                       params['ip'], params['netmask'], params['gateway'],
                                       request.client_addr)

    resp = Response(status=201)
    resp.location = request.route_url('bond_port', port_name=bond_name)
    return resp
Пример #22
0
def post_port_op(request):
    op_info = get_params_from_request(request, port_op_schema)
    port_name = request.matchdict['port_name']
    eth_face = ifmgr.if_mgr()
    eth = eth_face.get_interface_by_name(port_name)
    if op_info["opcode"] == "enable":
        eth.up(user=request.client_addr)
    elif op_info["opcode"] == "disable":
        eth.down(user=request.client_addr)
    return Response(status=200)
Пример #23
0
def modify_single_port(request):
    port_info = get_params_from_request(request, port_mod_schema)
    port_name = request.matchdict['port_name']
    eth_face = ifmgr.if_mgr()
    eth = eth_face.get_interface_by_name(port_name)
    eth.set_ip_config(ip=port_info.get("ip", None),
                      netmask=port_info.get("netmask", None),
                      gateway=port_info.get("gateway", None),
                      user=request.client_addr)
    return Response(status=200)
Пример #24
0
def add_group(request):
    group_info = get_params_from_request(request, group_info_schema)
    user_mgr = usermgr.user_mgr()
    user_mgr.group_add(group_info["name"], group_info.get("gid"),
                       user=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('group_info', group_name=group_info["name"])
    return resp
Пример #25
0
def put_snmp_agent_monitor_info(request):
    monitor_name = request.matchdict["monitor_name"]
    snmp_agent = snmpagent.SnmpAgentManager
    monitor_info = get_params_from_request(request, snmp_monitor_mod_schema)

    snmp_agent.update_monitor_conf(
        monitor_name, monitor_info.get("expression"), monitor_info.get("option"), operator=request.client_addr
    )

    return Response(status=200)
Пример #26
0
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)
    return Response(status=200)
Пример #27
0
def post_tgt_target_iqn_list(request):
    tgt_mgr = tgtmgr.TgtManager
    new_target_conf = get_params_from_request(request, target_conf_schema)
    tgt_mgr.create_target(new_target_conf["iqn"], operator=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('tgt_target_info',
                                      target_iqn=new_target_conf["iqn"])
    return resp
Пример #28
0
def scan_bus(request):
    scsi_mgr =  scsimgr.scsi_mgr()
    params = get_params_from_request(request, scan_bus_schema)
    remove = params.get("remove", None),
    force_rescan = params.get("force_rescan", None),
    force_remove = params.get("force_remove", None),
    if params['opt'] == "re_scan":  
        scsi_mgr.rescan_bus(params['host'], params['channels'], params['targets'],\
                             params['luns'],remove,force_rescan, force_remove)
    return Response(status=200)
Пример #29
0
def post_tgt_target_iqn_list(request):
    tgt_mgr = tgtmgr.TgtManager
    new_target_conf = get_params_from_request(request, target_conf_schema)
    tgt_mgr.create_target(new_target_conf["iqn"], operator=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('tgt_target_info',
                                      target_iqn=new_target_conf["iqn"])
    return resp
Пример #30
0
def modify_single_port(request):
    port_info = get_params_from_request(request, port_mod_schema)
    port_name = request.matchdict['port_name']
    eth_face = ifmgr.if_mgr()
    eth = eth_face.get_interface_by_name(port_name)
    eth.set_ip_config(ip=port_info.get("ip", None),
                      netmask=port_info.get("netmask", None),
                      gateway=port_info.get("gateway", None),
                      user=request.client_addr)
    return Response(status=200)
Пример #31
0
def post_port_op(request):
    op_info = get_params_from_request(request, port_op_schema)
    port_name = request.matchdict['port_name']
    eth_face = ifmgr.if_mgr()
    eth = eth_face.get_interface_by_name(port_name)
    if op_info["opcode"] == "enable":
        eth.up(user=request.client_addr)
    elif op_info["opcode"] == "disable":
        eth.down(user=request.client_addr)
    return Response(status=200)
Пример #32
0
def change_password(request):
    change_password_request = get_params_from_request(
        request, web_password_change_schema)
    if webconfig.WebPassword().change_password(
            change_password_request['login'],
            change_password_request['old_password'],
            change_password_request['new_password']):
        return Response(status=200)
    else:
        raise StorLeverError('Unable to change password')
Пример #33
0
def add_bond_group(request):
    params = get_params_from_request(request, bond_add_schema)
    bond_manager = bond.bond_mgr()
    bond_name = bond_manager.add_group(params['miimon'], params['mode'],
                                       params['ifs'], params['ip'],
                                       params['netmask'], params['gateway'],
                                       request.client_addr)

    resp = Response(status=201)
    resp.location = request.route_url('bond_port', port_name=bond_name)
    return resp
Пример #34
0
def mod_user_info(request):
    user_name = request.matchdict["user_name"]
    user_info = get_params_from_request(request)
    user_info["name"] = user_name
    user_info = user_info_schema.validate(user_info)
    user_mgr = usermgr.user_mgr()
    user_mgr.user_mod(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"),
                      user_info.get("comment"), user=request.client_addr)
    return Response(status=200)
Пример #35
0
def post_vg_op(request):
    params = get_params_from_request(request, vg_op_schema)
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    if(params['opt']) == 'grow' :
        vg.grow(params['dev'])
    elif(params['opt']) == 'shrink' :
        vg.shrink(params['dev'])
               
    return Response(status=200)
Пример #36
0
def change_fs(request):
    params = get_params_from_request(request, change_fs_schema)
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)

    if (params['opt']) == 'grow':
        fs.grow_size()
        return Response(status=200)
    else:
        return Response(status=403)
Пример #37
0
def change_fs(request):
    params = get_params_from_request(request, change_fs_schema)
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    
    if(params['opt']) == 'grow' :
        fs.grow_size()
        return Response(status=200) 
    else :
        return Response(status=403)
Пример #38
0
def put_snmp_agent_monitor_info(request):
    monitor_name = request.matchdict['monitor_name']
    snmp_agent = snmpagent.SnmpAgentManager
    monitor_info = get_params_from_request(request, snmp_monitor_mod_schema)

    snmp_agent.update_monitor_conf(monitor_name,
                                   monitor_info.get("expression"),
                                   monitor_info.get("option"),
                                   operator=request.client_addr)

    return Response(status=200)
Пример #39
0
def block_clean_meta(request):
    block_name = request.matchdict['block']
    params = get_params_from_request(request, block_clean_meta_schema)
    if params['opt'] == "clean_meta":  
        block_mgr =  blockmgr.block_mgr()
        block_dev = block_mgr.get_block_dev_by_name(block_name)
        block_dev.clean_meta()
    elif params['opt'] == "flush_buf":  
        block_mgr =  blockmgr.block_mgr()
        block_dev = block_mgr.get_block_dev_by_name(block_name)
        block_dev.flush_block_buf()   
    return Response(status=200)
Пример #40
0
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"),
                      user_info.get("comment"), user=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('user_info', user_name=user_info["name"])
    return resp
Пример #41
0
def add_group(request):
    group_info = get_params_from_request(request, group_info_schema)
    user_mgr = usermgr.user_mgr()
    user_mgr.group_add(group_info["name"],
                       group_info.get("gid"),
                       user=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('group_info',
                                      group_name=group_info["name"])
    return resp
Пример #42
0
def put_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, put_quoat_group_schema)
    user = params["user"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_user_set(user,block_softlimit,block_hardlimit,inode_softlimit,inode_hardlimit)
    return Response(status=200)
Пример #43
0
def add_quota_group(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, add_quoat_group_schema)
    group = params["group"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_group_set(group,block_softlimit,block_hardlimit,inode_softlimit,inode_hardlimit)
    return Response(status=200)
Пример #44
0
def block_clean_meta(request):
    block_name = request.matchdict['block']
    params = get_params_from_request(request, block_clean_meta_schema)
    if params['opt'] == "clean_meta":  
        block_mgr =  blockmgr.block_mgr()
        block_dev = block_mgr.get_block_dev_by_name(block_name)
        block_dev.clean_meta()
    elif params['opt'] == "flush_buf":  
        block_mgr =  blockmgr.block_mgr()
        block_dev = block_mgr.get_block_dev_by_name(block_name)
        block_dev.flush_block_buf()   
    return Response(status=200)
Пример #45
0
def put_tgt_target_outgoinguser_info(request):
    iqn = request.matchdict['target_iqn']
    username = request.matchdict['user_name']
    tgt_mgr = tgtmgr.TgtManager
    target = tgt_mgr.get_target_by_iqn(iqn)
    mod_user_conf = get_params_from_request(request)
    mod_user_conf["username"] = username
    mod_user_conf = user_conf_schema.validate(mod_user_conf)

    target.set_outgoinguser(mod_user_conf["username"], mod_user_conf["password"], operator=request.client_addr)

    return Response(status=200)
Пример #46
0
def post_vg_op(request):
    params = get_params_from_request(request, vg_op_schema)
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    if (params['opt']) == 'grow':
        for dev in params['dev']:
            vg.grow(dev)
    elif (params['opt']) == 'shrink':
        for dev in params['dev']:
            vg.shrink(dev)
    return Response(status=200)
Пример #47
0
def restore_conf_from_file(request):

    params = get_params_from_request(request)

    # check params
    if "file" not in params:
        raise StorLeverError("\"file\" params must be given", 400)

    cfg_mgr = cfgmgr.cfg_mgr()      # get cfg manager

    cfg_mgr.restore_from_file(params["file"], user=request.client_addr)

    return Response(status=200)
Пример #48
0
def post_lv_op(request):
    params = get_params_from_request(request, lv_op_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    if (params['opt']) == 'activate':
        lv.activate()
    elif (params['opt']) == 'disable':
        lv.deactivate()

    return Response(status=200)
Пример #49
0
def put_nfs_export_info(request):
    export_name = request.matchdict['export_name']
    nfs_mgr = nfsmgr.NfsManager
    export_conf = get_params_from_request(request)
    export_conf["name"] = export_name
    export_conf = nfs_export_schema.validate(export_conf)

    nfs_mgr.set_export_conf(export_name,
                            export_conf.get("path"),
                            export_conf.get("clients"),
                            operator=request.client_addr)

    return Response(status=200)
Пример #50
0
def modify_bond_group(request):
    bond_name = request.matchdict['port_name']
    params = get_params_from_request(request, bond_mod_schema)
    mode = params.get("mode")
    miimon = params.get("miimon")
    bond_manager = bond.bond_mgr()
    bond_group = bond_manager.get_group_by_name(bond_name)
    if mode is None:
        mode = bond_group.mode
    if miimon is None:
        miimon = bond_group.miimon
    bond_group.set_bond_config(miimon, mode, request.client_addr)
    return Response(status=200)
Пример #51
0
def post_smb_account_list(request):
    smb_mgr = smbmgr.SmbManager
    new_account_conf = get_params_from_request(request, smb_account_schema)

    smb_mgr.add_smb_account(new_account_conf["account_name"],
                            new_account_conf["password"],
                            operator=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url(
        'smb_account_conf', account_name=new_account_conf["account_name"])
    return resp
Пример #52
0
def backup_conf_to_file(request):

    params = get_params_from_request(request)

    # check params
    if "file" not in params:
        raise StorLeverError("\"file\" params must be given", 400)

    cfg_mgr = cfgmgr.cfg_mgr()  # get cfg manager

    cfg_mgr.backup_to_file(params["file"])

    return Response(status=200)
Пример #53
0
def put_smb_account_conf(request):
    account_name = request.matchdict['account_name']
    smb_mgr = smbmgr.SmbManager
    account_conf = get_params_from_request(request)

    account_conf["account_name"] = account_name
    account_conf = smb_account_schema.validate(account_conf)

    smb_mgr.set_smb_account_passwd(account_conf["account_name"],
                                   account_conf["password"],
                                   operator=request.client_addr)

    return Response(status=200)
Пример #54
0
def post_smb_account_list(request):
    smb_mgr = smbmgr.SmbManager
    new_account_conf = get_params_from_request(request, smb_account_schema)

    smb_mgr.add_smb_account(new_account_conf["account_name"],
                            new_account_conf["password"],
                            operator=request.client_addr)

    # generate 201 response
    resp = Response(status=201)
    resp.location = request.route_url('smb_account_conf',
                                      account_name=new_account_conf["account_name"])
    return resp
Пример #55
0
def restore_conf_from_file(request):

    params = get_params_from_request(request)

    # check params
    if "file" not in params:
        raise StorLeverError("\"file\" params must be given", 400)

    cfg_mgr = cfgmgr.cfg_mgr()  # get cfg manager

    cfg_mgr.restore_from_file(params["file"], user=request.client_addr)

    return Response(status=200)
Пример #56
0
def backup_conf_to_file(request):

    params = get_params_from_request(request)

    # check params
    if "file" not in params:
        raise StorLeverError("\"file\" params must be given", 400)

    cfg_mgr = cfgmgr.cfg_mgr()      # get cfg manager

    cfg_mgr.backup_to_file(params["file"])

    return Response(status=200)
Пример #57
0
def modify_bond_group(request):
    bond_name = request.matchdict['port_name']
    params = get_params_from_request(request, bond_mod_schema)
    mode = params.get("mode")
    miimon = params.get("miimon")
    bond_manager = bond.bond_mgr()
    bond_group = bond_manager.get_group_by_name(bond_name)
    if mode is None:
        mode = bond_group.mode
    if miimon is None:
        miimon = bond_group.miimon
    bond_group.set_bond_config(miimon, mode, request.client_addr)
    return Response(status=200)
Пример #58
0
def post_lv_op(request):
    params = get_params_from_request(request, lv_op_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    if(params['opt']) == 'activate' :
        lv.activate()
    elif(params['opt']) == 'disable' :
        lv.deactivate()
               
    return Response(status=200)
Пример #59
0
def add_quota_group(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, add_quoat_group_schema)
    group = params["group"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_group_set(group, block_softlimit, block_hardlimit,
                       inode_softlimit, inode_hardlimit)
    return Response(status=200)
Пример #60
0
def put_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, put_quoat_group_schema)
    user = params["user"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_user_set(user, block_softlimit, block_hardlimit, inode_softlimit,
                      inode_hardlimit)
    return Response(status=200)