Пример #1
0
 def addPort(self, request):
     request.needAuthType(request.ADMIN)
     request.checkArgs("ras_ip", "port_name", "phone", "type", "comment")
     request.getAuthNameObj().canDo("CHANGE RAS")
     return ras_main.getActionManager().addPort(
         request["ras_ip"], MultiStr(request["port_name"]), request["type"],
         MultiStr(request["phone"]), MultiStr(request["comment"]))
Пример #2
0
 def changeInit(self,mac,ip,ras_ip):
     """
         mac(str): mac address of user
         ip(str): ip/mask address of user
         ras_ip(str): ip of user, user intends to use
     """
     self.registerQuery("user","change",self.changeQuery,[])
     self.mac=map(string.upper,MultiStr(mac))
     self.ip=map(lambda _ip:iplib.formatIPAddress(_ip),MultiStr(ip)) #fix ip format
     self.ras_ip=MultiStr(ras_ip)
Пример #3
0
 def __parseVoIPAttrs(self):
     self.usernames = map(None, MultiStr(self.voip_username))
     if self.generate_password == 0:
         pass_multi = MultiStr(self.voip_password)
         self.passwords = map(lambda x: Password(pass_multi[x]),
                              range(len(self.usernames)))
     else:
         self.passwords = getPasswords(len(self.usernames),
                                       self.generate_password,
                                       self.password_len)
Пример #4
0
 def __initValues(self):
     if self.hasAttr():
         self.caller_id_patterns = map(
             re.compile,
             MultiStr(self.user_obj.getUserAttrs()["limit_caller_id"]))
         self.allow_no_caller_id = self.user_obj.getUserAttrs(
         )["limit_caller_id_allow_not_defined"] == "1"
Пример #5
0
    def getBWSnapShot(self, request):
        request.checkArgs("conds")
        conds = report_lib.fixConditionsDic(request["conds"])
        requester = request.getAuthNameObj()

        if request.hasAuthType(request.ADMIN):
            if not conds.has_key("user_id"):
                request.raiseIncompleteRequest("user_id")

            user_ids = MultiStr(conds["user_id"])
            loaded_users = user_main.getActionManager().getLoadedUsersByUserID(
                user_ids)

            for loaded_user in loaded_users:
                requester.canDo("SEE BW SNAPSHOTS", loaded_user)

            role = "admin"

        elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(
                request.VOIP_USER):
            conds["user_id"] = str(request.getAuthNameObj().getUserID())
            role = "user"

        searcher = snapshot_searcher.SnapShotSearcher(conds, requester, role,
                                                      "bw")
        return searcher.getSnapShots()
Пример #6
0
    def changeInit(self, ips):
        ip_list = map(lambda ip: ip.strip(), MultiStr(ips))

        for ip in ip_list:
            if not iplib.checkIPAddr(ip):
                raise GeneralException(
                    errorText("GENERAL", "INVALID_IP_ADDRESS") % ip)

        self.useGenerateQuery({"limit_station_ip": ",".join(ip_list)})
Пример #7
0
    def changeInit(self, macs):
        mac_list = map(lambda mac: mac.strip(), MultiStr(macs))

        for mac in mac_list:
            if not maclib.checkMacAddress(mac):
                raise GeneralException(
                    errorText("GENERAL", "INVALID_MAC_ADDRESS") % mac)

        self.useGenerateQuery({"limit_mac": ",".join(mac_list)})
