cancel
Showing results for 
Search instead for 
Did you mean: 

Python script triggered by UPM doesn't work properly

Python script triggered by UPM doesn't work properly

eyeV
New Contributor III
Hi everybody.
I use x480 with 16.1.2.

I have simple .py script like this.
import pexpect
import exsh
exsh.clicmd ('create log message "Starting NSCBackup!"')
for i in range(1,10):
print(i)
p = pexpect.spawn('/exos/bin/ssh -r 2 USERNAME@172.20.1.' + str(i))
idx = p.expect(['password', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('SECRETPASS')
idx = p.expect(['sCore', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('create log message "Not so cold backuper"')
idx = p.expect(['sCore', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('save')
idx = p.expect(['(y/N)', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('y')
idx = p.expect(['sCore', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('scp2 vr "VR-Default" sCore' + str(i) + '.cfg USERNAME@172.20.1.10:sCore' + str(i) + '.cfg')
idx = p.expect(['password', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('SECRETPASS')
p.sendline('exit')Not so beautiful, but it works!

So... I can run it with "load script NSCB.py". It works properly.

Then I created and scheduled UPM profile like this.
create upm profile NSCB
load script NSCB.py
.
create upm timer NSCBtimer
configure upm timer NSCBtimer profile NSCB
configure upm timer NSCBtimer at 11 5 2015 23 50 0 every 86400And I run it:
run upm profile "NSCB" I see some log messages, but script stucked.
11/06/2015 15:55:19.94 Starting NSCBackup!
11/06/2015 15:55:19.54 Launched profile NSCB for the event user-request

Any suggestions?
21 REPLIES 21

eyeV
New Contributor III
Yeah! I've fixed it! Thanks everybody!

eyeV
New Contributor III
Yes, I read it. Very useful document actually, but, as I say above, "from exos import api" line from this guide doesn't work for me. I guess I just don't fully understand something.

Did you read the Python Getting Started Guide?

http://www.extremenetworks.com/wp-content/uploads/2015/02/Python_Getting_Started_Guide.pdf

It might help you.

eyeV
New Contributor III
It was interesting. I've learned that there are two python environments in EXOS actually. This thread. So I can't execute "import exos.api" just by typing "run script blalbalba.py", but I can do it when I create process with this .py script. It's a bit confusing.

Moreover the "from exos import api" string doesn't work at all.

Sorry for my poor English )

GTM-P2G8KFN