How to load and install a python script and working on an ops assistant?

Created Feb 08, 2017 19:49:15Latest reply Mar 08, 2017 18:27:35 3240 7 0 0
  Rewarded E coins: 0 (problem resolved)
Hello everyone,


I have an AR1220 series router at my working place and im trying to send its running configuration file to a remote ftp server.
I used a python script to do this task, as i need to send this configuration file periodically to the ftp server.
I did following steps,
This is my python script

# coding=utf-8

import ops

 

def ops_condition(o):

                status, err_str = o.timer.relative("Timer",60)  //cyclic timer, timelength indicates 60 seconds

                return 0

 

def ops_execute(o):

                handle, err_desp = o.cli.open()                

                re0,re1,re2 = o.cli.execute(handle,"save test.cfg",{"save":"y"})  // the name of config file

                re3,re4,re5 = o.cli.execute(handle,"ftp 192.167.240.105 10021",{"User":"1","password":"1"})      //FTP server and user/password

                re6,re7,re8 = o.cli.execute(handle,"put test.cfg") //        the name of config file

                re9,re10,re11 = o.cli.execute(handle,"quit")

                result = o.cli.close(handle)

                return 0


First i uploaded the script to the router flash and installed the file using "ops install file file-name"

Then i created a python script assistant using the commands "ops" and "script-assistant python script-name "

then checked the ops assistant and the curent assistant state was ready.


https://mail.google.com/mail/u/0/?ui=2&ik=21960f91d7&view=fimg&th=159f31f60b08d77e&attid=0.0.1&disp=emb&attbid=ANGjdJ8dyNIVVnRJQ2LTXuVatLy-lETSg4QiLihxiwmbhHWiwyaPQuy9jy-g9zFxTgdqNGChVL1nYzd9aW5TE_8ET47cjD3lIIWRWZgDJpiF9DY301OetXyq_qUVMp8&sz=w1084-h160&ats=1486553801066&rm=159f31f60b08d77e&zw&atsh=1


These are the steps i did and after doing these i got following errors in my console.

Although i checked my ftp server for the config file it wasnt received. Can someone please guide me to do this?

Errors:


2017-2-2 13:43:12 00:00 Huawei %LINE/4/LOGIN_FAIL(s)[57]:Failed to login. 

(Ip=144.139.160.115, Reason="The number of users that log in to the server through the channel reaches the upper limit.")


2017-2-2 13:48:56 00:00 Huawei %OPSA/3/OPS_CLI_OPEN_FAIL(l)[64]:Script is savetoFTPserver.py, current event is Timer, instance is 903973420, fails to open a cli.


2017-2-6 10:46:29 00:00 Huawei %OPSA/3/OPS_EVENT_DISCARD_QUEUEFULL(l)[10]:Script is savetoFTPserver.py, Event Timer fails, instance is 903973188, the reason is "the script queue is full".


2017-2-6 11:28:32 00:00 Huawei %NTP/4/PACKET_LENGTH_WRONG(l)[16]:The received NTP packet is longer than or shorter than a valid packet. (RcvLen=9)



Thank you.





  • x
  • convention:

liyajun  Novice   Created Feb 08, 2017 19:49:16 Helpful(0) Helpful(0)

I tested the python script and it works well on my ar1220 router.
and the script as follow, I changed ftp server ip,port and the code annotation should begin with "#"

# coding=utf-8
import ops

def ops_condition(o):
status, err_str = o.timer.relative("Timer",60) ##cyclic timer, timelength indicates 60 seconds
return 0

def ops_execute(o):
handle, err_desp = o.cli.open()
re0,re1,re2 = o.cli.execute(handle,"save test.cfg",{"save":"y"}) ## the name of config file
re3,re4,re5 = o.cli.execute(handle,"ftp 192.167.240.147",{"User":"1","password":"1"}) ##FTP server and user/password
re6,re7,re8 = o.cli.execute(handle,"put test.cfg") ## the name of config file
re9,re10,re11 = o.cli.execute(handle,"quit")
result = o.cli.close(handle)
return 0
  • x
  • convention:

gululu  Admin   Created Feb 09, 2017 10:09:24 Helpful(0) Helpful(0)

@Lemon please help
  • x
  • convention:

Come on!
Mr_RMP     Created Feb 13, 2017 12:06:16 Helpful(0) Helpful(0)

Anyone ??
  • x
  • convention:

Mr_RMP     Created Feb 13, 2017 12:53:21 Helpful(0) Helpful(0)

Can you help me with the errors??
  • x
  • convention:

c00171712     Created Feb 13, 2017 14:34:28 Helpful(0) Helpful(0)

Mr_RMP 发表于 2017-2-13 12:53 Can you help me with the errors??
Please try to set the maximum VTY user to 15. eg.
[huawei]user-interface maximum-vty 15
  • x
  • convention:

Mr_RMP     Created Feb 21, 2017 15:04:19 Helpful(0) Helpful(0)

c00171712 发表于 2017-2-13 14:34 Please try to set the maximum VTY user to 15. eg.[huawei]user-interface maximum-vty 15
I think its not the case, Because it is already set to maximum Vty limit. Any more suggestions?
  • x
  • convention:

liyajun  Novice   Created Mar 08, 2017 18:27:35 Helpful(0) Helpful(0)

codes of script

This article contains more resources

You need to log in to download or view. No account?Register

x
  • x
  • convention:

Responses

Reply
You need to log in to reply to the post Login | Register

Notice:To ensure the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but not limited to politically sensitive content, content concerning pornography, gambling, drug abuse and trafficking, content that may disclose or infringe upon others' intellectual properties, including commercial secrets, trade marks, copyrights, and patents, and personal privacy. Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see“ Privacy Policy.”
If the attachment button is not available, update the Adobe Flash Player to the latest version!
Fast reply Scroll to top