Пример #8
0
    def getUserInfo(self, request):
        """
            return user information in a list of dics in format
            [{"basic_info":{basic_user_info},"attrs":{user_attributes}},{"basic_info":{basic_user_info},"attrs":{user_attributes}},...]
            basic_user_info and user_attributes are dictionaries contain name=>values

            if requester is admin, he can specify user_id or normal_username or voip_username. All can be multistrings
            if requirter is user, no argument will be parsed and auth_name is used
        """
        if request.hasAuthType(request.ADMIN):
            if request.has_key("user_id"):
                loaded_users = user_main.getActionManager(
                ).getLoadedUsersByUserID(MultiStr(request["user_id"]))
            elif request.has_key("normal_username"):
                loaded_users = user_main.getActionManager(
                ).getLoadedUsersByNormalUsername(
                    MultiStr(request["normal_username"]))
            elif request.has_key("voip_username"):
                loaded_users = user_main.getActionManager(
                ).getLoadedUsersByVoIPUsername(
                    MultiStr(request["voip_username"]))
            else:
                raise request.raiseIncompleteRequest("user_id")

            admin_obj = request.getAuthNameObj()
            map(admin_obj.canAccessUser, loaded_users)

        elif request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(
                request.VOIP_USER):
            loaded_users = [request.getAuthNameObj()]
        else:
            raise request.raiseIncompleteRequest("auth_type")

        user_infos = user_main.getActionManager().getUserInfosFromLoadedUsers(
            loaded_users, request.getDateType())

        if request.hasAuthType(request.NORMAL_USER) or request.hasAuthType(
                request.VOIP_USER):
            user_info = self.__filterAttrsForUser(user_infos.values()[0])
            return self.__addGroupAttrsForUser(user_info,
                                               request.getDateType())

        return user_infos
Пример #9
0
    def getParsedValue(self, search_helper, dic_key, value_parser_method):
        value = search_helper.getCondValue(dic_key)
        if value_parser_method == MultiStr:
            value = MultiStr(value)
        else:
            if type(value) == types.StringType:
                value = (value, )

            if callable(value_parser_method):
                value = map(lambda val: apply(value_parser_method, [val]),
                            value)

        return value
Пример #10
0
    def postMessageToUser(self, request):
        request.needAuthType(request.ADMIN)
        request.checkArgs("user_ids", "message")
        requester = request.getAuthNameObj()
        requester.canDo("POST MESSAGES")
        if request["user_ids"] == "ALL USERS":
            user_ids = None
        else:
            user_ids = map(lambda x: to_long(x, "user id"),
                           MultiStr(request["user_ids"]))

        message_main.getActionsManager().postMessageToUser(
            user_ids, request["message"])
Пример #11
0
    def killUser(self, request):
        request.needAuthType(request.ADMIN)
        request.checkArgs("user_id", "ras_ip", "unique_id_val", "kill")
        requester = request.getAuthNameObj()
        loaded_users = user_main.getActionManager().getLoadedUsersByUserID(
            MultiStr(request["user_id"]), True)
        if request["kill"]:
            map(lambda loaded_user: self.__canKillUser(loaded_user, requester),
                loaded_users)
        else:
            map(
                lambda loaded_user: self.__canClearUser(
                    loaded_user, requester), loaded_users)

        ras_ips = MultiStr(request["ras_ip"])
        unique_id_vals = MultiStr(request["unique_id_val"])

        for i in xrange(len(loaded_users)):
            user_main.getActionManager().killUser(loaded_users[i].getUserID(),
                                                  ras_ips[i],
                                                  unique_id_vals[i],
                                                  request["kill"],
                                                  requester.getUsername())
Пример #12
0
 def changeCredit(self, request):
     """
         change credit of user
     """
     request.needAuthType(request.ADMIN)
     request.checkArgs("user_id", "credit", "credit_comment")
     requester = request.getAuthNameObj()
     user_id_multi = MultiStr(request["user_id"])
     loaded_users = user_main.getActionManager().getLoadedUsersByUserID(
         user_id_multi)
     map(self.__canChangeCredit, loaded_users,
         itertools.repeat(requester, len(loaded_users)))
     return user_main.getActionManager().changeCredit(
         user_id_multi, to_float(request["credit"], "credit"),
         requester.getUsername(), request.getRemoteAddr(),
         request["credit_comment"], loaded_users)
