Hi, all.
Still, I can not execute python script. There is a function called push (see testflow.py
below). I placed command pusher.set(flow1) inside a push function.
From the kamailio I want to execute this "push" function(
python_exec("push");). However, it does not work. Though when I delete push
function, leaving just pusher.set(flow) commands, the script is executed when I run
kamailio. But I do not want to run the script with Kamailio during initialization process.
Any ideas about this issue?
Kamailio configs:
modparam("app_python", "script_name",
"/usr/local/etc/sip-router/testflow.py")
modparam("app_python", "mod_init_function", "mod_init")
modparam("app_python", "child_init_method", "child_init")
+++++++++++++++++++++++++++++++++++++
testflow.py file:
+++++++++++++++++++++++++++++++++++++
#! /usr/bin/python
import sys
import httplib
import json
class test(object):
def __init__(self, server):
self.server = server
def child_init(self, y):
return 0
def get(self, data):
ret = self.rest_call({}, 'GET')
return json.loads(ret[2])
def set(self, data):
ret = self.rest_call(data, 'POST')
return ret[0] == 200
def remove(self, objtype, data):
ret = self.rest_call(data, 'DELETE')
return ret[0] == 200
def installflowone():
call(["./installflows.sh"])
def rest_call(self, data, action):
path = '/wm/staticflowentrypusher/json'
headers = {
'Content-type': 'application/json',
'Accept': 'application/json',
}
body = json.dumps(data)
conn = httplib.HTTPConnection(self.server, 8080)
conn.request(action, path, body, headers)
response = conn.getresponse()
ret = (response.status, response.reason, response.read())
print ret
conn.close()
return ret
pusher = test('10.0.0.10')
flow1 = {
'switch':"00:00:08:00:27:62:77:1d",
"name":"flow-mod-1",
"cookie":"0",
"priority":"32000",
"ingress-port":"3",
"active":"true",
"actions":"output=4"
}
flow2 = {
'switch':"00:00:08:00:27:62:77:1d",
"name":"flow-mod-2",
"cookie":"0",
"priority":"30000",
"ingress-port":"4",
"active":"true",
"actions":"output=3"
}
def push(self):
pusher.set(flow1)
pusher.set(flow2)
def mod_init():
return test(object)
+++++++++++++++++++++++++++++++++++++++++++++
Best Regards,
Azamat Ailbayev
Mob.: +49 (0) 15215023005
Show replies by date