Exemplo n.º 1
0
def groups_view_manage(request):
    args = {}
    if request.POST:
        service = request.POST.get("s", None)
        if service == "list":
            tc = TelnetConnection()
            groups = Groups(telnet=tc.telnet)
            args = groups.list()
        elif service == "add":
            tc = TelnetConnection()
            groups = Groups(telnet=tc.telnet)
            groups.create(data={
                "gid": request.POST.get("gid"),
            })
        elif service == "delete":
            tc = TelnetConnection()
            groups = Groups(telnet=tc.telnet)
            args = groups.destroy(gid=request.POST.get("gid"))
        elif service == "enable":
            tc = TelnetConnection()
            groups = Groups(telnet=tc.telnet)
            args = groups.enable(gid=request.POST.get("gid"))
        elif service == "disable":
            tc = TelnetConnection()
            groups = Groups(telnet=tc.telnet)
            args = groups.disable(gid=request.POST.get("gid"))
    return HttpResponse(json.dumps(args), content_type='application/json')
def morouter_view_manage(request):
	args = {}
	if request.POST:
		service = request.POST.get("s", None)
		if service == "list":
			tc = TelnetConnection()
			morouter = MORouter(telnet=tc.telnet)
			args = morouter.list()
		elif service == "add":
			tc = TelnetConnection()
			morouter = MORouter(telnet=tc.telnet)
			morouter.create(data={
				"type": request.POST.get("type"),
				"order": request.POST.get("order"),
				"smppconnectors": request.POST.get("smppconnectors"),
				"filters": request.POST.get("filters"),
			})
		elif service == "delete":
			tc = TelnetConnection()
			morouter = MORouter(telnet=tc.telnet)
			args = morouter.destroy(order=request.POST.get("order"))
	return HttpResponse(json.dumps(args), content_type='application/json')
def filters_view_manage(request):
    args = {}
    if request.POST:
        service = request.POST.get("s", None)
        if service == "list":
            tc = TelnetConnection()
            filters = Filters(telnet=tc.telnet)
            args = filters.list()
        elif service == "add":
            tc = TelnetConnection()
            filters = Filters(telnet=tc.telnet)
            filters.create(
                data={
                    "fid": request.POST.get("fid"),
                    "type": request.POST.get("type"),
                    "parameter": request.POST.get("parameter"),
                })
        elif service == "delete":
            tc = TelnetConnection()
            filters = Filters(telnet=tc.telnet)
            args = filters.destroy(fid=request.POST.get("fid"))
    return HttpResponse(json.dumps(args), content_type='application/json')
Exemplo n.º 4
0
def httpccm_view_manage(request):
    args = {}
    if request.POST:
        service = request.POST.get("s", None)
        if service == "list":
            tc = TelnetConnection()
            httpccm = HTTPCCM(telnet=tc.telnet)
            args = httpccm.list()
        elif service == "add":
            tc = TelnetConnection()
            httpccm = HTTPCCM(telnet=tc.telnet)
            httpccm.create(
                data={
                    "cid": request.POST.get("cid"),
                    "url": request.POST.get("url"),
                    "method": request.POST.get("method"),
                })
        elif service == "delete":
            tc = TelnetConnection()
            httpccm = HTTPCCM(telnet=tc.telnet)
            args = httpccm.destroy(cid=request.POST.get("cid"))
    return HttpResponse(json.dumps(args), content_type='application/json')
