当前位置: 首页>>代码示例>>Python>>正文


Python common.get_params_from_request函数代码示例

本文整理汇总了Python中storlever.rest.common.get_params_from_request函数的典型用法代码示例。如果您正苦于以下问题:Python get_params_from_request函数的具体用法?Python get_params_from_request怎么用?Python get_params_from_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_params_from_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: put_service

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)
开发者ID:OpenSight,项目名称:StorLever,代码行数:26,代码来源:system.py

示例2: post_tgt_target_lun_list

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
开发者ID:OpenSight,项目名称:StorLever,代码行数:26,代码来源:san.py

示例3: check_password

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')
开发者ID:OpenSight,项目名称:StorLever,代码行数:7,代码来源:system.py

示例4: post_send_mail

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}
开发者ID:dulton,项目名称:StorLever,代码行数:7,代码来源:utils.py

示例5: set_scsi_dev_smart

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
开发者ID:ntvis,项目名称:StorLever,代码行数:30,代码来源:block.py

示例6: del_quota_user

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)
开发者ID:OpenSight,项目名称:StorLever,代码行数:8,代码来源:fs.py

示例7: get_fs_ls

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
开发者ID:OpenSight,项目名称:StorLever,代码行数:8,代码来源:fs.py

示例8: change_password

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')
开发者ID:OpenSight,项目名称:StorLever,代码行数:8,代码来源:system.py

示例9: set_block_opt

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)
开发者ID:ntvis,项目名称:StorLever,代码行数:9,代码来源:block.py

示例10: post_lv_snapshot

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)
开发者ID:OpenSight,项目名称:StorLever,代码行数:9,代码来源:lvm.py

示例11: post_tgt_target_iqn_list

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
开发者ID:OpenSight,项目名称:StorLever,代码行数:10,代码来源:san.py

示例12: add_group

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
开发者ID:OpenSight,项目名称:StorLever,代码行数:10,代码来源:system.py

示例13: put_snmp_agent_monitor_info

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)
开发者ID:dulton,项目名称:StorLever,代码行数:10,代码来源:utils.py

示例14: scan_bus

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)
开发者ID:ntvis,项目名称:StorLever,代码行数:10,代码来源:block.py

示例15: post_port_op

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)
开发者ID:OpenSight,项目名称:StorLever,代码行数:10,代码来源:network.py


注:本文中的storlever.rest.common.get_params_from_request函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。