Пример #13
0
 def delUser(self, request):
     """
         delete users
     """
     request.needAuthType(request.ADMIN)
     request.checkArgs("user_id", "delete_comment", "del_connection_logs",
                       "del_audit_logs")
     requester = request.getAuthNameObj()
     user_id_multi = MultiStr(request["user_id"])
     loaded_users = user_main.getActionManager().getLoadedUsersByUserID(
         user_id_multi)
     map(self.__canDeleteUser, loaded_users,
         itertools.repeat(requester, len(loaded_users)))
     return user_main.getActionManager().delUser(
         user_id_multi, request["delete_comment"],
         request["del_connection_logs"], request["del_audit_logs"],
         requester.getUsername(), request.getRemoteAddr())
Пример #14
0
    def updateUserAttrs(self, request):
        """
            update user attributes
            
            user_id(string): user ids that should be updated, can be multi strings
            attrs(dic): dictionary of attr_name:attr_value. We say we want attr_name value to be attr_value
            to_del_attrs(dic): dic of attributes that should be deleted 
        """
        request.needAuthType(request.ADMIN)
        request.checkArgs("user_id", "attrs", "to_del_attrs")
        loaded_users = user_main.getActionManager().getLoadedUsersByUserID(
            MultiStr(request["user_id"]))
        admin_obj = request.getAuthNameObj()
        map(admin_obj.canChangeUser, loaded_users)

        to_del_attrs = requestDicToList(request["to_del_attrs"])
        return user_main.getActionManager().updateUserAttrs(
            loaded_users, request.getAuthNameObj(), request["attrs"],
            to_del_attrs)
Пример #15
0
    def changeInit(self, caller_ids, allow_not_defined):
        caller_id_list = map(lambda caller_id: caller_id.strip(),
                             MultiStr(caller_ids))

        for caller_id in caller_id_list:
            try:
                re.compile(caller_id)
            except:
                raise GeneralException(
                    errorText("GENERAL", "INVALID_CALLER_ID_PATTERN") %
                    caller_id)

        toLog("%s,%s" % (caller_ids, allow_not_defined), LOG_DEBUG)

        self.useGenerateQuery({
            "limit_caller_id":
            ",".join(caller_id_list),
            "limit_caller_id_allow_not_defined":
            ("1", "0")[allow_not_defined == False]
        })
Пример #16
0
 def getRasPortInfo(self, request):
     request.needAuthType(request.ADMIN)
     request.getAuthNameObj().canDo("GET RAS INFORMATION")
     request.checkArgs("ras_ip", "port_name")
     return ras_main.getActionManager().getRasPortInfo(
         request["ras_ip"], MultiStr(request["port_name"]))
Пример #17
0
 def __filterCurrentUsernames(self, request):
     username = MultiStr(request["voip_username"])
     current_username = MultiStr(request["current_username"])
     return filter(lambda username: username not in current_username,
                   username)
Пример #18
0
 def multiStrGetAll(self, request):
     request.checkArgs("str", "left_pad")
     return map(lambda x: x, MultiStr(request["str"], request["left_pad"]))
Пример #19
0
 def __parseFilter(self, _filter):
     sp = re.split("\s+", _filter)
     if len(sp) != 2:
         raise GeneralException(
             errorText("BANDWIDTH", "INVALID_FILTER") % _filter)
     return sp[0], ",".join(MultiStr(sp[1], False))
Пример #20
0
 def delPort(self, request):
     request.needAuthType(request.ADMIN)
     request.checkArgs("ras_ip", "port_name")
     request.getAuthNameObj().canDo("CHANGE RAS")
     return ras_main.getActionManager().delPort(
         request["ras_ip"], MultiStr(request["port_name"]))
Пример #21
0
 def changeInit(self,caller_id):
     """
         caller_id(string): an multi string of caller_ids
     """
     self.registerQuery("user","change",self.changeQuery,[])
     self.caller_ids = MultiStr(caller_id)
Пример #22
0
 def changeInit(self, ips):
     self.ips = MultiStr(ips)
     self.checkIPs(self.ips)
     self.useGenerateQuery(
         {"assign_ip": ",".join(map(lambda x: x, self.ips))})
Пример #23
0
 def changeInit(self,email_address):
     self.email_address=map(None,MultiStr(email_address))
     self.registerQuery("user","change",self.changeQuery,[])