Exemplo n.º 5
0
def smppccm_view_manage(request):
    args = {}
    if request.POST:
        service = request.POST.get("s", None)
        if service == "list":
            tc = TelnetConnection()
            smppccm = SMPPCCM(telnet=tc.telnet)
            args = smppccm.list()
        elif service == "add":
            tc = TelnetConnection()
            smppccm = SMPPCCM(telnet=tc.telnet)
            smppccm.create(
                data={
                    "cid": request.POST.get("cid"),
                    "host": request.POST.get("host"),
                    "port": request.POST.get("port"),
                    "username": request.POST.get("username"),
                    "password": request.POST.get("password"),
                })
        elif service == "edit":
            tc = TelnetConnection()
            smppccm = SMPPCCM(telnet=tc.telnet)
            smppccm.partial_update(data={
                "cid":
                request.POST.get("cid"),
                "logfile":
                request.POST.get(
                    "logfile", "/var/log/jasmin/default-%s.log" %
                    request.POST.get("cid")),
                "logrotate":
                request.POST.get("logrotate", "midnight"),
                "loglevel":
                request.POST.get("loglevel", "20"),
                "host":
                request.POST.get("host", "127.0.0.1"),
                "port":
                request.POST.get("port", "2775"),
                "ssl":
                request.POST.get("ssl", "no"),
                "username":
                request.POST.get("username", "smppclient"),
                "password":
                request.POST.get("password", "password"),
                "bind":
                request.POST.get("bind", "transceiver"),
                "bind_to":
                request.POST.get("bind_to", "30"),
                "trx_to":
                request.POST.get("trx_to", "300"),
                "res_to":
                request.POST.get("res_to", "60"),
                "pdu_red_to":
                request.POST.get("pdu_red_to", "10"),
                "con_loss_retry":
                request.POST.get("con_loss_retry", "yes"),
                "con_loss_delay":
                request.POST.get("con_loss_delay", "10"),
                "con_fail_retry":
                request.POST.get("con_fail_retry", "yes"),
                "con_fail_delay":
                request.POST.get("con_fail_delay", "10"),
                "src_addr":
                request.POST.get("src_addr", ""),
                "src_ton":
                request.POST.get("src_ton", "2"),
                "src_npi":
                request.POST.get("src_npi", "1"),
                "dst_ton":
                request.POST.get("dst_ton", "1"),
                "dst_npi":
                request.POST.get("dst_npi", "1"),
                "bind_ton":
                request.POST.get("bind_ton", "0"),
                "bind_npi":
                request.POST.get("bind_npi", "1"),
                "validity":
                request.POST.get("validity", ""),
                "priority":
                request.POST.get("priority", "0"),
                "requeue_delay":
                request.POST.get("requeue_delay", "120"),
                "addr_range":
                request.POST.get("addr_range", ""),
                "systype":
                request.POST.get("systype", ""),
                "dlr_expiry":
                request.POST.get("dlr_expiry", "86400"),
                "submit_throughput":
                request.POST.get("submit_throughput", "1"),
                "proto_id":
                request.POST.get("proto_id", ""),
                "coding":
                request.POST.get("coding", "0"),
                "elink_interval":
                request.POST.get("elink_interval", "30"),
                "def_msg_id":
                request.POST.get("def_msg_id", "0"),
                "ripf":
                request.POST.get("ripf", "0"),
                "dlr_msgid":
                request.POST.get("dlr_msgid", "0"),
            },
                                   cid=request.POST.get("cid"))
        elif service == "delete":
            tc = TelnetConnection()
            smppccm = SMPPCCM(telnet=tc.telnet)
            args = smppccm.destroy(cid=request.POST.get("cid"))
        elif service == "start":
            tc = TelnetConnection()
            smppccm = SMPPCCM(telnet=tc.telnet)
            args = smppccm.start(cid=request.POST.get("cid"))
        elif service == "stop":
            tc = TelnetConnection()
            smppccm = SMPPCCM(telnet=tc.telnet)
            args = smppccm.stop(cid=request.POST.get("cid"))
        elif service == "restart":
            tc = TelnetConnection()
            smppccm = SMPPCCM(telnet=tc.telnet)
            args = smppccm.stop(cid=request.POST.get("cid"))
            args = smppccm.start(cid=request.POST.get("cid"))
    return HttpResponse(json.dumps(args), content_type='application/json')
