mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 00:28:44 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -28,6 +28,7 @@ type AttrAddAccountActionTriggers struct {
|
||||
ActionTriggerIDs *[]string
|
||||
ActionTriggerOverwrite bool
|
||||
ActivationDate string
|
||||
Executed bool
|
||||
}
|
||||
|
||||
func (self *ApierV1) AddAccountActionTriggers(attr AttrAddAccountActionTriggers, reply *string) error {
|
||||
@@ -66,6 +67,7 @@ func (self *ApierV1) AddAccountActionTriggers(attr AttrAddAccountActionTriggers,
|
||||
}
|
||||
}
|
||||
at.ActivationDate = actTime
|
||||
at.Executed = attr.Executed
|
||||
if !found {
|
||||
account.ActionTriggers = append(account.ActionTriggers, at)
|
||||
}
|
||||
|
||||
28
cmd/cgr-tester/cdr_repl/post_server.py
Normal file
28
cmd/cgr-tester/cdr_repl/post_server.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
import SocketServer
|
||||
|
||||
class S(BaseHTTPRequestHandler):
|
||||
def _set_headers(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/html')
|
||||
self.end_headers()
|
||||
|
||||
def do_POST(self):
|
||||
# Doesn't do anything with posted data
|
||||
self._set_headers()
|
||||
print(self)
|
||||
#self.wfile.write("<html><body><h1>POST!</h1></body></html>")
|
||||
|
||||
def run(server_class=HTTPServer, handler_class=S, port=80):
|
||||
server_address = ('', port)
|
||||
httpd = server_class(server_address, handler_class)
|
||||
print('Starting httpd...')
|
||||
httpd.serve_forever()
|
||||
|
||||
if __name__ == "__main__":
|
||||
from sys import argv
|
||||
|
||||
if len(argv) == 2:
|
||||
run(port=int(argv[1]))
|
||||
else:
|
||||
run(port=12080)
|
||||
49
cmd/cgr-tester/cdr_repl/process_cdr.go
Normal file
49
cmd/cgr-tester/cdr_repl/process_cdr.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
var err error
|
||||
var cdrsMasterRpc *rpcclient.RpcClient
|
||||
var cdrsMasterCfgPath string
|
||||
var cdrsMasterCfg *config.CGRConfig
|
||||
cdrsMasterCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsreplicationmaster")
|
||||
if cdrsMasterCfg, err = config.NewCGRConfigFromFolder(cdrsMasterCfgPath); err != nil {
|
||||
log.Fatal("Got config error: ", err.Error())
|
||||
}
|
||||
cdrsMasterRpc, err = rpcclient.NewRpcClient("tcp", cdrsMasterCfg.RPCJSONListen, 1, 1, "json", nil)
|
||||
if err != nil {
|
||||
log.Fatal("Could not connect to rater: ", err.Error())
|
||||
}
|
||||
cdrs := make([]*engine.CDR, 0)
|
||||
for i := 0; i < 10000; i++ {
|
||||
cdr := &engine.CDR{OriginID: fmt.Sprintf("httpjsonrpc_%d", i),
|
||||
ToR: utils.VOICE, OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_PSEUDOPREPAID,
|
||||
Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
|
||||
SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC),
|
||||
Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}
|
||||
cdrs = append(cdrs, cdr)
|
||||
}
|
||||
var reply string
|
||||
for _, cdr := range cdrs {
|
||||
if err := cdrsMasterRpc.Call("CdrsV2.ProcessCdr", cdr, &reply); err != nil {
|
||||
log.Fatal("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
log.Fatal("Unexpected reply received: ", reply)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
|
||||
RUN echo 'deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 main' | tee '/etc/apt/sources.list.d/mongodb-org-3.2.list'
|
||||
|
||||
# install dependencies
|
||||
RUN apt-get -y update && apt-get -y install git bzr mercurial redis-server mysql-server python-pycurl python-mysqldb postgresql postgresql-client sudo wget freeswitch-meta-vanilla vim zsh mongodb-org tmux rsyslog ngrep
|
||||
RUN apt-get -y update && apt-get -y install git bzr mercurial redis-server mysql-server python-pycurl python-mysqldb postgresql postgresql-client sudo wget freeswitch-meta-vanilla vim zsh mongodb-org tmux rsyslog ngrep curl
|
||||
|
||||
# add mongo conf
|
||||
COPY mongod.conf /etc/mongod.conf
|
||||
|
||||
@@ -451,7 +451,10 @@ func (self *CdrServer) replicateCdr(cdr *CDR) error {
|
||||
}
|
||||
body = jsn
|
||||
}
|
||||
errChan := make(chan error)
|
||||
var errChan chan error
|
||||
if rplCfg.Synchronous {
|
||||
errChan = make(chan error)
|
||||
}
|
||||
go func(body interface{}, rplCfg *config.CdrReplicationCfg, content string, errChan chan error) {
|
||||
fallbackPath := path.Join(
|
||||
self.cgrCfg.HttpFailedDir,
|
||||
@@ -462,10 +465,13 @@ func (self *CdrServer) replicateCdr(cdr *CDR) error {
|
||||
if err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf(
|
||||
"<CDRReplicator> Replicating CDR: %+v, got error: %s", cdr, err.Error()))
|
||||
errChan <- err
|
||||
if rplCfg.Synchronous {
|
||||
errChan <- err
|
||||
}
|
||||
}
|
||||
if rplCfg.Synchronous {
|
||||
errChan <- nil
|
||||
}
|
||||
errChan <- nil
|
||||
|
||||
}(body, rplCfg, content, errChan)
|
||||
if rplCfg.Synchronous { // Synchronize here
|
||||
<-errChan
|
||||
|
||||
@@ -207,7 +207,7 @@ func (s *Session) Refund(lastCC *engine.CallCost, hangupTime time.Time) error {
|
||||
Increments: refundIncrements,
|
||||
}
|
||||
cd.Increments.Compress()
|
||||
utils.Logger.Info(fmt.Sprintf("Refunding duration %v with cd: %+v", refundDuration, cd))
|
||||
//utils.Logger.Info(fmt.Sprintf("Refunding duration %v with cd: %+v", refundDuration, cd))
|
||||
var response float64
|
||||
err := s.sessionManager.Rater().Call("Responder.RefundIncrements", cd, &response)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user