转: 开源openacs server的使用脚本
转:http://guangming008.blog.163.com/blog/static/12039682010721411988/
?
openacs官方网站上关于如何使用的脚本比较简单,现在我把14个已经测试通过的脚本贴在下面,供有缘同行分享。
如有使用上的问题,可以发邮件xgmlovebee@126.com,共同讨论。现在已经把开发CPE TR69所需要的所有功能都测试一遍,不再需要花钱的ACS server。
openacs的设置
1??? CPE的设置
??????? http://192.168.1.86:8080/openacs/acs
??????? https://192.168.1.86:8443/openacs/acs
2??? openacs的设置
??????? 1)? 访问http://192.168.1.86:8080/openacs/index.jsf? 或者? https://192.168.1.86:8443/openacs/index.jsf
??????? 2)? 在"find CPE"页面,选择Hardware的型号,输入inform里SerialNumber,即可进行查询
??????? 3) 在查询页面"config"里可以进行用户名和密码设置,默认是没有的
??????? 4) 在"Configuration scripts"-->"Default"里输入要操作的脚本,点击保存
??????? 5) 在"find CPE"页面,选择型号输入serial number查询后 ,在显示的查询页面里点击"Connection request URL: "即可
openacs使用脚本
1??? 目前OpenAcs默认使用Default的脚本进行测试,暂不支持别的名称的脚本
2??? 重启脚本
??????? cpe.Reboot("commandKey");
3??? 恢复出厂设置脚本
??????? cpe.FactoryReset();
4??? CPE支持的方法GetRPCMethods
?? ?// this will output supported methods to server console
?? ?var methods = cpe.GetRPCMethods();
?? ?for (i = 0; i < methods.length; i++) {
? ??? ???? logger ('Method: '+methods[i]);
?? ?}
5??? 得到参数名称GetParameterNames?
?? ?var names = cpe.GetParameterNames ('.', true);
?? ?for (i = 0; i < names.length; i++) {
??? ??? ??? cpe.log (names[i].name + ' -> '+names[i].writable);
?? ?}
6??? 得到参数的值GetParameterValues
?? ?var parameters = new Array ();
?? ?parameters[0] = 'InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.';
?? ?//xgm add for CT test
?? ?//parameters[0] = 'InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.';
?? ?var response = cpe.GetParameterValues (parameters);
?? ?logger (response[0].name+'='+response[0].value);
?? ?注意:这里parameters参数最后的小数点问题,不是叶子节点,要加"."
7??? 设置参数的值
?? ?var parameters = new Array ();
?? ?parameters[0] = {name: 'InternetGatewayDevice.IPPingDiagnostics.Host', value: '192.168.0.1'};
?? ?// Encode parameter using default type xsd:string
?? ?parameters[1] = {name: 'InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions', value: '2'};
?? ?// set encoding type
?? ?parameters[2] = {name: 'InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions', value: '2', type: 'xsd:unsignedInt'};
?? ?//xgm add for CT test
?? ?parameters[0] = {name: 'InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.Enable', value: '0'};
?? ?parameters[1] = {name: 'InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.UserName', value: 'xgmtest'};
?? ?parameters[2] = {name: 'InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.Password', value: 'hahapassword'};
?? ?cpe.SetParameterValues (parameters, "commandKey");
8??? 软件升级
??????? 1)首先,服务器上要建立升级文件的目录,具体见"settings"-->"Firmware directory"
??????? 2) 然后通过网页上传升级文件,具体见"Hardware models"-->"具体CPE型号" -->"Firmware"-->"Create"
??????? 3) 设置CPE是否升级软件,具体见"Device profile"-->"Default"-->"添加具体CPE对应的升级版本"
??????? 4)等待period event time后,即可看到升级过程
????? 备注:img具体地址在http://192.168.1.86:8080/openacs/firmware/3.12L.02?? ------------->测试OK
?? ?可在"Configuration scripts"里写升级脚本。可以自定义控制升级。
?? ??? ?logger ("FIRWARE UPGRADE STARTING");?
?? ??? ?var response = cpe.Download ("daCommand", "1 Firmware Upgrade Image","http://192.168.1.86:8080/openacs/firmware/2.img", "", "", 1841146,"2.img");?
?? ??? ?logger ("FIRWARE UPGRADE st="+response.StartTime+" ct="+CompleteTime+" status="+response.Status);?
?? ??? ?logger ("FIRWARE UPGRADE DONE");?
????????? ?
?????? ?
9??? 增加节点AddOject------------测试OK
??????? cpe.AddObject ('InternetGatewayDevice.WANDevice.2.WANConnectionDevice.1.WANIPConnection.12.PortMapping.', '');
??????? cpe.AddObject ('InternetGatewayDevice.WANDevice.2.WANConnectionDevice.1.WANIPConnection.', '');
?? ?
10?? 下载配置文件-------------测试OK
??????? var response = cpe.Download ("daCommand", "3 Vendor Configuration File","http://192.168.1.86:8080/openacs/firmware/test.conf", "", "",000,"test.conf");
??????? logger ("st="+response.StartTime+" ct="+CompleteTime+" status="+response.Status);
11??? 上传配置文件------------测试OK
??????? var response = cpe.Upload("daCommand", "3 Vendor Configuration File","http://192.168.1.86:8080/openacs/", "", "",000,"upload.conf");
??????? logger ("st="+response.StartTime+" ct="+CompleteTime+" status="+response.Status);
??????? 注意:CPE上上传的流程完全正确,使用PUT方法,将文件发送成功,并且有上传成功的消息发出。
????????????? 但JBoss里不知道上传的文件放在哪里,暂不管,因为我们只做CPE的功能,ACS那边出错不管。
?????? ?
12??? 上传日志文件------------测试OK
??????? var response = cpe.Upload("daCommand", "2 Vendor Log File","http://192.168.1.86:8080/openacs/", "", "",000,"upload.log");
??????? logger ("st="+response.StartTime+" ct="+CompleteTime+" status="+response.Status);
??????? //In TR069 also define
??????? //??? 1 Firmware Upgrade Image
??????? //??? 2 Web Content
??????? //??? 3 Vendor Configuration File
??????? //??? 4 Vendor Log File
?????? ?
??????? 注意:CPE上上传的流程完全正确,使用PUT方法,将文件发送成功,并且有上传成功的消息发出。
????????????? 但JBoss里不知道上传的文件放在哪里,暂不管,因为我们只做CPE的功能,ACS那边不管。
13?? get attribute测试-----------------测试OK
??????? var parameters = new Array ();
??????? parameters[0] = 'InternetGatewayDevice.ManagementServer.ConnectionRequestURL';
??????? var response = cpe.GetParameterAttributes(parameters);
??????? logger (response[0].name+'='+response[0].value);
?????? ?
14?? set attribute测试----------------测试OK
??????? var parameters = new Array();
??????? parameters[0]=new Object;
??????? parameters[0].Name='InternetGatewayDevice.ManagementServer.ConnectionRequestURL';
??????? //here: 0-->notification off;? 1-->Passive notification;??? 2-->active notification
??????? parameters[0].Notification=0;
??????? parameters[0].NotificationChange=true;
??????? parameters[0].AccessListChange=true;
??????? parameters[0].AccessList= new Array ();
??????? parameters[0].AccessList[0]='subscriber';
??????? cpe.SetParameterAttributes (parameters);
15?? Delete Object测试-------------测试OK
??????? cpe.DeleteObject('InternetGatewayDevice.WANDevice.2.WANConnectionDevice.1.WANIPConnection.12.PortMapping.2.', '');