Exemplo n.º 6
0
def users_view_manage(request):
    args = {}
    if request.POST:
        service = request.POST.get("s", None)
        if service == "list":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            args = users.list()
        elif service == "add":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            users.create(
                data={
                    "uid": request.POST.get("uid"),
                    "gid": request.POST.get("gid"),
                    "username": request.POST.get("username"),
                    "password": request.POST.get("password"),
                })
            u = UserManager().add(
                data={
                    "uid": request.POST.get("uid"),
                    "gid": request.POST.get("gid"),
                    "username": request.POST.get("username"),
                    "password": request.POST.get("password"),
                })
        elif service == "edit":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            data = [
                ["uid", request.POST.get("uid")],
                ["gid", request.POST.get("gid")],
                ["username", request.POST.get("username")],
                [
                    "mt_messaging_cred", "valuefilter", "priority",
                    request.POST.get("priority_f", "^[0-3]$")
                ],
                [
                    "mt_messaging_cred", "valuefilter", "content",
                    request.POST.get("content_f", ".*")
                ],
                [
                    "mt_messaging_cred", "valuefilter", "src_addr",
                    request.POST.get("src_addr_f", ".*")
                ],
                [
                    "mt_messaging_cred", "valuefilter", "dst_addr",
                    request.POST.get("dst_addr_f", ".*")
                ],
                [
                    "mt_messaging_cred", "valuefilter", "validity_period",
                    request.POST.get("validity_period_f", "^\\d+$")
                ],
                [
                    "mt_messaging_cred", "defaultvalue", "src_addr",
                    request.POST.get("src_addr_d", "None")
                ],
                [
                    "mt_messaging_cred", "quota", "http_throughput",
                    request.POST.get("http_throughput", "ND")
                ],
                [
                    "mt_messaging_cred", "quota", "balance",
                    request.POST.get("balance", "ND")
                ],
                [
                    "mt_messaging_cred", "quota", "smpps_throughput",
                    request.POST.get("smpps_throughput", "ND")
                ],
                [
                    "mt_messaging_cred", "quota", "early_percent",
                    request.POST.get("early_percent", "ND")
                ],
                [
                    "mt_messaging_cred", "quota", "sms_count",
                    request.POST.get("sms_count", "ND")
                ],
                [
                    "mt_messaging_cred", "authorization", "dlr_level",
                    "True" if request.POST.get("dlr_level", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization",
                    "http_long_content", "True" if request.POST.get(
                        "http_long_content", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization", "http_send",
                    "True" if request.POST.get("http_send", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization",
                    "http_dlr_method", "True" if request.POST.get(
                        "http_dlr_method", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization",
                    "validity_period", "True" if request.POST.get(
                        "validity_period", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization", "priority",
                    "True" if request.POST.get("priority", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization", "http_bulk",
                    "True" if request.POST.get("http_bulk", False) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization", "src_addr",
                    "True" if request.POST.get("src_addr", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization", "http_rate",
                    "True" if request.POST.get("http_rate", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization",
                    "http_balance", "True" if request.POST.get(
                        "http_balance", True) else "False"
                ],
                [
                    "mt_messaging_cred", "authorization", "smpps_send",
                    "True" if request.POST.get("smpps_send", True) else "False"
                ],
            ]
            if len(request.POST.get("password")) > 0:
                data.append(["password", request.POST.get("password")])
            users.partial_update(data, uid=request.POST.get("uid"))
            u = UserManager().update(data={
                "uid": request.POST.get("uid"),
                "gid": request.POST.get("gid"),
                "username": request.POST.get("username"),
                "password": request.POST.get("password"),
            },
                                     uid=request.POST.get("uid"))
        elif service == "delete":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            args = users.destroy(uid=request.POST.get("uid"))
            u = UserManager().delete(uid=request.POST.get("uid"))
        elif service == "enable":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            args = users.enable(uid=request.POST.get("uid"))
        elif service == "disable":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            args = users.disable(uid=request.POST.get("uid"))
        elif service == "smpp_unbind":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            args = users.smpp_unbind(uid=request.POST.get("uid"))
        elif service == "smpp_ban":
            tc = TelnetConnection()
            users = Users(telnet=tc.telnet)
            args = users.smpp_ban(uid=request.POST.get("uid"))
    return HttpResponse(json.dumps(args), content_type='application/json')